diff --git a/src/main/java/org/olat/resource/accesscontrol/provider/paypalcheckout/ui/_content/paypal_smart_buttons.html b/src/main/java/org/olat/resource/accesscontrol/provider/paypalcheckout/ui/_content/paypal_smart_buttons.html index c04a12440329adba940f43842cf99454acc5ed7d..d8f11eb877fd12c5b40ab619ee9a186534a47034 100644 --- a/src/main/java/org/olat/resource/accesscontrol/provider/paypalcheckout/ui/_content/paypal_smart_buttons.html +++ b/src/main/java/org/olat/resource/accesscontrol/provider/paypalcheckout/ui/_content/paypal_smart_buttons.html @@ -19,15 +19,29 @@ <div id="paypal_buttons_${r.getCId()}"> <script defer> - jQuery(function() { + jQuery(function() { jQuery.ajax({ url: 'https://www.paypal.com/sdk/js?client-id=$clientId¤cy=$currency&intent=authorize', cache: true, dataType: "script", - success: loadButtons + success: loadButtons, + error: errorButtons, }); - + + function errorButtons() { + location.reload(); + } + function loadButtons() { + try { + internalLoadButtons(); + } catch(e) { + if(window.console) console.log(e); + location.reload(); + } + } + + function internalLoadButtons() { paypal.Buttons({ createOrder: function(data, actions) { return fetch('$mapperUri/create-paypal-transaction', {