I am trying to integrate PayPal express check out on our site using the REST API with the following workflow steps.
- Customer add item to cart, we have item list info (item price, qty, subtotal but no TAX and no shipping)
- Customer click on express checkout button, we pass an estimated subtotal to PayPal
- Customer create/select shipping address
- Customer click submit
- Customer back to our site with a shipping address
- We calculate customer’s shipping charge and tax based on the shipping address
- We display the order preview with a grand total = shipping + tax +subtotal.
- We do another api call to paypal to execute an payment
To match the above step, here are my understanding based on the api https://developer.paypal.com/docs/api/
- For example we have item abc $10 QtY=1 Subtotal =$10
- We call payment api and set intent to “authorize”, send amount total: $10
- Step #3 above on paypal site
- Step #4 above on paypal site
- Paypal respond back with an authorization object contains authorization id and HATEOAS link for capture the payment In the respond object we can also get payer object to calculate shipping and tax
- Now we have total = $10 (subtotal) + $2 (shipping) + $1.5 (tax)= $13.5
- We display the order preview with item subtotal, shipping, tax grand total
- When customer confirm the order, we do https://developer.paypal.com/docs/api/#authorizations 8.1 We call Authorization with the auth id obtained on step #5 8.2 We call Capture with the auth id and a new amount $13.5 (higher than step #2) 8.3 Paypal confirm with is_final_capture=true
My question are:
Is this the correct workflow for express checkout? It’s a little more complicate than regular payment since we have to calculate shipping/tax on our end.
Will paypal pass us the billing address from above api call? I didn’t see billing address in the response object. If not how do we get it?
Please note these questions are related to REST api not classic express checkout. Thanks in advance.