Paypal Checkout - 不要求非会员提供送货地址? [英] Paypal Checkout - don't ask for delivery address for non-members?
问题描述
我刚刚开始玩这个模块:
I've just started playing with this module:
https://github.com/paypal/paypal-checkout
我正在研究如何关闭客户的送货地址.我知道您可以在 URL 中按顺序执行 &NOSHIPPING=1
,但我找不到有关 API 4 版本的任何信息.我的代码是:
I'm trying to work out how to can turn off the shipping address for clients. I know in order versions you could do &NOSHIPPING=1
in the URL, but I can't find anything about the API 4 version. My code is:
paypal.Button.render({
// Pass the client ids to use to create your transaction on sandbox and production environments
locale: 'fr_FR',
//env: 'production',
env: 'sandbox',
client: {
sandbox: "...",
production: "..."
},
// Pass the payment details for your transaction
// See https://developer.paypal.com/docs/api/payments/#payment_create for the expected json parameters
payment: function() {
return paypal.rest.payment.create(this.props.env, this.props.client, {
transactions: [
{
amount: {
total: window.my_config.grand_total,
currency: 'EUR',
details: {
"subtotal": window.my_config.price,
"tax": window.my_config.vat_amount
}
},
}
]
});
},
// Display a "Pay Now" button rather than a "Continue" button
commit: true,
// Pass a function to be called when the customer completes the payment
onAuthorize: function(data, actions) {
return actions.payment.execute().then(function() {
console.log('The payment was completed!');
console.log(data, actions)
if (error === 'INSTRUMENT_DECLINED') {
actions.restart();
}
});
},
// Pass a function to be called when the customer cancels the payment
onCancel: function(data) {
console.log('The payment was cancelled!');
},
style: {
shape: 'rect',
size: "medium"
}
}, '#paypalContainerEl');
推荐答案
payment
中experience
下的no_shipping
选项需要通过函数,像这样:
You need to pass the no_shipping
option under experience
in the payment
function, like so:
return actions.payment.create(
{
payment:
{
transactions: [
{
amount:
{
total: "10",
currency: 'EUR'
}
}]
},
experience:
{
input_fields:
{
no_shipping: 1
}
}
});
在文档中,此处 和此处.需要注意的是,即使不再询问客人的送货地址,仍会要求客人提供帐单邮寄地址.
In the docs, here and here. A quick note though, guests will still be asked for their billing address, even though their shipping address will no longer be asked.
这篇关于Paypal Checkout - 不要求非会员提供送货地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!