craftcms / commerce-paypal-checkout

PayPal Checkout gateway for Craft Commerce.
https://plugins.craftcms.com/commerce-paypal-checkout
MIT License
5 stars 10 forks source link

PayPal error: Shipping postal code required #26

Closed boboldehampsink closed 3 years ago

boboldehampsink commented 3 years ago

Description

PayPal Checkout always returns with the following error logged:

{"name":"UNPROCESSABLE_ENTITY","details":[{"field":"/purchase_units/0/shipping/address/postal_code","value":"","issue":"POSTAL_CODE_REQUIRED","description":"The specified country requires a postal code"}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"bea95fd032bf0","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-POSTAL_CODE_REQUIRED","rel":"information_link","method":"GET"}]}

Additional info

nfourtythree commented 3 years ago

Hi @boboldehampsink

Looks like the answer might be in the question in this one. Looking at the response:

{
  "name": "UNPROCESSABLE_ENTITY",
  "details": [
    {
      "field": "/purchase_units/0/shipping/address/postal_code",
      "value": "",
      "issue": "POSTAL_CODE_REQUIRED",
      "description": "The specified country requires a postal code"
    }
  ],
  "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
  "debug_id": "bea95fd032bf0",
  "links": [
    {
      "href": "https://developer.paypal.com/docs/api/orders/v2/#error-POSTAL_CODE_REQUIRED",
      "rel": "information_link",
      "method": "GET"
    }
  ]
}

It would appear that you are not providing a postal code (zipCode in Commerce terminology) for the shipping address and that seems to be required by PayPal for that specific country.

Hope this helps, thanks.

boboldehampsink commented 3 years ago

Hi @nfourtythree the problem is that this appears whether I do or do not send cart info to paypal

nfourtythree commented 3 years ago

Hi @boboldehampsink

The sendCartInfo setting only relates to the line items and the cart totals breaking down.

Looking at the PayPal API docs it seems that shipping is not a required attribute. In that case, we can add a setting to allow control over whether or not the shipping information is sent to PayPal.

I feel like there needs to be a separation between the cart info and the shipping due to the way that PayPal handles some payment validation and how/what form it shows in the pop-up.

I will add this as a new feature request.

Thanks!