What is the API Flow for a Product Button Checkout

MattKennedy
Contributor
Contributor

Hello,

 

I am working on the PayPal REST API with the latest JavaScript SDK and started with a set of PayPal buttons on the product page, but can't understand how to add a set of Shipping Method options to an existing order via the PATCH request, what is the flow...

 

The new customer lands on the product and clicks the Pay By Card PayPal button and here we go...

 

  1. Create a new order (We know nothing about this customer other than he wants to buy Product X)
  2. Customer fills in shipping info on the PayPal guest checkout with a shipping address and clicks continue triggering the onShippingChange: function.
  3. Now we know the customers address location our App generates some available shipping rates JSON...

 

And here is where I can't find any docs to get those rates to the existing order via a PATCH request so that the customer can pick a shipping method.

Login to Me Too
2 REPLIES 2

MTS_Chiranjeevi
Moderator
Moderator

Good day @MattKennedy, 

 

Thank you for posting to the PayPal community.

 

Update/Patch Order API : https://developer.paypal.com/docs/api/orders/v2/#orders_patch. 

 

NoteThe shipping callback is a method passed in the paypal.Buttons function to receive and handle changes the buyer has made to their shipping information. If you have passed any shipping.options to actions.order.create(), then whenever a new option is selected, the shipping callback, onShippingChange is called. You can access the selected options in the data parameter passed as follows:

 

Please refer the below detailed guide link : 

 

https://developer.paypal.com/docs/checkout/standard/customize/shipping-options/#link-shippingcallbac... 

 

Sincerely,

Chiranjeevi

PayPal/Braintree MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

MattKennedy
Contributor
Contributor

Looking at this, all shipping options need to be passed on create order, but we can't do that because don't know the buyers delivery location yet, so we can't just offer all shipping methods.

 

Lets just pretend that we have live shipping rates based on shoppers delivery location, so passing shipping methods on initial orderCreate is not feasible.

 

Is it best to get the users shipping address, triggering the onShippingChange then, create a new order on PayPal, this new order contains the users shipping address and relevant shipping options based on the delivery location?

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.