我剛剛開始使用此模塊玩: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中(現在可能有所不同) –