Stripe Elements: Fix incorrect JavaScript and display loading indicator

This commit is contained in:
Raphael Michel
2017-11-24 09:42:26 +01:00
parent 65592dc42d
commit a62105fa28
3 changed files with 9 additions and 2 deletions

View File

@@ -64,7 +64,7 @@ $(function () {
$(".checkout-button-row .btn-primary").click( $(".checkout-button-row .btn-primary").click(
function (e) { function (e) {
if (($("input[name=payment][value=stripe]").prop('checked') || $("input[type=checkbox][name=payment]").length === 0) if (($("input[name=payment][value=stripe]").prop('checked') || $("input[type=checkbox][name=radio]").length === 0)
&& $("#stripe_token").val() == "") { && $("#stripe_token").val() == "") {
pretixstripe.start(); pretixstripe.start();
e.preventDefault(); e.preventDefault();

View File

@@ -28,6 +28,9 @@ var pretixstripe = {
}); });
}, },
'load': function () { 'load': function () {
if (pretixstripe.stripe !== null) {
return;
}
$('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true); $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true);
$.ajax( $.ajax(
{ {
@@ -66,6 +69,9 @@ var pretixstripe = {
); );
}, },
'load_checkout': function () { 'load_checkout': function () {
if (pretixstripe.checkout_handler !== null) {
return;
}
$('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true); $('.stripe-container').closest("form").find(".btn-primary").prop("disabled", true);
$.ajax( $.ajax(
{ {
@@ -151,7 +157,7 @@ $(function () {
$('.stripe-container').closest("form").submit( $('.stripe-container').closest("form").submit(
function () { function () {
if (($("input[name=payment][value=stripe]").prop('checked') || $("input[name=payment][type=checkbox]").length === 0) if (($("input[name=payment][value=stripe]").prop('checked') || $("input[name=payment][type=radio]").length === 0)
&& $("#stripe_token").val() == "") { && $("#stripe_token").val() == "") {
if ($("#stripe-checkout").length) { if ($("#stripe-checkout").length) {
pretixstripe.show_checkout(); pretixstripe.show_checkout();

View File

@@ -31,6 +31,7 @@
{% endif %} {% endif %}
<div id="stripe-card" class="form-control"> <div id="stripe-card" class="form-control">
<span class="fa fa-spinner fa-spin"></span>
<!-- a Stripe Element will be inserted here. --> <!-- a Stripe Element will be inserted here. -->
</div> </div>
<p class="help-block"> <p class="help-block">