How to call external javascript function from inside onAuthorize paypal smart payment button listener

十年热恋 提交于 2020-01-16 00:43:50

问题


While setting up a Paypal Smart Payment Button, I wanted to call an external function from the button listener onAuthorize. How to do it? External functions are not visible inside the button listener. In order to call them they have to be attached to the window object.

/* Paypal button code */
// Execute the payment
onAuthorize: function(data, actions) {$(this).attr('action')
    return actions.payment.execute().then(function(data) {
    // Show a confirmation message to the buyer
    window.user_membership_activation(data);
    });
}

/* Elsewhere in your page or included script */
window.user_membership_activation = function(data) {

    // do something here
} 

来源:https://stackoverflow.com/questions/57090296/how-to-call-external-javascript-function-from-inside-onauthorize-paypal-smart-pa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!