paypalpaypal-rest-sdk

Get complete shipping address from PayPal while showing PayPal popup


I know two ways of getting the shipping address, both of which are not sufficient in my case:

But I need the complete shipping address while the PayPal popup is open.
Is there a way I could achieve this?

(The reason for my question is that our system is only able to calculate an updated order including updated shipping costs if we create a new (and complete) address in our database for it. I would like to update the total amount already while the PayPal popup is being shown.)


Solution

  • The answer to your question is no. During approval, PayPal only provides city, countryCode, postalCode, state. This is by design. More information prior to the payer approving the purchase, just from signing into the PayPal checkout, is considered too much of a buyer information leak and could be abused.

    If you need more information than city, countryCode, postalCode, state (i.e. the street address), you will need to prompt for an address yourself prior to opening the PayPal popup.

    Alternatively, the older flow is to not do shipping calculations during approval, and instead specify user_action:CONTINUE when creating the order. When specifying user_action:CONTINUE, the verbiage of the last button in the PayPal checkout will change from "Pay Now" to "Continue to Review Order". This is only a wording change. The behavior change to match the wording change must be done by your integration, i.e. when returning from approval you must show an order review step, and it is there that you can retrieve the shipping address of the payer who approved the order, perform any necessary calculations, prompt for shipping method selection if applicable, patch the order total using the Update Order Patch API operation if applicable, and most importantly display a final order review step with a final price for user confirmation, after which you will then commit (capture/authorize) the order resulting in a transaction (if successful).