Square Payment not working with 4.10

1 year ago
Neither adding this code -

if(!_squarePaymentSettings.UseSandbox)
               paymentRequest.CustomValues.Add("Location", _squarePaymentSettings.LocationId);



or adding the access code manually worked for me.

Does anyone else have a fix. Are Nopcommerce Team working on this bug fix?
1 year ago
wunpac wrote:
Neither adding this code -

if(!_squarePaymentSettings.UseSandbox)
               paymentRequest.CustomValues.Add("Location", _squarePaymentSettings.LocationId);



or adding the access code manually worked for me.

Does anyone else have a fix. Are Nopcommerce Team working on this bug fix?


did you add the location code from square, squarepaymentsettings.locationid
1 year ago
you need to set the squarepaymentsettings.accesstoken value under all settings. it's definitely a bug around the code you quoted, but you don't need to edit the code.

start the process on the admin form to configure. when the location doesn't show up after saving, go set the accesstoken you get from square and then go back to the config form. the location should then show up.

you could also just manually set the remaining values if you snoop the html...
1 year ago
Hi all.
We assume that this error occurred due to incorrect plugin configuration, which in turn was a consequence of bad configuration page design.
We slightly changed the configuration process, and also updated the Square.Connect library to the latest version. Changes have been added to the develop branch, but you can apply this commit for version 4.10 and check whether the error has disappeared.
1 year ago
Thanks for all the suggestions and the fix!
1 year ago
FYI, this still doesn't work right. I have followed the directions exactly. I still end up having to manually set the values in the all settings.

It breaks when I try to obtain the access token. When I get redirected back to the site it says the plugin isn't installed, along with another message I can't remember right now. It clearly is installed.

Manually setting the values works.


I've also tried upgrading to the latest develop branch... that's completely broken; working through why now...

src\Presentation\Nop.Web\Plugins\Payments.Square\Views\_ViewImports.cshtml(9,11): error CS0234: The type or namespace name 'Plugin' does not exist in the namespace 'Nop' (are you missing an assembly reference?)

The name 'SquarePaymentDefaults' does not exist in the current context
1 year ago
gvanosdol wrote:
FYI, this still doesn't work right. I have followed the directions exactly. I still end up having to manually set the values in the all settings.

It breaks when I try to obtain the access token. When I get redirected back to the site it says the plugin isn't installed, along with another message I can't remember right now. It clearly is installed.

Manually setting the values works.


I've also tried upgrading to the latest develop branch... that's completely broken; working through why now...

src\Presentation\Nop.Web\Plugins\Payments.Square\Views\_ViewImports.cshtml(9,11): error CS0234: The type or namespace name 'Plugin' does not exist in the namespace 'Nop' (are you missing an assembly reference?)

The name 'SquarePaymentDefaults' does not exist in the current context


stack trace:

   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(RazorCodeDocument codeDocument, String generatedCode)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(String relativePath)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.OnCacheMiss(String normalizedPath)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet`1 expirationTokens, String relativePath, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromPath(String executingFilePath, String pagePath, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.GetView(String executingFilePath, String viewPath, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.GetView(String executingFilePath, String viewPath, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync[TFilter,TFilterAsync]()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   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()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 94
   at Nop.Services.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) in C:\Users\user\source\repos\bbk\src\Libraries\Nop.Services\Authentication\AuthenticationMiddleware.cs:line 79
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Nop.Core.Http.InstallUrlMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in C:\Users\user\source\repos\bbk\src\Libraries\Nop.Core\Http\InstallUrlMiddleware.cs:line 51
   at Nop.Core.Http.KeepAliveMiddleware.Invoke(HttpContext context, IWebHelper webHelper) in C:\Users\user\source\repos\bbk\src\Libraries\Nop.Core\Http\KeepAliveMiddleware.cs:line 50
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.<>c.<UseNopExceptionHandler>b__1_1(HttpContext context) in C:\Users\user\source\repos\bbk\src\Presentation\Nop.Web.Framework\Infrastructure\Extensions\ApplicationBuilderExtensions.cs:line 84
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context)
1 year ago
it appears this has something to do with the UsePluginsShadowCopy setting. I set it to false to try and fix azure scale out issues, which seemed to work. Setting it back to true seems to resolve the exception I was getting that's shown above.

I have to do my real job for a while... anybody have any ideas? It's some kind of path mismatch I gather, but I haven't had time to trace it down to the root cause (yet).

Thanks in advance.
1 year ago
I've been banging my head with this for months, sometimes a certain combination of clicks and it works only to fail again a few months later.  I'll be honest in that I'm not a web dev or have any experience of coding, so it's a miracle I have a functioning site at all.

I have managed to find the Nop.Plugin.Payments.Square.dll, but no .cs files, not that I'd likely have anything to edit it with on a mac anyway and as for manually setting the location - where do you even do this?

I can find my way around the back office, find files on my server, but that's about it.  Anybody able to give a step wise, descriptive guide how to fix this annoying issue?


EDIT - Now, all I get is this error:

An error occurred while obtaining an access token
× The remote server returned an error: (401) Unauthorized.
1 year ago
Any updates yet?