2

我正在使用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');

谁能告诉我我需要做什么才能在其中添加税费和运费?

4

2 回答 2

2

全面披露:我在布伦特里工作。如果您还有任何问题,请随时联系 support@braintreepayments.com。

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

于 2017-10-06T21:38:04.960 回答
1

您似乎正在使用 Braintree SDK 集成 PayPal Checkout中的代码。在此处actions.payment.create()查看通话的可用选项。请注意,并且在那里。有关付款 API 页面的更多详细信息。注意:您仍然需要计算总数,因此它包括税费和运费,就像 Erica 说的那样。taxshipping

如果你想创建支付服务器端,似乎你可以传递taxAmountshippingAmountBraintree 的transaction::sale()方法。也可以在订单项级别传递这些。同样,您需要计算总数,使其包括税费和运费。看来您还必须包括其他一些字段,因为taxAmount它是2 级字段,并且shippingAmount3 级字段。我没有使用它,所以我不能说它是如何工作的,或者它的工作情况如何。我想(希望)如果将 PayPal 用作付款方式,这些字段会传递到 PayPal。

对于经常性交易:我看不到任何特定于税收/运费的字段,但您可以price在创建订阅时覆盖以包含税(至少使用服务器端 Braintree API)。或者,我认为如果您创建一个税收附加组件,您可以在订阅创建时覆盖它而不知道订阅价格。无论哪种方式,我不确定您是否可以随着税率的变化(随着法律的变化)轻松更新订阅。

于 2018-07-11T20:40:16.240 回答