[英]Remove shipping address option in PayPal Express Checkout
我正在使用 PayPal 推荐的 JS 脚本。它运行良好,但显示买家的“收货地址”。
我正在尝试搜索 inte.net,发现https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/
requested with "no_shipping": 1,
可以解决问题。 但是为此我们需要在payment.create
之前发出一个 curl 请求,这样我们就可以传递它在 function 中返回的 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>
为了扩展Bluepnume的答案,这是一个完整的例子:
payment: function(data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: '1.00', currency: 'USD' }
}
]
},
experience: {
input_fields: {
no_shipping: 1
}
}
});
},
您可以通过以下体验选项:
paypal.rest.payment.create({
// payment options here
}, {
// experience options here
});
这是在 ngx-paypal 版本 11 中需要完成的方式
application_context:
{
shipping_preference: "NO_SHIPPING"
}
ngx-paypal:“^11.0.0”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.