PPv2: Handle paypal-payments/oders in 'created' status (Z#23225625) (#5929)

This commit is contained in:
Martin Gross
2026-02-25 09:21:58 +01:00
committed by GitHub
parent cb9c4466f9
commit 7cce1c9219

View File

@@ -802,14 +802,17 @@ class PaypalMethod(BasePaymentProvider):
all_captures_completed = False all_captures_completed = False
else: else:
any_captures = True any_captures = True
if not (any_captures and all_captures_completed):
# Payment has at least one capture, but it is not yet completed
if any_captures and not all_captures_completed:
messages.warning(request, _('PayPal has not yet approved the payment. We will inform you as ' messages.warning(request, _('PayPal has not yet approved the payment. We will inform you as '
'soon as the payment completed.')) 'soon as the payment completed.'))
payment.info = json.dumps(pp_captured_order.dict()) payment.info = json.dumps(pp_captured_order.dict())
payment.state = OrderPayment.PAYMENT_STATE_PENDING payment.state = OrderPayment.PAYMENT_STATE_PENDING
payment.save() payment.save()
return return
# Payment has at least one capture and all captures are completed
elif any_captures and all_captures_completed:
if pp_captured_order.status != 'COMPLETED': if pp_captured_order.status != 'COMPLETED':
payment.fail(info=pp_captured_order.dict()) payment.fail(info=pp_captured_order.dict())
logger.error('Invalid state: %s' % repr(pp_captured_order.dict())) logger.error('Invalid state: %s' % repr(pp_captured_order.dict()))
@@ -827,6 +830,9 @@ class PaypalMethod(BasePaymentProvider):
payment.confirm() payment.confirm()
except Quota.QuotaExceededException as e: except Quota.QuotaExceededException as e:
raise PaymentException(str(e)) raise PaymentException(str(e))
# Payment has not any captures yet - so it's probably in created status
else:
return
finally: finally:
if 'payment_paypal_oid' in request.session: if 'payment_paypal_oid' in request.session:
del request.session['payment_paypal_oid'] del request.session['payment_paypal_oid']