javascript - 在贝宝结帐按钮集成中禁用运输
问题描述
我想从 PayPal 结账集成中隐藏收货地址。我正在使用以下链接中的“使用 checkout.js 结帐”选项:https ://developer.paypal.com/docs/archive/checkout/integrate/ 我当前的代码如下所示:
paypal.Button.render({
env: 'production',
commit: false,
style: {
color: 'gold',
size: 'responsive',
label: 'pay',
shape: 'rect'
},
client: {
sandbox: 'yurtyfcnvmghjlgfjgsdfbvbxcvbsdffjdfcbngfetrrurteytrwgfsdgs',
production: 'werutpoeirutoputpoyuowieupoweutpwoeiuiouwrepotiwuperoldkfs'
},
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: pmt, currency: 'USD' }
}
]
}
});
},
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function(payment) {
window.location = 'some url';
});
},
onCancel: function(data, actions) {
window.location = 'some url';
},
onError: function(err) {
/* do something */
}
}, '#pwpl_m');
解决方案
checkout.js 是旧的/存档的解决方案,所以我建议您改用最新的 PayPal 结帐;这是一个演示模式:https ://developer.paypal.com/demo/checkout/#/pattern/client
语法和v2/orders一样,有一个application_context
对象:https ://developer.paypal.com/docs/api/orders/v2/#definition-order_application_context
基本上在它的purchase_units
数组之后你需要添加:
application_context: {
shipping_preference: 'NO_SHIPPING'
}
推荐阅读
- c# - 如何获取身份 id 类型 guid 并分配给另一个表中的外键 id。在 Asp.net Core 中应用
- r - 在具有时间分量变量的表中创建计数
- azure-devops - Azure DevOps 构建工件存储在哪里
- javascript - 带有 addEventListerner 的 JavaScript 异步/等待用户输入
- javascript - Angular:如何监听 window.onload 事件?
- node.js - 在循环NodeJs中动态创建一个类
- npm - NPM 命令在 vs code 终端中不起作用
- ios - 子视图中的按钮不适用于 SwiftUI
- r - 为什么/如何修复闪亮应用的导航按钮?
- shopify - 从 HTML 中删除空的 P 标签?