我如何找到Braintree Sandbox auth键



我正在使用braintree paypal结帐函数,我找到了jQuery代码,我需要将braintree sandbox auth键放在jquery varible中,我在braintree中创建了帐户,我尝试了所有该代码,但是在JQuery Console日志中它说验证失败了,有人可以帮助我在哪里可以找到该代码?这是我的相同代码

            <!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';中放置代码,任何人可以帮助我解决此问题吗?

全面披露:我在braintree工作。如果您还有其他疑问,请随时联系support@braintroepayments.com。

看起来您将BRAINTREE_SANDBOX_AUTH变量设置为商户ID,而不是客户端令牌。为了启动Braintree结帐,您将需要生成,然后传递client_token

您在服务器上生成client_token,然后将其传递到客户端呼叫中:braintree.client.create()

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

在PaypalCheckout组件中,您可以使用paypal.Button.render()配置PayPal按钮。

相关内容

  • 没有找到相关文章

最新更新