mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
PayPal: Patch API client to cache access tokens (#2600)
This commit is contained in:
@@ -58,6 +58,7 @@ from pretix.base.payment import BasePaymentProvider, PaymentException
|
||||
from pretix.base.services.mail import SendMailException
|
||||
from pretix.base.settings import SettingsSandbox
|
||||
from pretix.multidomain.urlreverse import build_absolute_uri
|
||||
from pretix.plugins.paypal.api import Api
|
||||
from pretix.plugins.paypal.models import ReferencedPayPalObject
|
||||
|
||||
logger = logging.getLogger('pretix.plugins.paypal')
|
||||
@@ -197,7 +198,7 @@ class Paypal(BasePaymentProvider):
|
||||
|
||||
def init_api(self):
|
||||
if self.settings.connect_client_id and not self.settings.secret:
|
||||
paypalrestsdk.set_config(
|
||||
paypalrestsdk.api.__api__ = Api(
|
||||
mode="sandbox" if "sandbox" in self.settings.connect_endpoint else 'live',
|
||||
client_id=self.settings.connect_client_id,
|
||||
client_secret=self.settings.connect_secret_key,
|
||||
@@ -205,10 +206,11 @@ class Paypal(BasePaymentProvider):
|
||||
openid_client_secret=self.settings.connect_secret_key
|
||||
)
|
||||
else:
|
||||
paypalrestsdk.set_config(
|
||||
paypalrestsdk.api.__api__ = Api(
|
||||
mode="sandbox" if "sandbox" in self.settings.get('endpoint') else 'live',
|
||||
client_id=self.settings.get('client_id'),
|
||||
client_secret=self.settings.get('secret'))
|
||||
client_secret=self.settings.get('secret')
|
||||
)
|
||||
|
||||
def payment_is_valid_session(self, request):
|
||||
return (request.session.get('payment_paypal_id', '') != ''
|
||||
|
||||
Reference in New Issue
Block a user