I'm integrating paypal Checkout
with server-side SDK
. I'm trying to figure out how to handle errors and I can't get the answers to these questions:
1)
In CreateOrder , after receiving the response from Paypal, I save the data in DB. If saving data gives an exception, the data will be inconsistent between what is in Paypal
and what I have in DB. Is there any way to delete the created order, in Paypal? (This is because I'd thinking try to make the payment again, but as the order_id
generated has associated the same invoice_Id
, it will cause problems, right?). I've notice there is no "Delete" in Orders API
, so how can I delete it?
2)
If saving data in my DB gives an exception after CaptureOrder
, I will have to ask for a refund
for that capture_id
to have the same information in DB and Paypal
. After the refund
is done, I'd like to make the payment again, can I used the same invoice_id
?
Orders that have not been captured/completed cannot be deleted. Simply forget about them and do not capture them. The invoice_id can be used in other orders, since it only matters for completed orders.
Re-using an invoice ID after refunding an order likely will not work, since it is meant to prevent such duplicate payments. But that something you would need to test yourself.