SerjG
SerjG

Reputation: 3570

PayPal immediate payment (intent="sale") expiration time

I'm using the Express Checkout flow with the advanced server integration.

So I reserve items in real time once user has clicked the "Checkout" button and wait for the success\fail response. User can just close the browser tab and it will look like a long payment process (there is no way for the JS code to call the onCancel handler).

So it looks like I don't know if user has closed the browser or just fell asleep. Problem that I can't wait too long (more than ~5 mins) and I want to cancel the payment after this time. And it seems that I can't cancel the Payment myself. So user can come back and pay after N minutes (N > 5) for the item which has been un-reserved and is already out of stock.

This answer says:

user has three hours to approve of the PayPal payment

  1. Answer about 3 hours is a bit old so do we have any fresh DOCS about the immediate payment lifetime? Is it still 3 hours for the REST Express Checkout flow?
  2. 3 hours is too long period for me. Is there a way to setup the expiration time or timeout for the payment during creation?
  3. Is there a way to cancel the Payment? Payments API has no reference about it.

Upvotes: 2

Views: 997

Answers (2)

bluepnume
bluepnume

Reputation: 17108

You can do a GET on the PAY-XXXX id.

https://developer.paypal.com/docs/api/payments/#payment_get

The response comes with a create_time field. You should be able to check the delta from create_time -> now, and if it's > 5 minutes, don't accept the PAY-XXXX id / cancel the transaction in your database.

Does that work for your use case?

Also note: No money is moved until you call execute, so long as you prevent execute calls for old transactions, you should be ok.

Upvotes: 3

simplybee
simplybee

Reputation: 1

I think it is still 3 hours and there is no way to set it up during the payment creation. But i would assume that buyer cannot pay until he returns back to your site either by approving or without approving. So is it not possible to put a check in between the step where buyer comes back and then call to complete the payment is made?

Upvotes: 0

Related Questions