gate abort_pending_payment_allowed by timeout and "APPROVED" state

This commit is contained in:
Lukas Bockstaller
2026-08-10 14:49:13 +02:00
parent 5f50d08707
commit 9878d7bfaa
+14
View File
@@ -519,6 +519,20 @@ class PaypalMethod(BasePaymentProvider):
def abort_pending_allowed(self):
return False
def abort_pending_payment_allowed(self, payment):
if payment.info_data.get('create_time', False):
create_time = datetime.fromisoformat(payment.info_data['create_time'])
if datetime.now(tz=timezone.utc) - create_time > timedelta(minutes=30):
return True
if payment.info_data.get('status', None) == "APPROVED":
# PayPal has recorded the customer approval. But not further processed it.
# The payment state will probably change with the next webhook we will receive,
# but in this time we cannot allow the customer to trigger a second payment.
return False
return False
def _create_paypal_order(self, request, payment=None, cart_total=None):
self.init_api()
kwargs = {}