paypal - 我如何找到 Braintree Sandbox 授权 key

标签 paypal paypal-sandbox braintree braintree-sandbox

我正在使用 braintree paypal 结帐功能,我找到了它的 jquery 代码,我需要将 Braintree Sandbox Auth Key 放在 jquery 变量中,我在 braintree 中创建了帐户,我尝试了所有代码,但在 jquery 控制台日志中它说授权失败,任何人都可以帮助我在哪里可以找到该代码? 这是我的相同代码

            <!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@braintreepayments.com。

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

您生成client_token on your server ,然后将其传递给您的 client-side call : braintree.client.create()

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

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

关于paypal - 我如何找到 Braintree Sandbox 授权 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46241204/

相关文章:

braintree - 如何在braintree中扩展授权状态

php - Stripe 3 层支付订阅

通过存储用户凭据在 php 中集成 Paypal

javascript - 如何使用 Braintree 在每月付款中每次折扣不同的值

java - 在做出 CreateRecurringPaymentsProfileResponseType 响应后,定期付款配置文件中遗漏了一些字段

php - 我的代码有什么问题( future 支付服务器端集成)

braintree - Braintree 沙盒 API : 'Billing state format is invalid' 上的突然失败请求

api - 通过 PayPal REST API 进行银行支付

ios - 集成 Paypal SDK for IOS 时出现 PayPal 链接错误

php - Paypal IPN 监听器代码挂起/无响应