From a3489eea044ff8c8fb509105eca421b01a36e6f2 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 21 Nov 2018 11:14:03 +0100 Subject: [PATCH] PayPal: Properly detect pending sales --- src/pretix/plugins/paypal/payment.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/pretix/plugins/paypal/payment.py b/src/pretix/plugins/paypal/payment.py index b699e2d63..1eadb1618 100644 --- a/src/pretix/plugins/paypal/payment.py +++ b/src/pretix/plugins/paypal/payment.py @@ -237,6 +237,17 @@ class Paypal(BasePaymentProvider): messages.error(request, _('We had trouble communicating with PayPal')) logger.exception('Error on creating payment: ' + str(e)) + for trans in payment.transactions: + for rr in trans.related_resources: + if hasattr(rr, 'sale') and rr.sale: + if rr.sale.state == 'pending': + messages.warning(request, _('PayPal has not yet approved the payment. We will inform you as ' + 'soon as the payment completed.')) + payment_obj.info = json.dumps(payment.to_dict()) + payment_obj.state = OrderPayment.PAYMENT_STATE_PENDING + payment_obj.save() + return + payment_obj.refresh_from_db() if payment.state == 'pending': messages.warning(request, _('PayPal has not yet approved the payment. We will inform you as soon as the '