2
votes

I am trying to integrate PayPal express check out on our site using the REST API with the following workflow steps.

  1. Customer add item to cart, we have item list info (item price, qty, subtotal but no TAX and no shipping)
  2. Customer click on express checkout button, we pass an estimated subtotal to PayPal
  3. Customer create/select shipping address
  4. Customer click submit
  5. Customer back to our site with a shipping address
  6. We calculate customer’s shipping charge and tax based on the shipping address
  7. We display the order preview with a grand total = shipping + tax +subtotal.
  8. 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/

  1. For example we have item abc $10 QtY=1 Subtotal =$10
  2. We call payment api and set intent to “authorize”, send amount total: $10
  3. Step #3 above on paypal site
  4. Step #4 above on paypal site
  5. 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
  6. Now we have total = $10 (subtotal) + $2 (shipping) + $1.5 (tax)= $13.5
  7. We display the order preview with item subtotal, shipping, tax grand total
  8. 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:

  1. 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.

  2. 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.

1

1 Answers

1
votes

A little rectification and re-summarize the flow:

  1. For example item abc $10 QtY=1 Subtotal =$10
  2. Call payment api and set intent to “authorize”, send amount total: $10 (identify "payment_method": "paypal" in the payer object)
  3. Payment api response returns the HATEOAS link approval_url and use that to redirect customer to PayPal checkout page
  4. Step #3 above on paypal site
  5. Step #4 above on paypal site, and customer is returned to your site
  6. Call execute api with HATEOAS link (execute link) from Step#2 and "payer_id" obtained from the return url, PayPal responds with a new set of HATEOAS links, including a capture link that you use to capture the payment. Also, you will be able to obtain the shipping_address from the payer_info object of the Json response
  7. Now calculate the shipping & tax, total = $10 (subtotal) + $2 (shipping) + $1.5 (tax)= $13.5
  8. Display the order preview with item subtotal, shipping, tax grand total
  9. When customer confirms the order, call the Capture api (HATEOAS from Step#6) with a new amount $13.5 (higher than step #2)

is_final_capture=true is an api request parameter, not a confirmation from PayPal, it indicates that this is a full capture rather than a partial capture. What PayPal would confirm is "state": "completed" in the json response

You will not be able to get the billing address of the buyer, the feature has to be reviewed and with special access granted on your account, you may turn to PayPal service for further details