PPv2: Surface error-messages if XHR-call fails

This commit is contained in:
Martin Gross
2022-05-31 19:23:57 +02:00
parent 823de60e8c
commit e20c2c56f0
2 changed files with 7 additions and 2 deletions

View File

@@ -198,7 +198,12 @@ var pretixpaypal = {
}).then(function (res) { }).then(function (res) {
return res.json(); return res.json();
}).then(function (data) { }).then(function (data) {
return data.id; if ('id' in data) {
return data.id;
} else {
// Refreshing the page to surface the request-error message
location.reload();
}
}); });
}, },
onApprove: function (data, actions) { onApprove: function (data, actions) {

View File

@@ -151,7 +151,7 @@ class XHRView(View):
} }
paypal_order = prov._create_paypal_order(request, None, cart) paypal_order = prov._create_paypal_order(request, None, cart)
r = JsonResponse(paypal_order.dict()) r = JsonResponse(paypal_order.dict() if paypal_order else {})
r._csp_ignore = True r._csp_ignore = True
return r return r