Always register ApplePay domains in livemode (#2154)

This commit is contained in:
Martin Gross
2021-07-21 09:41:57 +02:00
committed by GitHub
parent 7fef81bdef
commit c1dfec20f6

View File

@@ -54,13 +54,28 @@ def stripe_verify_domain(event, domain):
prov = StripeCC(event)
account = get_stripe_account_key(prov)
# Yes, we could just use the **prov.api_kwargs
# But since we absolutely need to always issue this call with live keys,
# we're building our api_kwargs here by hand.
# Only if no live connect secret key is set, we'll fall back to the testmode keys.
# But this should never happen except in scenarios where pretix runs in devmode.
if prov.settings.connect_client_id and prov.settings.connect_user_id:
api_kwargs = {
'api_key': prov.settings.connect_secret_key or prov.settings.connect_test_secret_key,
'stripe_account': prov.settings.connect_user_id
}
else:
api_kwargs = {
'api_key': prov.settings.secret_key,
}
if RegisteredApplePayDomain.objects.filter(account=account, domain=domain).exists():
return
try:
resp = stripe.ApplePayDomain.create(
domain_name=domain,
**prov.api_kwargs
**api_kwargs
)
except stripe.error.StripeError:
logger.exception('Could not verify domain with Stripe')