Braintree Paypal 在 Sandbox 中运行但不在生产环境中运行

Braintree Paypal works in Sandbox but not production

我正在使用 Paypal/Braintree 和 PHP sdk 并设置 Vault 流程来创建订阅。在 Sandbox 中一切正常,但现在在产品中我收到错误代码 93108,消息:Unknown paymentMethodNonce。

我的客户端代码是:

braintree.setup(GFormVATVars.br_client_token, "paypal", {
                container: "paypal-container",
                singleUse: false,
                onPaymentMethodReceived: function (obj) {
                    $(".gform_next_button").show();
                    $("span#br_pp_message").html('<img height="15" width="15" src="'+GFormVATVars.spinner_gif+'"/>');
                     $.post(GFormVATVars.ajaxurl,{action: 'process_br_pp_payment_token',token: obj.nonce,security: GFormVATVars.security},function(response) {
                        $("span#br_pp_message").html(response);
                    });
                    return;
                }
            });

在Ajax请求中我保存了随机数,然后在Braintree_Customer::create

中使用它

我的服务器端代码是:

$cargs = array(
                'firstName' => $entry["6.3"],
                'lastName' => $entry["6.6"],
                'company' => $entry["18"],
                'email' => $entry["7"]
$cargs['paymentMethodNonce'] = $_SESSION['wswp_payment_token'];

                                file_put_contents(dirname(__FILE__)."/logbeforectry.php",print_r($cargs,true));
                                try {

                    // Configure Braintree environment
                    Braintree_Configuration::environment( strtolower( $settings['environment'] ) );
                    Braintree_Configuration::merchantId( $settings['merchant-id']);
                    Braintree_Configuration::publicKey( $settings['public-key'] );
                    Braintree_Configuration::privateKey( $settings['private-key'] );
                                    $cresult = Braintree_Customer::create($cargs);
                                    file_put_contents(dirname(__FILE__)."/logcresult.php",print_r($cresult,true));
                                }
                               catch( Exception $e ) {
                                file_put_contents(dirname(__FILE__)."/catchcresult.php",print_r($e->getMessage(),true));
                    // Do nothing with exception object, just fallback to generic failure
                }

它带回了如上所述的错误响应。我已经检查过并且 $cargs 的参数都按应有的方式填充,包括通过弹出窗口登录后随机数具有 payment_method_nonce 填充的值这一事实。奇怪的是,如果您按下按钮并再次授权,它就会起作用。请帮助我用这个撕掉我的头发。

为了解决这个问题,Braintree 支持团队帮助诊断了问题,即正在生成的客户端令牌来自 Braintree 沙箱环境,然后用于 Braintree 生产环境。