本文介绍了我们如何在Braintree PayPal结帐中添加税款和运费的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用braintree paypal结帐,对我来说很好,但是我无法加税和运费,我试图获取一些信息,但是这对我也不起作用,这是我目前的脑树结帐代码

I am working with braintree paypal checkout, it is working fine for me, but i am not able to add tax and shipping charge, i tried to get some information, but that is also not working for me, here is my current code for braintree checkout

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');

有人可以告诉我我需要怎么做才能增加税金和运费吗?

Can anyone please tell me what i need to do to add tax and shipping charge in it?

推荐答案

Braintree没有用于taxshipping的参数.您需要自己创建此逻辑,然后将总数传递到amount参数.

Braintree doesn't have parameters for tax or shipping. You'll need to create this logic on your side and pass the total into the amount parameter.

这篇关于我们如何在Braintree PayPal结帐中添加税款和运费的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 04:53