Reputation: 5905
I am using Paypal/Braintree with PHP sdk and setting up Vault flow to create subscriptions. It all worked fine in Sandbox but now in product I get error code 93108, message: Unknown paymentMethodNonce.
My client side code is:
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;
}
});
In the Ajax request I save the nonce, and then use it in the Braintree_Customer::create
My server side code is:
$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
}
It brings back the error response as described above. I have checked and the parameters for $cargs are all filled as they should be, including the fact that the nonce has the value of the payment_method_nonce filled after logging in via the popup. The strange thing is that if you hit the button and authorize again it works. Please help I am tearing my hair out with this one.
Upvotes: 2
Views: 1980
Reputation: 7976
Just to close this issue out, the Braintree support team helped diagnose the issue, which was that the client token being generated was from the Braintree Sandbox environment and then used in the Braintree production environment.
Upvotes: 3