2017-09-29 15 views
1

私はbraintree paypal checkoutで働いています。私にとってはうまくいっていますが、税金と配送料を追加することはできません。それはブレーントリー精算のための私の現在のコードで、ここで、私のために働いてもいないbraintree paypal 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'); 

誰もが、私はそれに税と送料を追加する何をする必要があるかを教えていただけますか?

答えて

0

全開示:私はブレーントリーで働いています。ご不明な点がございましたら、[email protected]までご連絡ください。

Braintreeにはtaxまたはshippingのパラメータがありません。このロジックを自分の側に作成し、合計をamountパラメータに渡す必要があります。

+0

ただし、定期/定期購読の場合、税金はどのように管理できますか?税率は、地域や国によって異なります。そして、これは買い手の場所に応じて異なる計画を作成するための良い習慣ではありません。 –

関連する問題