From b1e6f7e37ff09e4f291ee2cbef0836b117d19e7a Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Mon, 9 Nov 2026 09:44:56 +0200 Subject: [PATCH 1/2] Redirect Stripe checkout to the Checkout Session url Fixes Strategy11/business-directory-premium#390 Pay Now goes to the session url when the server returns one, so it works when another plugin loads a Stripe.js without redirectToCheckout. Needs Strategy11/formidable-stripe-connect#110 deployed for the url path. --- assets/js/checkout.js | 6 ++++++ assets/js/checkout.min.js | 2 +- includes/gateways/class-stripe-gateway.php | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/js/checkout.js b/assets/js/checkout.js index 816031ad7..f277f9ad1 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -79,6 +79,12 @@ jQuery(function($) { } const configuration = $.parseJSON( configurationElement.dataset.configuration ); + + if ( 'string' === typeof configuration.url && 0 === configuration.url.indexOf( 'https://checkout.stripe.com/' ) ) { + window.location.href = configuration.url; + return false; + } + const stripe = Stripe( configuration.key, { stripeAccount: configuration.accountId } ); stripe.redirectToCheckout({ diff --git a/assets/js/checkout.min.js b/assets/js/checkout.min.js index 1446b7f6d..5a6e28cfb 100644 --- a/assets/js/checkout.min.js +++ b/assets/js/checkout.min.js @@ -1 +1 @@ -jQuery(function($){({init:function(){var self,$form=$("form#wpbdp-checkout-form");0!=$form.length&&((self=this).$form=$form,this.$container=this.$form.find("#wpbdp-checkout-form-fields"),this.payment_key=this.$form.find('input[name="payment"]').val(),this.nonce=this.$form.find('input[name="_wpnonce"]').val(),this.working=!1,this.$form.find('input[name="gateway"]').change(function(){var gateway;self.working||(gateway=self.$form.find('input[name="gateway"]:checked').val())&&self.load_gateway(gateway)}),this.$form.find('input[name="gateway"]').trigger("change"))},load_gateway:function(gateway_id){var self=this,url=(self.$container.html(""),self.working=!0,wpbdp_global.ajaxurl),url=(url+=0"),mywindow.document.write($("head").html()),mywindow.document.write(""),mywindow.document.write($(e).wrap("

").parent().html()),mywindow.document.write(""),mywindow.document.close(),mywindow.focus(),mywindow.onload=function(){mywindow.print(),mywindow.close()}})}); \ No newline at end of file +jQuery(function($){({init:function(){var self,$form=$("form#wpbdp-checkout-form");0!=$form.length&&((self=this).$form=$form,this.$container=this.$form.find("#wpbdp-checkout-form-fields"),this.payment_key=this.$form.find('input[name="payment"]').val(),this.nonce=this.$form.find('input[name="_wpnonce"]').val(),this.working=!1,this.$form.find('input[name="gateway"]').change(function(){var gateway;self.working||(gateway=self.$form.find('input[name="gateway"]:checked').val())&&self.load_gateway(gateway)}),this.$form.find('input[name="gateway"]').trigger("change"))},load_gateway:function(gateway_id){var self=this,url=(self.$container.html(""),self.working=!0,wpbdp_global.ajaxurl),url=(url+=0"),mywindow.document.write($("head").html()),mywindow.document.write(""),mywindow.document.write($(e).wrap("

").parent().html()),mywindow.document.write(""),mywindow.document.close(),mywindow.focus(),mywindow.onload=function(){mywindow.print(),mywindow.close()}})}); \ No newline at end of file diff --git a/includes/gateways/class-stripe-gateway.php b/includes/gateways/class-stripe-gateway.php index 07ad99d29..ccbb8f997 100644 --- a/includes/gateways/class-stripe-gateway.php +++ b/includes/gateways/class-stripe-gateway.php @@ -213,6 +213,7 @@ private function configure_stripe( $payment ) { } $stripe['sessionId'] = $session->id; + $stripe['url'] = $session->url ?? ''; return $stripe; } From 9766a737d87b33794700992378cc24469950717b Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Mon, 9 Nov 2026 09:58:56 +0200 Subject: [PATCH 2/2] Follow Checkout Session urls on custom Stripe domains Accept any https session url instead of only checkout.stripe.com, so accounts with a custom Checkout domain can pay. --- assets/js/checkout.js | 2 +- assets/js/checkout.min.js | 2 +- includes/gateways/class-stripe-gateway.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/js/checkout.js b/assets/js/checkout.js index f277f9ad1..00aa49e64 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -80,7 +80,7 @@ jQuery(function($) { const configuration = $.parseJSON( configurationElement.dataset.configuration ); - if ( 'string' === typeof configuration.url && 0 === configuration.url.indexOf( 'https://checkout.stripe.com/' ) ) { + if ( 'string' === typeof configuration.url && 0 === configuration.url.indexOf( 'https://' ) ) { window.location.href = configuration.url; return false; } diff --git a/assets/js/checkout.min.js b/assets/js/checkout.min.js index 5a6e28cfb..b0b2a830d 100644 --- a/assets/js/checkout.min.js +++ b/assets/js/checkout.min.js @@ -1 +1 @@ -jQuery(function($){({init:function(){var self,$form=$("form#wpbdp-checkout-form");0!=$form.length&&((self=this).$form=$form,this.$container=this.$form.find("#wpbdp-checkout-form-fields"),this.payment_key=this.$form.find('input[name="payment"]').val(),this.nonce=this.$form.find('input[name="_wpnonce"]').val(),this.working=!1,this.$form.find('input[name="gateway"]').change(function(){var gateway;self.working||(gateway=self.$form.find('input[name="gateway"]:checked').val())&&self.load_gateway(gateway)}),this.$form.find('input[name="gateway"]').trigger("change"))},load_gateway:function(gateway_id){var self=this,url=(self.$container.html(""),self.working=!0,wpbdp_global.ajaxurl),url=(url+=0"),mywindow.document.write($("head").html()),mywindow.document.write(""),mywindow.document.write($(e).wrap("

").parent().html()),mywindow.document.write(""),mywindow.document.close(),mywindow.focus(),mywindow.onload=function(){mywindow.print(),mywindow.close()}})}); \ No newline at end of file +jQuery(function($){({init:function(){var self,$form=$("form#wpbdp-checkout-form");0!=$form.length&&((self=this).$form=$form,this.$container=this.$form.find("#wpbdp-checkout-form-fields"),this.payment_key=this.$form.find('input[name="payment"]').val(),this.nonce=this.$form.find('input[name="_wpnonce"]').val(),this.working=!1,this.$form.find('input[name="gateway"]').change(function(){var gateway;self.working||(gateway=self.$form.find('input[name="gateway"]:checked').val())&&self.load_gateway(gateway)}),this.$form.find('input[name="gateway"]').trigger("change"))},load_gateway:function(gateway_id){var self=this,url=(self.$container.html(""),self.working=!0,wpbdp_global.ajaxurl),url=(url+=0"),mywindow.document.write($("head").html()),mywindow.document.write(""),mywindow.document.write($(e).wrap("

").parent().html()),mywindow.document.write(""),mywindow.document.close(),mywindow.focus(),mywindow.onload=function(){mywindow.print(),mywindow.close()}})}); \ No newline at end of file diff --git a/includes/gateways/class-stripe-gateway.php b/includes/gateways/class-stripe-gateway.php index ccbb8f997..abd373db8 100644 --- a/includes/gateways/class-stripe-gateway.php +++ b/includes/gateways/class-stripe-gateway.php @@ -213,7 +213,7 @@ private function configure_stripe( $payment ) { } $stripe['sessionId'] = $session->id; - $stripe['url'] = $session->url ?? ''; + $stripe['url'] = esc_url_raw( $session->url ?? '', array( 'https' ) ); return $stripe; }