2017-09-15 92 views
0

我正在与braintree paypal结帐功能,我发现jquery代码为此,我需要将Braintree沙箱验证密钥放入jquery变量中,我在braintree中创建帐户,我尝试了所有代码,但在jQuery控制台日志中说,authrization失败,任何人都可以请帮我我在哪里可以找到代码? 这里是我的sameple代码我如何才能找到Braintree沙盒验证密钥

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

我需要将代码放在这个变量var BRAINTREE_SANDBOX_AUTH = '38mqtdwp4nth5tbk';谁能帮助我解决这个问题?

回答

1

完全披露:我在布伦特里工作。如果您有任何其他问题,请随时联系[email protected]

看起来您正在将您的BRAINTREE_SANDBOX_AUTH变量设置为商家ID,而不是Client Token。为了启动Braintree结帐,您需要生成,然后传入client_token

您生成client_tokenon your server,然后将其传递到您的client-side callbraintree.client.create()

如果成功,braintree.client.create()将返回一个客户端实例,您可以使用该实例创建一个包含braintree.paypalCheckout.create()的PayPal结帐组件。

paypalCheckout component之内,您可以使用paypal.Button.render()配置您的PayPal按钮。

+0

感谢现在为我工作 –