2017-09-15 4 views
0

Ich arbeite mit Braintree Paypal Checkout-Funktion, ich fand jquery Code dafür, ich brauche Braintree Sandbox Auth Key in jquery Variable, ich habe Konto in Braintree, ich versuchte all diesen Code , aber in jquery console log sagt es authrisation fehlgeschlagen, kann jemand bitte mir helfen, wo kann ich diesen Code finden? Hier ist mein sameple CodeWie kann ich Braintree Sandbox Auth Key finden

  <!DOCTYPE html> 

      <head> 
       <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
       <meta name="viewport" content="width=device-width, initial-scale=1"> 
       <script src="https://www.paypalobjects.com/api/checkout.js"></script> 
       <script src="https://js.braintreegateway.com/web/3.11.0/js/client.min.js"></script> 
       <script src="https://js.braintreegateway.com/web/3.11.0/js/paypal-checkout.min.js"></script> 
      </head> 

      <body> 
       <div id="paypal-button-container"></div> 

       <script> 

        var BRAINTREE_SANDBOX_AUTH = '38mqtdwp4nth5tbk'; 

        // Render the PayPal button 

        paypal.Button.render({ 

         // Pass in the Braintree SDK 

         braintree: braintree, 

         // Pass in your Braintree authorization key 

         client: { 
          sandbox: BRAINTREE_SANDBOX_AUTH, 
          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: '1', 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) { 
           console.log('Payment details:', payment); 
          }); 
         } 
        }, '#paypal-button-container'); 
       </script> 
      </body> 

I-Code in diesen Variablen platzieren müssen var BRAINTREE_SANDBOX_AUTH = '38mqtdwp4nth5tbk'; kann jemand mir helfen, dieses Problem zu lösen?

Antwort

1

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

Es sieht so aus, als ob Sie Ihre BRAINTREE_SANDBOX_AUTH Variable auf eine Händler-ID setzen und nicht auf Client Token. Um das Braintree-Checkout zu initiieren, müssen Sie ein client_token generieren und dann einreichen.

Sie generieren die client_tokenon your server, dann übergeben Sie sie in Ihre client-side call: .

Wenn erfolgreich, gibt eine Clientinstanz zurück, mit der Sie eine PayPal-Checkout-Komponente mit braintree.paypalCheckout.create() erstellen können.

Innerhalb der paypalCheckout component können Sie Ihre PayPal-Schaltfläche mit paypal.Button.render() konfigurieren.

+0

Danke, es funktioniert jetzt für mich –

Verwandte Themen