From be6fe81865119797fa727e13a109a8bd04e2ea37 Mon Sep 17 00:00:00 2001 From: dylanfisher Date: Mon, 18 Jul 2022 16:56:37 -0400 Subject: [PATCH] If Spree.pathFor is defined, use this to generate Stripe intent URL Without this change, the mount path of the Spree engine isn't taken into account, and this hard-coded URL results in a 404. Fixes #392 --- app/views/spree/checkout/_payment_confirm.html.erb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/spree/checkout/_payment_confirm.html.erb b/app/views/spree/checkout/_payment_confirm.html.erb index e1ab6445..d0f44935 100644 --- a/app/views/spree/checkout/_payment_confirm.html.erb +++ b/app/views/spree/checkout/_payment_confirm.html.erb @@ -8,7 +8,11 @@ var form = document.getElementById('checkout_form_payment_confirm'); function confirmCardPaymentResponseHandler(response) { - $.post("/api/v2/storefront/intents/handle_response", { response: response, order_token: "<%= @order.token %>" }).done(function (result) { + var url = 'api/v2/storefront/intents/handle_response'; + if ( typeof Spree.pathFor == 'function' ) { + url = Spree.pathFor(url) + } + $.post(url, { response: response, order_token: "<%= @order.token %>" }).done(function (result) { // conditional needs for spree 3.7 if(form.elements["commit"]) { form.elements["commit"].disabled = false;