process_ipn_return not being called

I am completing the development and testing of a MarketPress Payment Gateway plugin for using Touchnet Payment Systems UPAY as the payment services provider. I have all aspects of the process working except for receiving the notifications from TouchNet when the payment process is complete. I have extracted the $IPN_URL value to use for testing the callback process. To determine wheter the process_ipn_return() is being called, I add a wp_mail call that sends an email message to me when the call is made. The start of my function_ipn_return() is:

function process_ipn_return() {
global $mp;

wp_mail('Michael@MichaelCagle.com','TouchNet process_ipn_return v5','Message body','Content-Type: text/html; FROM: Michael@MichaelCagle.com');

The register call is:

mp_register_gateway_plugin( 'MP_Gateway_TouchNet', 'touchnet-payments', __('TouchNet Checkout', 'mp'), true );

Thanks for any help you can provide.

Mike Cagle

  • aecnu
    • WP Unicorn

    Greetings mcagle,

    Thank you for being a WPMU Dev member!

    I will see about getting our lead developer in here to advise or offer advice in an effort to assist in the finishing of your gateway coding.

    This may take longer then a normal ticket, but we do hope to help you get this sorted out asap.

    Cheers, Joe :slight_smile:

  • Aaron
    • CTO

    I've done some internal tests. The only reasons it would not be called is:

    - a problem with rewrites - this does not seem the case, but not positive
    - Your test gateway is not active for that blog.

    If you want to debug, you can modify the handle_gateway_returns() function.

  • mcagle
    • WPMU DEV Initiate

    I placed wp_mail statements in handle_gateway_returns and found that handle_gateway_returns was being called and was calling do_action.

    I added mail statements to do_action and found that is was calling a MP_GATEWAY function. I was not able to determine the exact name of the function it was calling.

    I am stuck and this is getting critical for me. Any help you can provide with be greatly appreciated.

    My modified do_action function is below:

    function do_action($tag, $arg = '') {
    global $wp_filter, $wp_actions, $merged_filters, $wp_current_filter;

    $caglerpt = "";
    if ($tag == 'mp_handle_payment_return_touchnet-payments') {
    $localtrace = true;
    } else {
    $localtrace = false;
    }

    if ( ! isset($wp_actions) )
    $wp_actions = array();

    if ( ! isset($wp_actions[$tag]) ) {
    $wp_actions[$tag] = 1;
    if ($localtrace) {
    $caglerpt .= $tag . " First Use ~\r\n";
    }
    } else {
    ++$wp_actions[$tag];
    if ($localtrace) {
    $caglerpt .= $tag . " Reuse ~\r\n";
    }
    }

    // Do 'all' actions first
    if ( isset($wp_filter['all']) ) {
    $wp_current_filter[] = $tag;
    $all_args = func_get_args();
    if ($localtrace) {
    $caglerpt .= $tag . " All Filter \r\n";
    }
    if ($localtrace) {
    $caglerpt .= $tag . " _wp_call_all_hook \r\n";
    }
    _wp_call_all_hook($all_args);
    }

    if ( !isset($wp_filter[$tag]) ) {
    if ( isset($wp_filter['all']) )
    array_pop($wp_current_filter);
    $caglerpt .= $tag . " all=" . isset($wp_filter['all']) . "\r\n";
    if ($localtrace) {
    //mail("Michael@MichaelCagle.com",$tag . " plugin.php - All filter hook",$caglerpt,"From:Michael@MichaelCagle.com");
    }
    return;
    }

    if ( !isset($wp_filter['all']) )
    $wp_current_filter[] = $tag;

    $args = array();
    if ( is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0]) ) // array(&$this)
    $args[] =& $arg[0];
    else
    $args[] = $arg;
    for ( $a = 2; $a < func_num_args(); $a++ )
    $args[] = func_get_arg($a);

    // Sort
    if ( !isset( $merged_filters[ $tag ] ) ) {
    ksort($wp_filter[$tag]);
    $merged_filters[ $tag ] = true;
    }

    reset( $wp_filter[ $tag ] );

    do {
    foreach ( (array) current($wp_filter[$tag]) as $the_ ) {
    if ( !is_null($the_['function']) ) {
    if ($localtrace) {
    foreach ($the_ as $k => $v) {
    $caglerpt .= "@" . $k . "=" . $v . "+\r\n";
    }
    /* foreach ($the_['function'] as $k >= $v) {
    $caglerpt .= "#" . $v . "=" . "`\r\n";
    foreach ($v as $vv) {
    $caglerpt .= "*" . $vv . "_\r\n";
    }
    }
    */ }
    call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));
    }
    }
    } while ( next($wp_filter[$tag]) !== false );
    array_pop($wp_current_filter);

    if ($localtrace) {
    mail("Michael@MichaelCagle.com","plugin function call report-" . $tag,$caglerpt,"From:Michael@MichaelCagle.com");
    }
    }

  • mcagle
    • WPMU DEV Initiate

    Register statement:

    mp_register_gateway_plugin( 'MP_Gateway_TouchNet', 'touchnet-payments', __('TouchNet Checkout', 'mp'), true );

    Beginning of payment-gateway code. Please review the "on-creation" function. I may have botched that.

    <?php
    /*
    MarketPress TouchNet Plugin
    Author: Michael Cagle, Michael@MichaelCagle.com
    */

    class MP_Gateway_TouchNet extends MP_Gateway_API {

    //private gateway slug. Lowercase alpha (a-z) and dashes (-) only please!
    var $plugin_name = 'touchnet-payments';

    //name of your gateway, for the admin side.
    var $admin_name = '';

    //public name of your gateway, for lists and such.
    var $public_name = '';

    //url for an image for your checkout method. Displayed on checkout form if set
    var $method_img_url = '';

    //url for an submit button image for your checkout method. Displayed on checkout form if set
    var $method_button_img_url = '';

    //whether or not ssl is needed for checkout page
    var $force_ssl = false;

    //always contains the url to send payment notifications to if needed by your gateway. Populated by the parent class
    var $ipn_url;

    //whether if this is the only enabled gateway it can skip the payment_form step
    var $skip_form = true;

    //only required for global capable gateways. The maximum stores that can checkout at once
    var $max_stores = 10;

    // Payment action
    var $payment_action = 'Sale';

    //paypal vars
    var $API_Username, $API_Password, $API_Signature, $SandboxFlag, $returnURL, $cancelURL, $API_Endpoint, $paypalURL, $version, $currencyCode, $locale, $API_Loaded;

    /****** Below are the public methods you may overwrite via a plugin ******/

    /**
    * Runs when your class is instantiated. Use to setup your plugin instead of __construct()
    */
    function on_creation() {
    global $mp;

    $settings = get_option('mp_settings');

    //set names here to be able to translate
    $this->admin_name = __('TouchNet Checkout', 'mp');
    $this->public_name = __('TouchNet Checkout.', 'mp');

    $this->returnURL = mp_checkout_step_url('touchnet-payments');
    $this->cancelURL = mp_checkout_step_url('touchnet-payments') . "?cancel=1";
    $this->version = "69.0"; //api version

    //dynamic button img, see: https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration
    $this->method_img_url = 'https://secure.touchnet.com/C20206_tsa/web/images/poweredby.gif';
    // $this->method_button_img_url = 'https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image&locale=' . get_locale();
    if ($this->API_Loaded <> 'Y') {
    $subj = 'TouchNet Check-on_creation() - API_Status=' . $this->API_Loaded;
    //mail('Michael@MichaelCagle.com',$subj,'','Content-Type: text/html; FROM: Michael@MichaelCagle.com');
    }
    $this->API_Loaded = 'Y';
    date_default_timezone_set('America/Chicago');
    wp_mail('Michael@MichaelCagle.com','TouchNet on-creation - ' . date("F j, Y, g:i a"),'Message body','from: Michael@MichaelCAGLE.com');
    }

    ----- Register Statement

  • Aaron
    • CTO

    Well, you can check if your gateway is actually attaching to the hook by calling:
    $bool = has_action('mp_handle_payment_return_touchnet-payments');

    Additionally you can see what the hook is it's trying to load based on $wp_query->query_vars['paymentgateway'] in that function.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.