• Resolved Orange06

    (@miha02)


    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

    (@mra13)

    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

    (@miha02)

    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

    (@miha02)

    I figured it out, thank you ??

    Thread Starter Orange06

    (@miha02)

    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 !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Catch response code when submiting the form’ is closed to new replies.