PayPalSmartPaymentButtons Error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi.
I have an error trying to use this plugin - Error: Expected an order id to be passed.

I have checked the logs and there are many errors from PayPal API of this type:
{
            "field": "/purchase_units/@reference_id=='c319a32c-32f6-4b40-8d30-73faeec2beb1'/items/0/unit_amount/value",
            "value": "652,94",
            "location": "body",
            "issue": "INVALID_PARAMETER_SYNTAX",
            "description": "The value of a field does not conform to the expected format."
        }

My project has german localization, so I would say the problem is the decimal formatting of sent values - comma instead of point.

Could you please fix this error.
4 years ago
If you don't get a reply form the team soon, you may want to create an issue:
https://github.com/nopSolutions/nopCommerce/issues/
4 years ago
Hi,

I've had the same problem with the amount passed to PayPal.
In their reference guide, the validation pattern is:
^((-?[0-9]+)|(-?([0-9]+)?[.][0-9]+))$.
https://developer.paypal.com/docs/api/orders/v2/#definition-money

As you said "problem is the decimal formatting".
Need to update the code to change the culture variant of the currency
Example:
In the ServiceManager
ItemTotal = new PayPalCheckoutSdk.Orders.Money { CurrencyCode = currency, Value = (_workContext.WorkingCurrency.Rate * itemTotal).ToString("F", CultureInfo.InvariantCulture) }


Another problem I faced is the phone number needs to be numerical only.  nopCommerce allows a "+" for example in the phone number, while PayPal does not.
https://developer.paypal.com/docs/api/orders/v2/#definition-phone

Simply remove any non-numerical values from the phone number (billing and shipping) before passing to PayPal.
Example:
In the ServiceManager
var newPhone = new string(billingAddress.PhoneNumber.Where(c => char.IsDigit(c)).ToArray());


After fixing the two, I've haven't had an issue.

Hope this helps.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.