mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Merge branch 'Add-Promptpay-for-stripe' (#5670)
This commit is contained in:
@@ -137,7 +137,7 @@ logger = logging.getLogger('pretix.plugins.stripe')
|
|||||||
# Real-time payments
|
# Real-time payments
|
||||||
# - Swish: ✓
|
# - Swish: ✓
|
||||||
# - PayNow: ✗
|
# - PayNow: ✗
|
||||||
# - PromptPay: ✗
|
# - PromptPay: ✓
|
||||||
# - Pix: ✗
|
# - Pix: ✗
|
||||||
#
|
#
|
||||||
# Vouchers
|
# Vouchers
|
||||||
@@ -440,6 +440,14 @@ class StripeSettingsHolder(BasePaymentProvider):
|
|||||||
'before they work properly.'),
|
'before they work properly.'),
|
||||||
required=False,
|
required=False,
|
||||||
)),
|
)),
|
||||||
|
('method_promptpay',
|
||||||
|
forms.BooleanField(
|
||||||
|
label='PromptPay',
|
||||||
|
disabled=self.event.currency != 'THB',
|
||||||
|
help_text=_('Some payment methods might need to be enabled in the settings of your Stripe account '
|
||||||
|
'before they work properly.'),
|
||||||
|
required=False,
|
||||||
|
)),
|
||||||
('method_swish',
|
('method_swish',
|
||||||
forms.BooleanField(
|
forms.BooleanField(
|
||||||
label=_('Swish'),
|
label=_('Swish'),
|
||||||
@@ -1880,6 +1888,30 @@ class StripeSwish(StripeRedirectMethod):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class StripePromptPay(StripeRedirectMethod):
|
||||||
|
identifier = 'stripe_promptpay'
|
||||||
|
verbose_name = _('PromptPay via Stripe')
|
||||||
|
public_name = 'PromptPay'
|
||||||
|
method = 'promptpay'
|
||||||
|
confirmation_method = 'automatic'
|
||||||
|
explanation = _(
|
||||||
|
'This payment method is available to PromptPay users in Thailand. Please have your app ready.'
|
||||||
|
)
|
||||||
|
|
||||||
|
def is_allowed(self, request: HttpRequest, total: Decimal=None) -> bool:
|
||||||
|
return super().is_allowed(request, total) and request.event.currency == "THB"
|
||||||
|
|
||||||
|
def _payment_intent_kwargs(self, request, payment):
|
||||||
|
return {
|
||||||
|
"payment_method_data": {
|
||||||
|
"type": "promptpay",
|
||||||
|
"billing_details": {
|
||||||
|
"email": payment.order.email,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class StripeTwint(StripeRedirectMethod):
|
class StripeTwint(StripeRedirectMethod):
|
||||||
identifier = 'stripe_twint'
|
identifier = 'stripe_twint'
|
||||||
verbose_name = _('TWINT via Stripe')
|
verbose_name = _('TWINT via Stripe')
|
||||||
|
|||||||
@@ -46,15 +46,17 @@ def register_payment_provider(sender, **kwargs):
|
|||||||
from .payment import (
|
from .payment import (
|
||||||
StripeAffirm, StripeAlipay, StripeBancontact, StripeCC, StripeEPS,
|
StripeAffirm, StripeAlipay, StripeBancontact, StripeCC, StripeEPS,
|
||||||
StripeGiropay, StripeIdeal, StripeKlarna, StripeMobilePay,
|
StripeGiropay, StripeIdeal, StripeKlarna, StripeMobilePay,
|
||||||
StripeMultibanco, StripePayByBank, StripePayPal, StripePrzelewy24,
|
StripeMultibanco, StripePayByBank, StripePayPal, StripePromptPay,
|
||||||
StripeRevolutPay, StripeSEPADirectDebit, StripeSettingsHolder,
|
StripePrzelewy24, StripeRevolutPay, StripeSEPADirectDebit,
|
||||||
StripeSofort, StripeSwish, StripeTwint, StripeWeChatPay,
|
StripeSettingsHolder, StripeSofort, StripeSwish, StripeTwint,
|
||||||
|
StripeWeChatPay,
|
||||||
)
|
)
|
||||||
|
|
||||||
return [
|
return [
|
||||||
StripeSettingsHolder, StripeCC, StripeGiropay, StripeIdeal, StripeAlipay, StripeBancontact,
|
StripeSettingsHolder, StripeCC, StripeGiropay, StripeIdeal, StripeAlipay, StripeBancontact,
|
||||||
StripeSofort, StripeEPS, StripeMultibanco, StripePrzelewy24, StripeRevolutPay, StripeWeChatPay,
|
StripeSofort, StripeEPS, StripeMultibanco, StripePayByBank, StripePrzelewy24, StripePromptPay, StripeRevolutPay,
|
||||||
StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayByBank, StripePayPal, StripeSwish, StripeTwint, StripeMobilePay
|
StripeWeChatPay, StripeSEPADirectDebit, StripeAffirm, StripeKlarna, StripePayPal, StripeSwish,
|
||||||
|
StripeTwint, StripeMobilePay
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,3 +79,9 @@
|
|||||||
.vcenter {
|
.vcenter {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.stripe-qr-code {
|
||||||
|
max-width: 80%;
|
||||||
|
width: 200px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
@@ -325,6 +325,8 @@ $(function () {
|
|||||||
} else if ($("#stripe_payment_intent_next_action_redirect_url").length) {
|
} else if ($("#stripe_payment_intent_next_action_redirect_url").length) {
|
||||||
let payment_intent_next_action_redirect_url = $.trim($("#stripe_payment_intent_next_action_redirect_url").html());
|
let payment_intent_next_action_redirect_url = $.trim($("#stripe_payment_intent_next_action_redirect_url").html());
|
||||||
pretixstripe.handlePaymentRedirectAction(payment_intent_next_action_redirect_url);
|
pretixstripe.handlePaymentRedirectAction(payment_intent_next_action_redirect_url);
|
||||||
|
} else if ($.trim($("#stripe_payment_intent_action_type").html()) === "promptpay_display_qr_code") {
|
||||||
|
waitingDialog.hide();
|
||||||
} else if ($.trim($("#stripe_payment_intent_action_type").html()) === "wechat_pay_display_qr_code") {
|
} else if ($.trim($("#stripe_payment_intent_action_type").html()) === "wechat_pay_display_qr_code") {
|
||||||
let payment_intent_client_secret = $.trim($("#stripe_payment_intent_client_secret").html());
|
let payment_intent_client_secret = $.trim($("#stripe_payment_intent_client_secret").html());
|
||||||
pretixstripe.handleWechatAction(payment_intent_client_secret);
|
pretixstripe.handleWechatAction(payment_intent_client_secret);
|
||||||
|
|||||||
@@ -27,9 +27,21 @@
|
|||||||
<div class="stripe-errors sr-only panel-body">
|
<div class="stripe-errors sr-only panel-body">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body embed-responsive embed-responsive-sca" id="scacontainer">
|
{% if payment_intent_promptpay_image_url %}
|
||||||
|
<div class="panel-body">
|
||||||
</div>
|
<p>{% blocktrans trimmed %}
|
||||||
|
Please scan the QR code below to complete your PromptPay payment.
|
||||||
|
Once you have completed your payment, you can refresh this page.
|
||||||
|
{% endblocktrans %}</p>
|
||||||
|
<div class="text-center">
|
||||||
|
<img src="{{ payment_intent_promptpay_image_url }}" alt="{% trans 'PromptPay QR code' %}"
|
||||||
|
class="stripe-qr-code" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="panel-body embed-responsive embed-responsive-sca" id="scacontainer">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="row checkout-button-row">
|
<div class="row checkout-button-row">
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ class ScaView(StripeOrderView, View):
|
|||||||
|
|
||||||
if intent.status == 'requires_action' and intent.next_action.type in [
|
if intent.status == 'requires_action' and intent.next_action.type in [
|
||||||
'use_stripe_sdk', 'redirect_to_url', 'alipay_handle_redirect', 'wechat_pay_display_qr_code',
|
'use_stripe_sdk', 'redirect_to_url', 'alipay_handle_redirect', 'wechat_pay_display_qr_code',
|
||||||
'swish_handle_redirect_or_display_qr_code', 'multibanco_display_details',
|
'swish_handle_redirect_or_display_qr_code', 'multibanco_display_details', 'promptpay_display_qr_code',
|
||||||
]:
|
]:
|
||||||
ctx = {
|
ctx = {
|
||||||
'order': self.order,
|
'order': self.order,
|
||||||
@@ -631,6 +631,8 @@ class ScaView(StripeOrderView, View):
|
|||||||
elif intent.next_action.type == 'multibanco_display_details':
|
elif intent.next_action.type == 'multibanco_display_details':
|
||||||
ctx['payment_intent_next_action_redirect_url'] = intent.next_action.multibanco_display_details['hosted_voucher_url']
|
ctx['payment_intent_next_action_redirect_url'] = intent.next_action.multibanco_display_details['hosted_voucher_url']
|
||||||
ctx['payment_intent_redirect_action_handling'] = 'iframe'
|
ctx['payment_intent_redirect_action_handling'] = 'iframe'
|
||||||
|
elif intent.next_action.type == 'promptpay_display_qr_code':
|
||||||
|
ctx['payment_intent_promptpay_image_url'] = intent.next_action.promptpay_display_qr_code['image_url_svg']
|
||||||
|
|
||||||
r = render(request, 'pretixplugins/stripe/sca.html', ctx)
|
r = render(request, 'pretixplugins/stripe/sca.html', ctx)
|
||||||
r._csp_ignore = True
|
r._csp_ignore = True
|
||||||
|
|||||||
536
src/pretix/static/pretixcontrol/img/auth-b.svg
Normal file
536
src/pretix/static/pretixcontrol/img/auth-b.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 163 KiB |
Reference in New Issue
Block a user