3

In the simple javascript drop-in UI, when the form is being submitted, braintree.js will intercept the form submission and inserts a hidden field named "payment_method_nonce" into the form, before the submission actually goes to the server.

However, when using the AngularJS as the frontend framework, I generally don't want the form submission to directly go to the server and then do a page reload. Instead, I want my AngularJS function to intercept and deal with the form submission (e.g., via ng-click or ng-submit), AND in its processing it needs to retrieve and use the "payment_method_nonce" value.

I tried it and it can still intercept the form submission. However, it seems like AngularJS intercepts the form submission BEFORE braintree.js does and inserts the "payment_method_nonce" field.

Hence, my AngularJS code that responds to the form submission cannot retrieve that "payment_method_nonce" field and perform appropriate processing. Any suggestions on how I can work around this?

Thanks!

XIN ZHANG
  • 133
  • 6
  • After reading more braintree docs, it turns out registering a paymentMethodNonceReceived callback when setting up the braintree gateway is the right way to go! – XIN ZHANG Nov 23 '14 at 16:08
  • I work at Braintree. Glad you figured it out! You should post that as an answer -- it's totally fine to answer your own question. – agf Nov 24 '14 at 16:56
  • 3
    Can you please provide a sample code for this because I have specified the paymentMethodNonceReceived and cannot get the call back – Sandeep Taneja Jan 26 '15 at 16:35

1 Answers1

5

After reading more braintree docs, it turns out registering a paymentMethodNonceReceived callback when setting up the braintree gateway is the right way to go!

XIN ZHANG
  • 133
  • 6
  • Note that this function has been replaced with `onPaymentMethodReceived`, however the way of using it and the resulting behaviour remain the same. See https://developers.braintreepayments.com/guides/client-sdk/javascript/v2 – Boris Dec 17 '15 at 14:46
  • 1
    Could you post your sample code and show how you did it? Having same problem using angular – iTenzo Jun 06 '16 at 06:01