我刚刚开始使用此模块玩:Paypal结帐 - 请不要要求非会员的送货地址?
https://github.com/paypal/paypal-checkout
我试图找出如何可以关闭送货地址的客户端。我知道在订购版本中,您可以在URL中执行&NOSHIPPING=1
,但我找不到有关API 4版本的任何信息。我的代码是:
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');
谢谢 - 但你怎么用PayPal结账JS呢?它只是作为'transactions:[]'部分的一个选项吗? –
@AndrewNewby你发现这是怎么回事? –
@Michał它已经有一段时间了 - 但我似乎记得当时没有选择将它放入PayPal JS API中(现在可能有所不同) –