From 4ec24fc88444d81ee1cca5cf6a3c36d44a93ebd6 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 27 Apr 2020 11:39:57 +0200 Subject: [PATCH] PayPal: Show sale ID in backend --- src/pretix/plugins/paypal/payment.py | 7 ++++++- .../paypal/templates/pretixplugins/paypal/control.html | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pretix/plugins/paypal/payment.py b/src/pretix/plugins/paypal/payment.py index e6a721d756..9fb0e291c5 100644 --- a/src/pretix/plugins/paypal/payment.py +++ b/src/pretix/plugins/paypal/payment.py @@ -444,8 +444,13 @@ class Paypal(BasePaymentProvider): def payment_control_render(self, request: HttpRequest, payment: OrderPayment): template = get_template('pretixplugins/paypal/control.html') + sale_id = None + for trans in payment.info_data.get('transactions', []): + for res in trans.get('related_resources', []): + if 'sale' in res and 'id' in res['sale']: + sale_id = res['sale']['id'] ctx = {'request': request, 'event': self.event, 'settings': self.settings, - 'payment_info': payment.info_data, 'order': payment.order} + 'payment_info': payment.info_data, 'order': payment.order, 'sale_id': sale_id} return template.render(ctx) def payment_partial_refund_supported(self, payment: OrderPayment): diff --git a/src/pretix/plugins/paypal/templates/pretixplugins/paypal/control.html b/src/pretix/plugins/paypal/templates/pretixplugins/paypal/control.html index e41bdf6675..165c0c9172 100644 --- a/src/pretix/plugins/paypal/templates/pretixplugins/paypal/control.html +++ b/src/pretix/plugins/paypal/templates/pretixplugins/paypal/control.html @@ -4,6 +4,8 @@
{% trans "Payment ID" %}
{{ payment_info.id }}
+
{% trans "Sale ID" %}
+
{{ sale_id|default_if_none:"?" }}
{% trans "Payer" %}
{{ payment_info.payer.payer_info.email }}
{% trans "Last update" %}