Hi, I’m trying to take a payment using WebPayments SDK and PaymentApi. I’m working through your reference doc at https://developer.squareup.com/reference/sdks/web/payments/card-payments alongside your YouTube video “Sandbox 101: End to End Payments with Web Payments SDK”. Both of which are V.good but not aligned very well at all (so trying code from both).
I’ve managed to generate a Payment Token in WebPayments (in index.html) and am trying to send it to the PaymentsApi Server.js file.
on doing this it looks at
module.exports = router(
post(‘/payment’, createPayment),
and here is where it throws an error.
In my console I get the following message:
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>The resource cannot be found.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
<br><br>
<b> Requested URL: </b>/payment<br><br>
<hr width=100% size=1 color=silver>
<b>Version Information:</b> Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0
</font>
</body>
and the Exception error is:
[HttpException]: The controller for path '/payment' was not found or does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
→
at createPayment (https://localhost:44302/Index.html:69:23)
at async HTMLButtonElement. (https://localhost:44302/Index.html:29:40)
The source of the error seems to be this line in Server.js
// micro provides http helpers
const { createError, json, send } = require(‘micro’);
Where it complains not able to find ‘micro’, in regards to Node.js.
I’ve check the directory where it is looking for this and the Node.js folder exists.
I have installed Node.js to my local machine and attached it via NuGet to my project too.
Am stumped as to what to look at next and have found nothing to help in the docs or forums.
Any ideas / questions appreciated.
Using Visual Studio Pro 2019 / ASP.Net WebApplication (.Net Framework) / C#