gpt4 book ai didi

javascript - Paypal 快速结帐按钮

转载 作者:太空宇宙 更新时间:2023-11-03 15:58:16 24 4
gpt4 key购买 nike

我在我的网站上集成了 Paypal 快速结账按钮,我有以下代码:

paypal.Button.render({

env: 'sandbox', // Optional: specify 'sandbox' environment
style: {
size: 'medium',
color: 'blue',
shape: 'rect'
},

payment: function(resolve, reject) {

var CREATE_PAYMENT_URL = 'http://example.com/create-payment';

paypal.request.post(CREATE_PAYMENT_UR)
.then(function(data) {
resolve(data.paymentID);
})
.catch(function(err) {
reject(err);
});
},

onAuthorize: function(data) {

// Note: you can display a confirmation page before executing

var EXECUTE_PAYMENT_URL = 'http://example.com/execute-payment';

paypal.request.post(EXECUTE_PAYMENT_URL, {
paymentID: data.paymentID,
payerID: data.payerID,
})
.then(function(data) { /* Go to a success page */ })
.catch(function(err) { /* Go to an error page */ });
}

}, '#paypal-button');

我想分别设置paymentonAuthorize。有什么办法吗?

类似于:paypal.Button.onAuthorize = function() { };

最佳答案

如果有帮助,您可以单独创建函数

function payment() {
...
}

function onAuthorize() {
...
}

paypal.Button.render({

payment: payment,
onAuthorize: onAuthorize

});

关于javascript - Paypal 快速结帐按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42446486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com