My eCommerce platform charges the customer when the item ships, not when it is ordered. Would this be the correct flow to do this? Note that customer's can pay using CardFields or PaypalButtons.
First I create a POST request to
${process.env.PAYPAL_ENDPOINT}/v2/checkout/orders
to create the order. The intent is set to "AUTHORIZE".
Then I send the order ID back to my frontend to pass it to onApprove.
Then no other calls are made until we ship the product. This can be days later. Then a POST request is made to ${process.env.PAYPAL_ENDPOINT}/v2/checkout/orders/${req.body.paypalOrderId}/capture
.
I thought I would have to confirm the order, but it says I am missing a parameter, but payment_source should be attached on its own in the frontend to my understanding (unless I am approved to collect it on my own, which I am not).
This method does work when capturing it immediately, but I'm unsure if it will work in, for example, 28 days which is the max number of days to capture a payment.
onApprove
should immediately call your server which should in turn do an Orders Authorize API call https://developer.paypal.com/docs/api/orders/v2/#orders_authorize , and display success or failure to the customer based on that authorize API response.
The payments.authorization.id that is returned can be used for 28 days for capture with https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture when you are ready to ship