在PayPal Express Checkout中删除送货地址选项
问题描述:
我使用PayPal推荐的JS script。它运作良好,但它显示“船到”地址的买家。在PayPal Express Checkout中删除送货地址选项
我想搜索互联网,发现https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/
要求与"no_shipping": 1,
可以做的伎俩。但为此,我们需要在payment.create
之前发出curl请求,以便我们可以在函数中传递它返回的id。
这是可能的JS?
还是有更好更简单的方法来删除它使用下面的JS?
<script src="https://www.paypalobjects.com/api/checkout.js" data-version-4></script>
<script>
paypal.Button.render({
env: 'sandbox', // Optional: specify 'sandbox' or 'production'
client: {
sandbox: '{{$data['SandboxId']}}',
production: '{{$data['ProductionId']}}'
},
payment: function() {
var amount = document.getElementById("amount").value;
var env = this.props.env;
var client = this.props.client;
return paypal.rest.payment.create(env, client, {
transactions: [
{
amount: {
total: amount,
currency: "USD",
details: {
subtotal: amount,
tax: "0.00",
shipping: "0.00"
}
},
description: "This is payment description.",
item_list: {
items:[
{
quantity:"1",
name:"Orders",
price:amount,
sku:"product12345",
currency:"USD"
}
],
},
}],
});
},
commit: false, // Optional: show a 'Pay Now' button in the checkout flow
onAuthorize: function(data, actions) {
console.log(data);
alert('confirmation here');
// Optional: display a confirmation page here
return actions.payment.execute().then(function() {
alert('Success here');
// Show a success page to the buyer
});
},
}, '#paypal-button');
</script><div id="paypal-button" ></div>
答
你可以传递一个体验的选项,如下所示:
paypal.rest.payment.create({
// payment options here
}, {
// experience options here
});
答
要在Bluepnume的答案扩大,这里是一个完整的例子:
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1.00', currency: 'USD' }
}
]
},
experience: {
input_fields: {
no_shipping: 1
}
}
});
},
Blueprnum嗨!有没有这方面的文件?我尝试添加NOSHIPPING作为体验选项,但没有运气。 – jhk
没关系 - 找到了! – jhk