Square Payment not working with 4.10

1 year ago
I have a fresh install of 4.1, and setup Square.  

Sandbox works as expected, and also populates a fake location correctly.

It doesn't seem to store the Business Location in the settings dropdown. And after hitting obtain access token it populates the dropdown with Locations (2) then when I save the App Secret, Business Locations, and Access Token all show blank.  Successfully configured message.

When I try to checkout I receive this error "Location is a required parameter for payment requests".  When I view the database it has the locationId set correctly.

I have tried several times and cannot checkout.  I even added the locationID to the javascript in the plugin, and it populates the javascript, but still nothing.

Any help please.  I have some of the Nop-Templates.com Emporium theme and plugins install, tried with normal checkout and one page checkout, and also added the nonce fix for Nop-Templates.com.

In Plugins:
Plugins/Payments.Square/Views/PaymentInfo.cshtml

var paymentForm = new SqPaymentForm({
            applicationId: '@squarePaymentSettings.ApplicationId',
            locationId: '@squarePaymentSettings.LocationId',
            inputClass: 'square-input',






1 year ago
Has this been figured out yet? we are having the same issue.
1 year ago
Hi.
Did you try to look at log? What error messages are there?
1 year ago
From my original post:

"When I try to checkout I receive this error "Location is a required parameter for payment requests".  When I view the database it has the locationId set correctly."
1 year ago
That is not the exact same issue here. The sandbox square account works fine. When I change to the live square account, it pulls from Square the location options, I choose the location from the square options it should be set to and save and nopcommerce confirms it has saved the settings, but if I refresh the screen it has no location saved. thus the error when trying to process a transaction, Location is required, that would be Nopcom not sending a location to square when trying to process the transaction because it didn't save the location setting when the payment was being configured, maybe?

Log Entry 1 {Error while placing order. Error 1: Location is a required parameter for payment requests.}

Log Entry 2 {Nop.Core.NopException: Location is a required parameter for payment requests
   at Nop.Plugin.Payments.Square.SquarePaymentMethod.ProcessPayment(ProcessPaymentRequest paymentRequest, Boolean isRecurringPayment)
   at Nop.Plugin.Payments.Square.SquarePaymentMethod.ProcessPayment(ProcessPaymentRequest processPaymentRequest)
   at Nop.Services.Payments.PaymentService.ProcessPayment(ProcessPaymentRequest processPaymentRequest) in E:\nopCommerce\sources\src\Libraries\Nop.Services\Payments\PaymentService.cs:line 187
   at Nop.Services.Orders.OrderProcessingService.GetProcessPaymentResult(ProcessPaymentRequest processPaymentRequest, PlaceOrderContainer details) in E:\nopCommerce\sources\src\Libraries\Nop.Services\Orders\OrderProcessingService.cs:line 1387
   at Nop.Services.Orders.OrderProcessingService.PlaceOrder(ProcessPaymentRequest processPaymentRequest) in E:\nopCommerce\sources\src\Libraries\Nop.Services\Orders\OrderProcessingService.cs:line 1535}


Log Entry 3 short message {Square payment error: Error calling ListLocations: {"errors":[{"category":"AUTHENTICATION_ERROR","code":"UNAUTHORIZED","detail":"Your request did not include an `Authorization` http header with an access token. The header value is expected to be of the format \"Bearer TOKEN\" (without quotation marks), where TOKEN is to be replaced with your access token (e.g. \"Bearer ABC123def456GHI789jkl0\"). For more information, see https://docs.connect.squareup.com/api/connect/v2/#requestandresponseheaders. If you are seeing this error message while using one of our officially supported client libraries, please report this to [email protected] "}]}.

Log Entry 3 Long message {Square.Connect.Client.ApiException: Error calling ListLocations: {"errors":[{"category":"AUTHENTICATION_ERROR","code":"UNAUTHORIZED","detail":"Your request did not include an `Authorization` http header with an access token. The header value is expected to be of the format \"Bearer TOKEN\" (without quotation marks), where TOKEN is to be replaced with your access token (e.g. \"Bearer ABC123def456GHI789jkl0\"). For more information, see https://docs.connect.squareup.com/api/connect/v2/#requestandresponseheaders. If you are seeing this error message while using one of our officially supported client libraries, please report this to [email protected] "}]}
   at Square.Connect.Api.LocationsApi.ListLocationsWithHttpInfo()
   at Square.Connect.Api.LocationsApi.ListLocations()
   at Nop.Plugin.Payments.Square.Services.SquarePaymentManager.GetActiveLocations()
1 year ago
Thanks for the details. We'll investigate it.
1 year ago
If you log in to the Square dashboard and set the API to the July version it works fine. It is the current api that must of changed the request header format I am guessing.
1 year ago
I only see two options in the dropdown in Square:

2018-07-12
2018-09-18 (latest)

Ours was set to 2018-07-12, hence the first post from beginning of Aug.

Can you elaborate?
1 year ago
Maybe switch the the newer API. Try to add it. Then when the payment fails, switch back to the old API. After about 30 attempts and checking another nop4.10 square combo. That finally worked..
1 year ago
Hi

I am still struggling with this issue. I already tried changing back and forth the API versions and already added the code fix recommended by nop-templates for the 'Nop One Page Checkout' (see below) and added the code
 locationId: '@squarePaymentSettings.LocationId',


And yet, I am still seeing this same error - 'Location is a required parameter for payment requests'

Nop templates code:

function getCardNonceSquare(data) {
            var selectedStoredCardId = $('#@Html.IdFor(model => model.StoredCardId)').val()
            if (!submitForm && (!selectedStoredCardId || selectedStoredCardId == '0')) {
                if (paymentForm) {
                    paymentForm.requestCardNonce();
                }
                return false;
            }
            else if (onePageCheckout) {
                submitForm = false;
                PaymentInfo.save();
            }
        }

        if (realOnePageCheckout) {

            $('.complete-button').on('click', getCardNonceSquare);
        } else {

            $('input.payment-info-next-step-button').on('click', getCardNonceSquare);
        }


Did anyone here find a solution that actually works?

P.s. in my case sandbox mode didn't work either...