Braintree - paymentMethodNonceReceived is not called

I have a dropin UI setup for braintree. I can see the user interface. Before that, I created a client, and I can see the client in a sandbox song. Now I want to add a payment method to the client. I am trying to do the following code, but paymentMethodNonceReceived is not called. I do not know why.

braintree.setup("<?=CLIENT_TOKEN_FROM_PHP?>", "dropin", { container: "divBrainTreeContainer", paymentMethodNonceReceived: function (event, nonce) { console.log(nonce); $('#formProfile').append('<input type="hidden" name="payment_method_nonce" value="'+nonce+'" />'); $('#formProfile').submit(); } } ); 
+8
javascript php payment-gateway braintree
source share
3 answers

According to the @kdetella comment, the <form> element must have a submit button to get a nonce payment method.

+5
source share

I am using below JavaScript and it works fine :

  braintree.setup(clientToken, "custom", { id: "my-sample-form", hostedFields: { number: { selector: "#card-number" }, cvv: { selector: "#cvv" }, expirationMonth: { selector: "#expiration-month" }, expirationYear: { selector: "#expiration-year" }, },onPaymentMethodReceived:function(nonce){ console.log(JSON.stringify(nonce)); return false; } } ); 

The above is the answer below and DOES NOT submit the form:

 {"nonce":"ff2662e1-f1fd-42a3-a16f-d8f3213a2406","details":{"lastTwo":"11","cardType":"Visa"},"type":"CreditCard"} 

means using onPaymentMethodReceived instead of paymentMethodNonceReceived

Thanks http://www.web-technology-experts-notes.in/2015/06/braintree-payment-gateway-integration.html

+7
source share

https://github.com/braintree/braintree-web/issues/58

For custom integration with multiple payment methods, use onSuccess instead of onPaymentMethodReceived.

 braintree.setup(TOKEN, 'custom', { id: 'checkout', paypal: { container: 'paypal-container', onSuccess: function (nonce, email) { // This will be called as soon as the user completes the PayPal flow // nonce:String // email: String } }, onPaymentMethodReceived: function(obj) { // This will be called when the user submits the form } }); 
+2
source share

All Articles