diff --git a/packages/Webkul/Paypal/src/Resources/views/checkout/onepage/paypal-smart-button.blade.php b/packages/Webkul/Paypal/src/Resources/views/checkout/onepage/paypal-smart-button.blade.php index 0fdf64d4d..b4988d20b 100644 --- a/packages/Webkul/Paypal/src/Resources/views/checkout/onepage/paypal-smart-button.blade.php +++ b/packages/Webkul/Paypal/src/Resources/views/checkout/onepage/paypal-smart-button.blade.php @@ -21,7 +21,7 @@ }; window.onload = (function() { - eventBus.$on('after-payment-method-selected', function(payment) { + eventBus.$on('after-payment-method-selected', function (payment) { if (payment.method != 'paypal_smart_button') { $('.paypal-buttons').remove(); @@ -40,6 +40,8 @@ shape: 'rect', }, + authorizationFailed: false, + enableStandardCardFields: false, alertBox: function (message) { @@ -58,10 +60,11 @@ }) .catch(function (error) { if (error.response.data.error === 'invalid_client') { + options.authorizationFailed = true; options.alertBox(messages.authorizationError); } - options.alertBox(messages.universalError); + return error; }); }, @@ -86,6 +89,12 @@ .catch(function (error) { window.location.href = "{{ route('shop.checkout.cart.index') }}"; }) + }, + + onError: function (error) { + if (! options.authorizationFailed) { + options.alertBox(error); + } } };