Skip to content

Commit

Permalink
If Spree.pathFor is defined, use this to generate Stripe intent URL
Browse files Browse the repository at this point in the history
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 spree#392
  • Loading branch information
dylanfisher committed Jul 18, 2022
1 parent 8215a4a commit be6fe81
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/views/spree/checkout/_payment_confirm.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit be6fe81

Please sign in to comment.