transition "PENDING_REVIEW" paypal payment into "PENDING" state

This commit is contained in:
Lukas Bockstaller
2026-08-10 14:48:08 +02:00
parent e9dee4007e
commit 5f50d08707
+7 -4
View File
@@ -471,8 +471,8 @@ def webhook(request, *args, **kwargs):
elif payment.state in (OrderPayment.PAYMENT_STATE_PENDING, OrderPayment.PAYMENT_STATE_CREATED,
OrderPayment.PAYMENT_STATE_CANCELED, OrderPayment.PAYMENT_STATE_FAILED):
if sale['status'] == 'COMPLETED':
any_captures = False
all_captures_completed = True
any_pending_review = False
for purchaseunit in sale['purchase_units']:
for capture in purchaseunit['payments']['captures']:
try:
@@ -483,9 +483,9 @@ def webhook(request, *args, **kwargs):
if capture['status'] not in ('COMPLETED', 'REFUNDED', 'PARTIALLY_REFUNDED'):
all_captures_completed = False
else:
any_captures = True
if any_captures and all_captures_completed:
if capture['status_details']['reason'] == "PENDING_REVIEW":
any_pending_review = True
if all_captures_completed:
try:
payment.info = json.dumps(sale.dict())
payment.save(update_fields=['info'])
@@ -493,6 +493,9 @@ def webhook(request, *args, **kwargs):
prov.log_payment_duration(payment)
except Quota.QuotaExceededException:
pass
if any_pending_review:
payment.state = OrderPayment.PAYMENT_STATE_PENDING
payment.save()
elif sale['status'] == 'APPROVED':
try:
request.session['payment_paypal_oid'] = payment.info_data['id']