Search code examples
paypale-commercepaypal-rest-sdk

PP REST API charge tax and shipping without sending address?


Using the REST API, how can I charge tax or shipping if I send the user to PayPal to collect shipping information (and pay, of course)?

Doing some research it almost seems like that isn't possible, but I can't imagine that being the case. If I have to collect shipping information myself, the value prop for using PP is greatly reduced.


Solution

  • With the REST API, just like the Classic API, a PayPal payment is executed in three steps:

    1) Send initial information to PayPal to get a token. Redirect customer to PayPal. Customer authorizes payment. 2) Get payment details (like the shipping address) 3) Confirm payment.

    So, in this case, after getting the shipping address, you display an order review page to the customer where it will generate the shipping options and tax amount to the customer. They then have to select a "Confirm Order" button which will then finalize the charge to PayPal with the new tax/shipping and final amount.

    In API terms, the final step is done with the /execute command. This accepts the payer_id you received in step 2, and a transactions array that supports a new amount object.

    The amount object includes a details object that includes shipping, tax, handling fee, insurance, etc.

    Include the details the customer decides on your review page and PayPal will charge the updated amount to the customer's funding source of choice.