• What I understand :

    1) The callback_function only works with PayPal and Stripe.

    2) The callback_function is added to the short code this way:

    [wpi_checkout item='Item from line items list' title='Any title I choose' callback_function='my_callback_function']

    3) The callback_function is placed in functions.php and is triggered with the completion of the IPN handshake.

    What is not clear is:

    1) What are the variables I can manipulate on return of the callback.

    2) How is the callback_function to be handled in functions.php. Do I need to tie it to a custom hook for wp-invoice and if so, what is the hook?

    What I have tried and have failed at:

    Within functions.php:

    function my_callback_function($transaction_data){
        //My procedures here e.g.
        wp_mail( 'myemail@demo.com', 'Success from PayPal', 'Success from PayPal' ); 
    }

    This has not been successful. So, I am supposing that a hook is necessary here. I am not sure what hook to use. So, I need some direction.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor MariaKravchenko

    (@mariakravchenko)

    Hello.

    Thank you for your question. We will respond as soon as possible.

    Regards.

    Thread Starter cravaus

    (@cravaus)

    I misstated above. I understand that the callback function will work only with PayPal and Authorize (not with stripe). Nevertheless, I am not able to get the callback function to trigger.

    It appears from your code that the callback function should also include $transaction_data as arguments. So I am adding that. I am pretty sure this is correct although none of your documentation explains this.

    Regarding the $transaction_data it appears that the following is passed and can be manipulated by me:

    
                    'new_user' => $new_user,
                    'new_user_password' => $new_user_password['pass'],
                    'transaction' => array(
                      'payment_status' => 'Complete'
                    ),
                    'billing' => array(
                      'customer_information_domain_name' => $domain_name['domain_name'],
                      'user_email' => $user_email
                    ),
                    'user_data' => array(
                      'ID'         => $user->ID,
                      'first_name' => !empty( $user_meta['first_name'][0] ) ? $user_meta['first_name'][0] : 'User',
                      'last_name'  => !empty( $user_meta['last_name'][0] ) ? $user_meta['last_name'][0] : 'User',
                      'user_email' => $user_email,
                      'user_login' => $user_email
                    ),
                    'items' => $items,
                    'other_meta' => array(
                      'charge_amount' => $post['mc_gross'],
                      'cc_number'     => $post['payer_email'],
                      'transaction_id'=> $post['txn_id']
                    ),
                    'post_data' => $post_data  //all the meta keys associated with the post id
    

    Hopefully this is the case because I will need to manipulate a few of these variables in my call back function.

    So this is what I am able to discern. Am I off base? Have I misinterpreted?

    I have tested my simple call back function by calling it with php on my success page. it does work: When I call the function the test email is sent. Therefore, if I am correct in all the above assumptions, and I set up the short code as explained in the first post, and the function is in functions.php as stated in my first post, then why is it not triggering with successful payment in the sandbox and with the IPN handshake completed? What is missing? Do I need to have Return URL on at PayPal? I do not think that this is necessary but is it? I have tried it but still no success? Do I need to use a special hook? I do not know why that would be the case given that I see it is set up with call_user_func(). I think a simple function with an argument would be sufficient. Am I wrong? Could this be because I am in sandbox mode. Does the callback not work in sandbox?

    I need the call the back function to work for this project so please respond.

    Thread Starter cravaus

    (@cravaus)

    I did a live test and the callback_function works fine live. It does not work in the business sandbox. The IPN and other settings are set up just like on the main account. I tried making several other payer sandbox accounts and paying from them and still no response from the sandbox. So, that is the issue. The only other option I see is to test it on a live account using some items with penny values. That is not ideal but it works.

    Plugin Contributor Anton Korotkoff

    (@anton-korotkoff)

    Hello,

    so you are sure it works when Live and it doesn’t when Sandbox? Are you talking about PayPal or Authorize.net?

    Thread Starter cravaus

    (@cravaus)

    I am just working with PayPal. I have tried for weeks to get it to work. I may have missed something but I checked over the settings multiple times and started going backwards through your code trying to see how it all works. Something is not working at the end of the sandbox routine. The IPN handshake takes place. It will not do the redirect (I see that this is a common problem in the sandbox) and the callback_function is not triggered. I know that it is delivered in the array to the sandbox. Following the sequence in the console in Firefox after payment, I was not able to discern precisely what was coming back to me. That is as far as I was willing to go after weeks of no progress on my project. I could find no reason in you code for it not to work at least live.

    I then tested it live and all is well. I did a print_r on the $transaction_data to see what all I could work with there. This SPC with the call back function is a really cool feature. I wish you would have documented it a little better. Also I see that there are switches to turn off components of the shortcode template but I could not figure out how to use them. I ended up using CSS to turn off the components. I just wanted the button to show up with no form. I suppose I could have used your switches but all you have done for me in the documentation is point to the fact that the switches are there without telling me what they are or how to use them. I would have prefered using the switches and keeping my page clean. So, as a developers tool that would make me happier with WP-Invoice.

    At any rate, thanks for the program it is working well. I finished my project and all is working great!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Single Page Checkeout and callback_function’ is closed to new replies.