我正在使用braintree paypal结帐,对我来说很好,但是我无法加税和运费,我试图获取一些信息,但这也不适用于我,这是我当前的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没有用于tax
或shipping
的参数。您需要自己创建此逻辑,并将总数传递给amount
参数。
关于paypal - 我们如何在Braintree Paypal结帐中添加税款和运费,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46489672/