I have integrated Paypal into my website but I don't quite understand how to deal with some scenarios. The integration involves both client side and server side. Ideally: 1. The user clicks the paypal button, my site calls my server. 2. My server calls the create order api, receives a) an order Id, which it saves into the database and b) a link to redirect the user to which it returns to my site. 3. My site redirects the user to the paypal interface. 4. The user approves the payment, gets redirected back to my site. 5. My site calls my server with the order id, the server calls the capture order api, funds transferred, everyone's happy. My question is how to deal with two things: A) Suppose the user cancels the order after step 3. How do I cancel the order ("created" status)? B) Suppose that something goes wrong after step 4. The user approved the transaction but my server never gets notified about that. I'd like to cancel the order after 1 day or so, because I don't want pending orders in my database (I wasn't notified of the user approval). How do I cancel the order ("approved" status)?
... View more