【发布时间】:2015-07-11 05:59:04
【问题描述】:
我正在使用带有 PHP sdk 的 Paypal/Braintree 并设置 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 请求中,我保存 nonce,然后在 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 的参数都按原样填写,包括 nonce 具有通过弹出登录后填写的 payment_method_nonce 的值这一事实。奇怪的是,如果您按下按钮并再次授权,它就会起作用。请帮我用这个把头发扯掉。
【问题讨论】:
-
据我了解(我不擅长贝宝),如果您发送请求两次,它将起作用,所以您是否尝试将第一个请求和第二个请求保存在某个地方然后看看区别
-
我已经减少了发送到 Braintree_Customer::create 的参数,只使用 paypal 付款的 paymentMethodNonce,它仍然第一次失败,第二次成功。比较请求显示 nonce 两次都成功通过。
-
您需要比较第一次和第二次发送到贝宝的参数......我知道它必须相同......但我们应该这样做......因为如果相同的参数和相同的请求,它必须给出相同的结果
-
嗨,利亚姆。我是 Braintree Pay with PayPal 团队的开发人员。为了澄清,您已经在 logbeforectry 中查看了每个请求的输出,并且每个请求都包含一个付款方式 nonce?
-
如果是这种情况,并且您仍然无法通过第一个请求,我建议您通过 support@braintreepayments.com 与我们的支持团队联系。随意链接这个问题并包括我的名字(Goggin),我们将查看我们这边的日志以验证是否正在发送付款方式随机数参数。
标签: javascript php paypal braintree