mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Improved error handling with paypal
This commit is contained in:
parent
08f9443c82
commit
02c85e9330
@ -15,8 +15,8 @@
|
|||||||
@endphp
|
@endphp
|
||||||
@section('gateway_head')
|
@section('gateway_head')
|
||||||
<meta http-equiv="Content-Security-Policy" content="
|
<meta http-equiv="Content-Security-Policy" content="
|
||||||
frame-src 'self' https://c.paypal.com https://www.sandbox.paypal.com https://www.paypal.com;
|
frame-src 'self' https://c.paypal.com https://www.sandbox.paypal.com https://www.paypal.com https://www.paypalobjects.com;
|
||||||
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://c.paypal.com https://www.paypalobjects.com https://www.paypal.com https://www.sandbox.paypal.com/;
|
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://c.paypal.com https://www.paypalobjects.com https://www.paypal.com https://www.sandbox.paypal.com https://www.google-analytics.com;
|
||||||
img-src * data: 'self';
|
img-src * data: 'self';
|
||||||
style-src 'self' 'unsafe-inline';"
|
style-src 'self' 'unsafe-inline';"
|
||||||
>
|
>
|
||||||
@ -171,8 +171,18 @@
|
|||||||
|
|
||||||
document.getElementById('errors').textContent = `Sorry, your transaction could not be processed...\n\n${error.message}`;
|
document.getElementById('errors').textContent = `Sorry, your transaction could not be processed...\n\n${error.message}`;
|
||||||
document.getElementById('errors').hidden = false;
|
document.getElementById('errors').hidden = false;
|
||||||
|
|
||||||
|
document.getElementById('pay-now').disabled = false;
|
||||||
|
document.querySelector('#pay-now > svg').classList.add('hidden');
|
||||||
|
document.querySelector('#pay-now > span').classList.remove('hidden');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
onError: function(error) {
|
||||||
|
|
||||||
|
throw new Error(error);
|
||||||
|
|
||||||
},
|
},
|
||||||
onCancel: function() {
|
onCancel: function() {
|
||||||
|
|
||||||
@ -231,14 +241,12 @@
|
|||||||
cardField.submit().then(() => {
|
cardField.submit().then(() => {
|
||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
|
||||||
console.log(error);
|
|
||||||
|
|
||||||
let msg;
|
let msg;
|
||||||
|
|
||||||
if(!['INVALID_NUMBER','INVALID_CVV','INVALID_EXPIRY'].includes(error.message))
|
if(!['INVALID_NUMBER','INVALID_CVV','INVALID_EXPIRY'].includes(error.message))
|
||||||
{
|
{
|
||||||
const errorM = parseError(error.message);
|
const errorM = parseError(error);
|
||||||
msg = handle422Error(errorM);
|
msg = handle422Error(errorM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +263,7 @@
|
|||||||
else if(error.message == 'INVALID_EXPIRY') {
|
else if(error.message == 'INVALID_EXPIRY') {
|
||||||
document.getElementById('errors').textContent = "{{ ctrans('texts.invalid_cvv') }}";
|
document.getElementById('errors').textContent = "{{ ctrans('texts.invalid_cvv') }}";
|
||||||
}
|
}
|
||||||
else if(msg.description){
|
else if(msg?.description){
|
||||||
document.getElementById('errors').textContent = msg?.description;
|
document.getElementById('errors').textContent = msg?.description;
|
||||||
}
|
}
|
||||||
document.getElementById('errors').hidden = false;
|
document.getElementById('errors').hidden = false;
|
||||||
@ -270,7 +278,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handle422Error(errorData) {
|
function handle422Error(errorData) {
|
||||||
const errorDetails = errorData.details || [];
|
const errorDetails = errorData?.details || [];
|
||||||
const detail = errorDetails[0];
|
const detail = errorDetails[0];
|
||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user