Nop's version of SquareUp breaks checkout page?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hi, does anyone else have any issues with the SquareUp Plugin breaking the checkout pages in 4.00? I get this message in both prod and test:


info: Microsoft.AspNetCore.Mvc.RedirectToRouteResult[1]
      Executing RedirectToRouteResult, redirecting to /onepagecheckout from route CheckoutOnePage.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action Nop.Web.Controllers.CheckoutController.Index (Nop.Web) in 204.6863ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 302.1967ms 302
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://ochapparel.com/onepagecheckout  
info: Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler[8]
      AuthenticationScheme: Authentication was successfully authenticated.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Executing action method Nop.Web.Controllers.CheckoutController.OnePageCheckout (Nop.Web) with arguments ((null)) - ModelState is Valid
info: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]
      Executing ViewResult, running view at path /Views/Checkout/OnePageCheckout.cshtml.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action Nop.Web.Controllers.CheckoutController.OnePageCheckout (Nop.Web) in 2081.9799ms
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An unhandled exception has occurred: The path in 'value' must start with '/'.
      Parameter name: value
System.ArgumentException: The path in 'value' must start with '/'.
Parameter name: value
   at Microsoft.AspNetCore.Http.PathString..ctor(String value)
   at Nop.Web.Framework.UI.PageHeadBuilder.GenerateScripts(IUrlHelper urlHelper, ResourceLocation location, Nullable`1 bundleFiles)
   at Nop.Web.Framework.UI.LayoutExtensions.NopScripts(IHtmlHelper html, IUrlHelper urlHelper, ResourceLocation location, Nullable`1 bundleFiles)
   at AspNetCore._Views_Shared__Root_Head_cshtml.<<ExecuteAsync>b__9_2>d.MoveNext() in C:\HostingSpaces\ochapparel\ochapparel.com\wwwroot\Views\Shared\_Root.Head.cshtml:line 67
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.<SetOutputContentAsync>d__30.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at AspNetCore._Views_Shared__Root_Head_cshtml.<ExecuteAsync>d__9.MoveNext() in C:\HostingSpaces\ochapparel\ochapparel.com\wwwroot\Views\Shared\_Root.Head.cshtml:line 39
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderPageCoreAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderPageAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderLayoutAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.<RenderAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.<ExecuteAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.<ExecuteAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeResultAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Nop.Services.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Session.SessionMiddleware.<Invoke>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nop.Core.Http.InstallUrlMiddleware.<Invoke>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nop.Core.Http.KeepAliveMiddleware.<Invoke>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An exception was thrown attempting to execute the error handler.
System.ArgumentException: The path in 'value' must start with '/'.
Parameter name: value
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.<>c.<UseNopExceptionHandler>b__1_1(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
      An unhandled exception has occurred: The path in 'value' must start with '/'.
      Parameter name: value
System.ArgumentException: The path in 'value' must start with '/'.
Parameter name: value
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.<>c.<UseNopExceptionHandler>b__1_1(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
      Sending file. Request path: '/errorpage.htm'. Physical path: 'C:\HostingSpaces\ochapparel\ochapparel.com\wwwroot\wwwroot\errorpage.htm'
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
6 years ago
Appears to be failing in Nop.Web.Framework - UI - PageHeadBuilder.cs at line 348 when dealing with https://js.squareup.com/v2/paymentform

When it gets to adding that it bombs out.
6 years ago
Found a work around. I had to download the JS from "https://js.squareup.com/v2/paymentform" and copy it into `Nop.Plugin.Payments.Square\Content\paymentform.js`

Then had to update these locations:
**Nop.Plugin.Payments.Square\Views\PaymentInfo.cshtml(4)**
_From_
`Html.AddScriptParts(ResourceLocation.Footer, "https://js.squareup.com/v2/paymentform");`

_To_
`Html.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Payments.Square/Content/paymentform.js");`


**Nop.Plugin.Payments.Square\Services\EventConsumer.cs(66)**
_From_
`eventMessage.Helper.AddScriptParts(ResourceLocation.Footer, "https://js.squareup.com/v2/paymentform");`

_To_
`eventMessage.Helper.AddScriptParts(ResourceLocation.Footer, "~/Plugins/Payments.Square/Content/paymentform.js");`


Not sure if this is the proper way to accomplish this. It would be best to have it pull from Square...but I'm not sure how.
6 years ago
We'll investigate it very soon - https://github.com/nopSolutions/nopCommerce/issues/2738
6 years ago
Hi.
We should exclude such remote scripts from bundling. You can see how it was done in this commit.
Thanks for the suggestion
6 years ago
RomanovM wrote:
Hi.
We should exclude such remote scripts from bundling. You can see how it was done in this commit.
Thanks for the suggestion


thanks I'll have to download it and try
6 years ago
Hello guys,

I would like to report another issue with the Square payment method plugin.
As you know we have a One Page Checkout plugin which uses AngularJS and after the page is loaded it makes an AJAX call to get the all the checkout data. This way any plugins (payment methods, shipping methods, etc) that add any scripts via the tag helpers never get their scripts loaded since the footer is already rendered.
We would suggest that any dynamically loaded plugins (e.g. payment methods, shipping methods, etc) should add their scripts directly rather than using the tag helpers. This way they will work all cases.

Regards,
Anton
6 years ago
Nop-Templates.com wrote:
Hello guys,

I would like to report another issue with the Square payment method plugin.
As you know we have a One Page Checkout plugin which uses AngularJS and after the page is loaded it makes an AJAX call to get the all the checkout data. This way any plugins (payment methods, shipping methods, etc) that add any scripts via the tag helpers never get their scripts loaded since the footer is already rendered.
We would suggest that any dynamically loaded plugins (e.g. payment methods, shipping methods, etc) should add their scripts directly rather than using the tag helpers. This way they will work all cases.

Regards,
Anton

Hi Anton,

Thanks!

If we add them using "<script>", then they won't be loaded because the default (built-in) one-page checkout has "payment info" step rendered using AJAX. None of these methods will work (rendering directly or using tag helpers). That's why we use the code from \Nop.Plugin.Payments.Square\Services\EventConsumer.cs to render the script when the one-page checkout page is rendered. I think the issue now is that we've hard-coded our default controller and action name - "Checkout" and "OnePageCheckout" (please see here). We should be compare with the route name rather than controller/action names.

Here is a work item
6 years ago
Nop-Templates.com wrote:
Hello guys,

I would like to report another issue with the Square payment method plugin.


Hi.
Now we identify a route by name instead of route values for adding scripts to the checkout page. You can see changes here.
Please check whether the problem persists.
6 years ago
Hello,

Thank you for looking into this issue!
However, I believe this solution will not work as well. We register a route with a different name for our One Page Checkout plugin which means that the scripts will not be added to the checkout page if our plugin is enabled since the route name is not "CheckoutOnePage".

Can you modify the code in a way that provides 3rd party plugin developers with the ability to add and remove their route names and then check against them rather than just the "CheckoutOnePage" route name?

Regards,
Anton
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.