From 863165caaa9ffe2f59b3449f1e6651eaa1c54638 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 31 Oct 2018 14:47:44 +0100 Subject: [PATCH] Gracefully handle PayPal exceptions --- src/pretix/plugins/paypal/payment.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pretix/plugins/paypal/payment.py b/src/pretix/plugins/paypal/payment.py index 169c767a8a..b699e2d636 100644 --- a/src/pretix/plugins/paypal/payment.py +++ b/src/pretix/plugins/paypal/payment.py @@ -177,7 +177,7 @@ class Paypal(BasePaymentProvider): logger.error('Error on creating payment: ' + str(payment.error)) except Exception as e: messages.error(request, _('We had trouble communicating with PayPal')) - logger.error('Error on creating payment: ' + str(e)) + logger.exception('Error on creating payment: ' + str(e)) def checkout_confirm_render(self, request) -> str: """ @@ -231,7 +231,11 @@ class Paypal(BasePaymentProvider): ) } ]) - payment.execute({"payer_id": request.session.get('payment_paypal_payer')}) + try: + payment.execute({"payer_id": request.session.get('payment_paypal_payer')}) + except Exception as e: + messages.error(request, _('We had trouble communicating with PayPal')) + logger.exception('Error on creating payment: ' + str(e)) payment_obj.refresh_from_db() if payment.state == 'pending':