Title: Catch response code when submiting the form
Last modified: September 18, 2017

---

# Catch response code when submiting the form

 *  Resolved [Orange06](https://wordpress.org/support/users/miha02/)
 * (@miha02)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/catch-response-code-when-submiting-the-form/)
 * Hi,
 * I’m trying to send user email If transaction was successful. I found in front_page.
   js where the “Success” dialog appears and where .braintree-payment-form.submit();
   but I’m having difficulties with finding the “file(/s?)” (or code) which is/are
   listening to server response. Is there a way I can catch successful transaction
   before “success” dialog fires/ shows up ? I’m sending some form data to separate.
   php where data gets sorted and where email is send… but I have the wrong timing;
   email gets send either before transaction is send, or in second chance, the form
   already clears up- before my code in “success dialog” gets executed.
 * Where can I put my code
    if (transaction.success == true) { // send my form data
   before it gets cleared }
 * 🙂 I Hope I explained it well 🙂

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [mra13 / Team Tips and Tricks HQ](https://wordpress.org/support/users/mra13/)
 * (@mra13)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/catch-response-code-when-submiting-the-form/#post-9508651)
 * I have added a new hook that gets triggered after a transaction. You should be
   able to use that hook.
 * Here is the action hook that I added.
 *     ```
       do_action('wp_braintree_payment_completed', $wp_braintree_order_id);
       ```
   
 *  Thread Starter [Orange06](https://wordpress.org/support/users/miha02/)
 * (@miha02)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/catch-response-code-when-submiting-the-form/#post-9509434)
 * Thank you for your response!
 * I see where you put that yes, but problem is, form still gets cleared before 
   message containing transaction information shows up… I don’t want to use db and
   all the unnecessary code just to send email when transaction is done… Can I trigger
   javascript function before page reloads or does it reload automatically when 
   sending CC info and waiting for respond ?
 *  Thread Starter [Orange06](https://wordpress.org/support/users/miha02/)
 * (@miha02)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/catch-response-code-when-submiting-the-form/#post-9509546)
 * I figured it out, thank you 🙂
 *  Thread Starter [Orange06](https://wordpress.org/support/users/miha02/)
 * (@miha02)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/catch-response-code-when-submiting-the-form/#post-9509572)
 * Solution for anyone else trying to achieve the same;
 * You can manipulate messages and customize div classes and visual stuff in main.
   php in /plugins/wp-braintree – be careful when doing this.
    Around line 420 (
   nice number :)) there should be “if($result->success)” and in here you can put
   you php logic when transaction is finished successfully, few lines below you 
   will find “else if ($result->transaction)” and in here you can put your logic
   for failed transactions. Below, around line 570 you will find <table> where information
   like credit card number and the rest is- here you can expand this to add First&
   Last name and email- which you can catch them in “if($result->success)” under
   $_POST[‘your-input-name’]. I did it like this to send user email if transaction
   was successful, and to send admin email that new transaction was just made – 
   since braintree himself doesn’t offer email notice if new transaction was made
   🙂
 * Thank you [@mra13](https://wordpress.org/support/users/mra13/) !

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Catch response code when submiting the form’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-braintree_fcffe2.svg)
 * [WP Braintree](https://wordpress.org/plugins/wp-braintree/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-braintree/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-braintree/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-braintree/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-braintree/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-braintree/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Orange06](https://wordpress.org/support/users/miha02/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/catch-response-code-when-submiting-the-form/#post-9509572)
 * Status: resolved