From 5bc622bcfe1b539571b4e08f78dba935b10034f3 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 10 Jun 2024 14:10:02 +0200 Subject: [PATCH] PayPal: Validate proper payee set with ISU integration (#4206) --- src/pretix/plugins/paypal/payment.py | 5 ++++- src/pretix/plugins/paypal2/payment.py | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pretix/plugins/paypal/payment.py b/src/pretix/plugins/paypal/payment.py index 6455dea334..88b302ff62 100644 --- a/src/pretix/plugins/paypal/payment.py +++ b/src/pretix/plugins/paypal/payment.py @@ -229,7 +229,10 @@ class Paypal(BasePaymentProvider): kwargs['cart_namespace'] = request.resolver_match.kwargs['cart_namespace'] try: - if request.event.settings.payment_paypal_connect_user_id: + if self.settings.connect_client_id and not self.settings.secret: + if not request.event.settings.payment_paypal_connect_user_id: + raise PaymentException('Payment method misconfigured') + try: tokeninfo = Tokeninfo.create_with_refresh_token(request.event.settings.payment_paypal_connect_refresh_token) except BadRequest as ex: diff --git a/src/pretix/plugins/paypal2/payment.py b/src/pretix/plugins/paypal2/payment.py index c99e02a3f0..265c8d85b8 100644 --- a/src/pretix/plugins/paypal2/payment.py +++ b/src/pretix/plugins/paypal2/payment.py @@ -524,10 +524,13 @@ class PaypalMethod(BasePaymentProvider): kwargs['cart_namespace'] = request.resolver_match.kwargs['cart_namespace'] # ISU - if request.event.settings.payment_paypal_isu_merchant_id: - payee = { - "merchant_id": request.event.settings.payment_paypal_isu_merchant_id, - } + if self.settings.connect_client_id and self.settings.connect_secret_key and not self.settings.secret: + if request.event.settings.payment_paypal_isu_merchant_id: + payee = { + "merchant_id": request.event.settings.payment_paypal_isu_merchant_id, + } + else: + raise PaymentException('Payment method misconfigured') # Manual API integration else: payee = {}