gpt4 book ai didi

paypal - 我们如何在 braintree paypal 结账时添加税费和运费

转载 作者:太空宇宙 更新时间:2023-11-03 15:48:05 24 4
gpt4 key购买 nike

我正在使用 braintree paypal checkout,它对我来说工作正常,但我无法添加税费和运费,我试图获取一些信息,但这对我也不起作用,这是我当前的braintree 结帐代码

var form = document.querySelector('#payment-form');
var client_token = "<?php echo \Braintree\ClientToken::generate(); ?>";
// Render the PayPal button

paypal.Button.render({

// Pass in the Braintree SDK

braintree: braintree,

// Pass in your Braintree authorization key

client: {
sandbox: client_token,
production: '<insert production auth key>'
},

// Set your environment

env: 'sandbox', // sandbox | production

// Wait for the PayPal button to be clicked

payment: function(data, actions) {

// Make a call to create the payment

return actions.payment.create({
payment: {
transactions: [
{
amount: {
total: <?php echo $cart_total_amount; ?>,
currency: 'USD'
}
}
]
}
});
},

// Wait for the payment to be authorized by the customer

onAuthorize: function(data, actions) {

// Call your server with data.nonce to finalize the payment

console.log('Braintree nonce:', data.nonce);

// Get the payment and buyer details

return actions.payment.get().then(function(payment) {
$("div#divLoading").addClass('show');
console.log('Payment details:', payment);
var payment_id = payment.id;
var total_amount = '<?php echo $cart_total_amount; ?>';
$.ajax({
type: 'POST',
url : '<?php $_SERVER["DOCUMET_ROOT"] ?>/media/secure_checkout/create_order_braintree.php',
data : 'payment_id='+payment_id+'&total_amount='+total_amount,
dataType : 'json',
success: function(msg) {
$("div#divLoading").removeClass('show');
if(msg.status == '1') {
//$("#myModal").modal('show');
document.location.href= 'http://<?php echo $_SERVER['HTTP_HOST']; ?>/media/secure_checkout/checkout.php?payment=confirm';
}
},
error: function(msg) {
$("div#divLoading").removeClass('show');
}
});
});
}

}, '#paypal-button-container');

任何人都可以告诉我我需要做什么来添加税费和运费吗?

最佳答案

全面披露:我在 Braintree 工作。如果您有任何其他问题,请随时联系 support@braintreepayments.com。

Braintree 没有taxshipping 参数。您需要自己创建此逻辑并将总数传递给 amount 参数。

关于paypal - 我们如何在 braintree paypal 结账时添加税费和运费,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46489672/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com