我用的是JSscript https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/basic-integration/贝宝推荐。它运行良好,但它显示出“运送到”买家的地址。
我试图在互联网上搜索并发现https://api.sandbox.paypal.com/v1/payment-experience/web-profiles/
请求与"no_shipping": 1,
可以做到这一点。但为此我们需要在之前发出一个curl请求payment.create
,这样我们就可以在函数中传递它返回的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>