mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
PProv: Implement detection of wallets such as Google Pay and Apple Pay (#3444)
Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
@@ -59,7 +59,9 @@ from pretix import __version__
|
||||
from pretix.base.decimal import round_decimal
|
||||
from pretix.base.forms import SecretKeySettingsField
|
||||
from pretix.base.models import Event, OrderPayment, OrderRefund, Quota
|
||||
from pretix.base.payment import BasePaymentProvider, PaymentException
|
||||
from pretix.base.payment import (
|
||||
BasePaymentProvider, PaymentException, WalletQueries,
|
||||
)
|
||||
from pretix.base.plugins import get_all_plugins
|
||||
from pretix.base.services.mail import SendMailException
|
||||
from pretix.base.settings import SettingsSandbox
|
||||
@@ -219,6 +221,20 @@ class StripeSettingsHolder(BasePaymentProvider):
|
||||
]
|
||||
|
||||
extra_fields = [
|
||||
('walletdetection',
|
||||
forms.BooleanField(
|
||||
label=mark_safe(
|
||||
_('Check for Apple Pay/Google Pay') +
|
||||
' ' +
|
||||
'<span class="label label-info">{}</span>'.format(_('experimental'))
|
||||
),
|
||||
help_text=_("pretix will attempt to check if the customer's webbrowser supports wallet-based payment "
|
||||
"methods like Apple Pay or Google Pay and display them prominently with the credit card"
|
||||
"payment method. This detection does not take into consideration if Google Pay/Apple Pay "
|
||||
"has been disabled in the Stripe Dashboard."),
|
||||
initial=True,
|
||||
required=False,
|
||||
)),
|
||||
('postfix',
|
||||
forms.CharField(
|
||||
label=_('Statement descriptor postfix'),
|
||||
@@ -747,6 +763,15 @@ class StripeCC(StripeMethod):
|
||||
public_name = _('Credit card')
|
||||
method = 'cc'
|
||||
|
||||
@property
|
||||
def walletqueries(self):
|
||||
# ToDo: Check against Stripe API, if ApplePay and GooglePay are even activated/available
|
||||
# This is probably only really feasable once the Payment Methods Configuration API is out of beta
|
||||
# https://stripe.com/docs/connect/payment-method-configurations
|
||||
if self.settings.get("walletdetection", True, as_type=bool):
|
||||
return [WalletQueries.APPLEPAY, WalletQueries.GOOGLEPAY]
|
||||
return []
|
||||
|
||||
def payment_form_render(self, request, total) -> str:
|
||||
account = get_stripe_account_key(self)
|
||||
if not RegisteredApplePayDomain.objects.filter(account=account, domain=request.host).exists():
|
||||
|
||||
Reference in New Issue
Block a user