2017-09-29 2 views
1

Ich arbeite mit Braintree Paypal Checkout, es funktioniert gut für mich, aber ich bin nicht in der Lage, Steuern und Versandkosten, ich habe versucht, einige Informationen zu bekommen, aber das ist auch nicht für mich arbeiten, hier ist mein aktueller Code für braintree KasseWie können wir hinzufügen, Steuern und Versandkosten in braintree Paypal Kasse

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

Kann jemand bitte sagen sie mir, was ich tun müssen, um Steuern und Lieferkosten in sich hinzufügen?

Antwort

0

Volle Offenlegung: Ich arbeite in Braintree. Wenn Sie weitere Fragen haben, wenden Sie sich bitte an [email protected]

Braintree hat keine Parameter für tax oder shipping. Sie müssen diese Logik auf Ihrer Seite erstellen und die Gesamtsumme an den Parameter amount übergeben.

+0

Aber im Falle von Recurring/Subscription, wie kann ich Steuern verwalten? Der Steuersatz ist in verschiedenen Provinzen oder Ländern unterschiedlich. Dann ist es keine gute Übung, nach dem Ort des Käufers einen anderen Plan zu erstellen. –

Verwandte Themen