Error: "Unable to change shipping method. Please try again." in PayPal popup

MatBrummitt
Contributor
Contributor

Hi,

 

We're updating our checkout with PayPal Standard checkout integration and currently have an issue.

 

We're initialising the PayPal buttons with paypal_sdk.Buttons() and we're passing in the following callback functions:

  1. onShippingAddressChange
  2. onShippingOptionsChange 

The problem:

When we include onShippingOptionsChange when initialising with paypal_sdk.Buttons(), we get a big red error message appearing within the PayPal window if the customer chooses "Pay with debit or credit card" without logging in.  As soon as they complete entering their address, the red error appears and reads: "Unable to change shipping method. Please try again.". Additionally, the console of the popup shows an error emitted by beaver-logger.js: "weasley_on_shipping_address_change_callback_generic_error" with "Must pass shippingAddress in data to handle changes in shipping address."

 

So we appear to have 2 errors (1 customer-facing and 1 in the console), relating to two different events (onShippingOptionsChange and onShippingAddressChange).  Both errors stop happening if we don't register a callback function for onShippingOptionsChange, even if we keep the onShippingAddressChange function.

 

Note: at this moment in time, onShippingOptionsChange callback function does nothing but do a basic console.log - it's just a skeleton function to see that we're at least receiving the callback.

 

Note: If the customer logs in, the onShippingAddressChange runs successfully, and makes a request to our server to validate the address, and fetch the applicable shipping options for the address.  The issue only seems to happen if the user chooses not to log in, but to check out with Debit or Credit Card instead.

 

Our use case:

  • Customer sets/changes their shipping address within PayPal popup, we get notified via the onShippingAddressChange callback. We validate the selected address is deliverable by sending the address to our server which provides response data.
  • If the address is not deliverable, we call actions.reject().
  • If the address is deliverable, the server response also includes applicable shipping options for the selected address, and we must update PayPal popup with these options...
  • We call actions.buildOrderPatchPayload() function, passing in shippingOptions. PayPal responds with a payload which we send to our server, so that it can use this payload to call the PayPal Orders API from the server.
  • Customer changes the selected shipping option, the client-side javascript notifies the server by passing along which shipping option was chosen.

I'm struggling to understand why we're getting the big red error message in the popup "Unable to change shipping method. Please try again." when we simply wish to register a callback for change of shipping option. The callback doesn't currently do anything other than a console log, and this log is not even appearing with my browser's console.

 

Note: We also pass in a function to createOrder when we call paypal_sdk.Buttons(). This sends a request to the server, which creates the order with PayPal on the server-side. The server response includes the order ID. This is handed to PayPal by returning it from the createOrder function. On the server-side we've tried passing in a dummy address initially, with some dummy shipping options, in case having none was causing this issue. However that hasn't made any difference.

 

Many thanks for your assistance.

 

Thanks

 

Mat

Login to Me Too
1 REPLY 1

3lon
Contributor
Contributor

setting up a sub is total garbage expirance and needs to be heavily fixed up, its so confusing trying to find anything related to setting up a sub plan and then now that I finally got it working its asking for a shipping address even tho I can't find anywhere to change that setting, PayPal needs to copy the dev flow of stripe in setting up a sub and checkout as currently im pulling out my hair and waisting time. and this is after spending 2 days trying to setup Braintree with no luck

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.