如何将客户端ID和生产授权密钥放在paypal快速结账沙箱上

时间:2018-01-12 13:18:48

标签: javascript php paypal braintree express-checkout

以下代码客户端部分的此代码我必须添加生产密钥和客户端令牌。

<script>

    // Render the PayPal button

    paypal.Button.render({

        // Pass in the Braintree SDK

        braintree: braintree,

        // Pass in your Braintree authorization key

        client: {
            sandbox: paypal.request.get('/demo/checkout/api/braintree/client-token/'),
            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: '10', currency: 'USD' }
                        }
                    ]
                }
            });
        },

        // Wait for the payment to be authorized by the customer

        onAuthorize: function(data, actions) {
            return actions.payment.tokenize().then(function(data) {
                console.log('Braintree nonce:', data.nonce);
            });
        }

    }, '#paypal-button-container');

</script>

如何从paypal express沙箱获取客户端ID和秘密身份验证,因为 我必须在下面的代码中添加它们。

client: {
            sandbox: paypal.request.get('/demo/checkout/api/braintree/client-token/'),
            production: '<insert production auth key>'
        },

我已输入我们的沙箱应用验证密钥和ID我收到错误。

1 个答案:

答案 0 :(得分:0)

如果您的生产凭据不正确,您将无法打开PayPal Light框。

您的代码应与此类似:(下面列出的Sandbox和Production Client ID来自演示页面作为示例):

https://developer.paypal.com/demo/checkout/#/pattern/client -

  client: {
            sandbox:    'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
            production: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R'
        },

以下是获取沙盒和Live Client ID的步骤:

  1. 转到PayPal开发者网站https://developer.paypal.com
  2. 点击登录仪表板(使用您的实时PayPal凭证)
  3. 点击我的应用&amp;凭证
  4. 向下滚动到Rest API应用
  5. 点击您创建的应用(或创建应用)
  6. 复制沙箱客户端ID
  7. 点击右上角的直播
  8. 复制Live Client ID