Have a bit of a sticky situation, working on upgrading an existing codebase to use the v2 REST API from PayPal for an ecommerce checkout and would like to replace billing/shipping info with the (verified) address data from the response after authorizing the requested payment total. However, I would need to recalculate real-time shipping costs and taxes based on the address returned from PayPal if it does not match the address supplied in our checkout flow. Is there a way I can modify the requested amount with new costs after the initial authorization without voiding the original? The documentation isn’t the most clear, and seems to randomly jump between v1 and v2 API docs.
Question posted in Paypal API
The official documentation to get you started can be found here.
The official documentation to get you started can be found here.
2
Answers
All I needed to do was run a GET request to
/v2/checkout/orders/(paypal order token)
after returning from PayPal in order to pull in the address they supplied prior to the authorization request to compare against the original address and recalculate/update the order as needed, and run a PATCH to the order endpoint to set the new value before completing the authorization request.Yes. Submit the modified amount(s) in your v2/orders capture call.