Skip to content
Snippets Groups Projects
Commit fea27b49 authored by mattwire's avatar mattwire
Browse files

If CRM.api3 fails to execute StripePaymentintent.Process display a more...

If CRM.api3 fails to execute StripePaymentintent.Process display a more helpful error message instead of 'parsererror'
parent 95d2e8b6
No related branches found
No related tags found
No related merge requests found
...@@ -133,7 +133,12 @@ ...@@ -133,7 +133,12 @@
var error = ts('Unknown error'); var error = ts('Unknown error');
if (object.hasOwnProperty('statusText') && (object.statusText !== 'OK')) { if (object.hasOwnProperty('statusText') && (object.statusText !== 'OK')) {
// A PHP exit can return 200 "OK" but we don't want to display "OK" as the error! // A PHP exit can return 200 "OK" but we don't want to display "OK" as the error!
error = object.statusText; if (object.statusText === 'parsererror') {
error = ts('Configuration error - unable to process paymentIntent');
}
else {
error = object.statusText;
}
} }
CRM.payment.debugging(confirm.scriptName, error); CRM.payment.debugging(confirm.scriptName, error);
confirm.swalFire({ confirm.swalFire({
......
...@@ -272,14 +272,7 @@ ...@@ -272,14 +272,7 @@
} }
} }
}) })
.fail(function(object) { .fail(stripePaymentIntentProcessFail(paymentIntentProcessResponse));
var error = ts('Unknown error');
if (object.hasOwnProperty('statusText') && (object.statusText !== 'OK')) {
// A PHP exit can return 200 "OK" but we don't want to display "OK" as the error!
error = object.statusText;
}
displayError(error, true);
});
} }
} }
}); });
...@@ -320,14 +313,27 @@ ...@@ -320,14 +313,27 @@
// From here the on 'paymentmethod' of the paymentRequest handles completion/failure // From here the on 'paymentmethod' of the paymentRequest handles completion/failure
} }
}) })
.fail(function(object) { .fail(stripePaymentIntentProcessFail(paymentIntentProcessResponse));
// Triggered when http code !== 200 (eg. 400 Bad request) }
var error = ts('Unknown error');
if (object.hasOwnProperty('statusText')) { /**
error = object.statusText; * Display a helpful error message if call to StripePaymentintent.Process fails
} * @param {object} failObject
displayError(error, true); * @returns {boolean}
}); */
function stripePaymentIntentProcessFail(failObject) {
var error = ts('Unknown error');
if (object.hasOwnProperty('statusText') && (object.statusText !== 'OK')) {
// A PHP exit can return 200 "OK" but we don't want to display "OK" as the error!
if (object.statusText === 'parsererror') {
error = ts('Configuration error - unable to process paymentIntent');
}
else {
error = object.statusText;
}
}
displayError(error, true);
return true;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment