2017-09-15 4 views
0

Je travaille avec la fonction checkout de braintree paypal, j'ai trouvé le code de jquery pour cela, je dois placer Braintree Sandbox Auth Key dans la variable de jquery, j'ai créé le compte dans braintree, j'ai essayé tout ce code , mais dans le journal de la console jquery il est dit que l'authentification a échoué, quelqu'un peut-il m'aider s'il vous plaît où puis-je trouver ce code? Voici mon code samepleComment puis-je trouver Braintree Sandbox Auth Key

  <!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> 

J'ai besoin de placer le code dans cette variable var BRAINTREE_SANDBOX_AUTH = '38mqtdwp4nth5tbk'; quelqu'un peut me aider à résoudre ce problème?

Répondre

1

Description complète: Je travaille chez Braintree. Si vous avez d'autres questions, n'hésitez pas à contacter [email protected]

Il semble que vous définissiez votre variable BRAINTREE_SANDBOX_AUTH sur un ID de marchand, plutôt que sur Client Token. Pour lancer la commande Braintree, vous devez générer, puis transmettre un client_token.

Vous générez le client_tokenon your server, puis le transmettez à votre client-side call: braintree.client.create().

En cas de succès, braintree.client.create() renverra une instance client que vous pouvez utiliser pour créer un composant de paiement PayPal avec braintree.paypalCheckout.create(). Dans le paypalCheckout component, vous pouvez configurer votre bouton PayPal en utilisant paypal.Button.render().

+0

Merci de travailler maintenant pour moi –