gpt4 book ai didi

javascript - 如何将返回 url 添加到 paypal 的 javascript/rest 快速结帐简单集成

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

我有 paypals simple express checkout javascript,我在测试时遇到问题,我似乎无法弄清楚如何在下面的代码中添加返回 url。

在 paypal 开发者网站应用程序和凭据下,我创建了一个 REST API 应用程序并在那里添加了一个返回 url,但这似乎不适用于下面列出的简单 javascript Express Checkout 集成。

我可以简单地返回并取消 url 还是 Basic 客户端集成不允许这样做?

很抱歉问了一个愚蠢的问题,它只是 palpays 文档根本不是那么好,看起来扔谷歌那里有很多不同的选择来做同样的基本事情

<script src="https://www.paypalobjects.com/api/checkout.js"></script>

<div id="paypal-button-container"></div>

<script>

// Render the PayPal button

paypal.Button.render({
// Set your environment

env: 'sandbox', // sandbox | production

// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create

client: {
sandbox: 'sandbox',
production: 'production'
},
// Wait for the PayPal button to be clicked

payment: function () {

// Make a client-side call to the REST api to create the payment

return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: {total: '10.99', currency: 'USD'}
}
]
});
},
// Wait for the payment to be authorized by the customer

commit: true, // Optional: show a 'Pay Now' button in the checkout flow

onAuthorize: function (data, actions) {

// Execute the payment

return actions.payment.execute().then(function () {
// Show a success page to the buyer
});
}

}, '#paypal-button-container');

最佳答案

我放弃了这个小部件,因为它是有限的,而且有很多马车。但我认为您可以在 onAuthorize 回调处理程序中进行重定向。

paypal.Button.render({
// etc...
onAuthorize: function (data, actions) {
return actions.payment.execute().then(function () {
// redirect to success page
}).catch(function(err) {
// redirect to error page
});
}
}, '#paypal-button-container');

关于javascript - 如何将返回 url 添加到 paypal 的 javascript/rest 快速结帐简单集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43379439/

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