Membership Custom Gateway Documentation?


I purchased this plugin for a project and for the most part it works as I need. It is not friendly to customize (wish it had hooks so I could move my logic outside as a separate plugin) and I cannot seem to get any shortcodes working for subscriptions (I want to redesign all internal pages: account, subscriptions, etc. but the shortcodes don't seem to work) but I was able to work past that. My concern right now, and it's a big issue as it would require me to use another plugin or write a plugin myself, is the custom payment gateway. I have looked over these forums and I have found very minimal information other than to use gateway.paypalexpress.php as an example or pay someone to do this for me (not an option). The problem is there are no comments in this file. So I am expected to guess at how the gateway system works. Do you have any information as to the workflow for the gateway? What methods are the bare minimum (no interface or abstract)? I just need to know what methods are used by the system so I can ensure my gateway is built properly. I am connecting to Vindicia CashBox and any information you can provide would be much appreciated. Once I figure this out, I plan to post my discoveries here to help future developers.


  • Vinod Dalvi

    Hi @Olympusat,

    I have again notified the plugin developer to get his reply here and i hope he will reply here ASAP.

    Is it possible to bypass the page they are directed to when you click on a subscription? I would like to go directly to the payment page

    Do you want to bypass the page they are directed to when you click on a subscription as displayed in the attached screenshot?

    If yes then how will you handle the coupon codes?

    Vinod Dalvi

  • Olympusat

    Thanks for notifying the developer again.

    Currently I am not using the coupon codes. Although I think it wouldn't be hard to have that on the payment page and have the apply coupon just resubmit to the same page to load the coupon (or use AJAX.) I plan to test this today. I think I figured out the gateway for the most part. I will respond back to this post with details to help future developers.

  • Jack Kitterhing

    Hi there @Olympusat,

    Hope you're well today! :slight_smile:

    Did you get this all sorted as you need?

    Although I think it wouldn't be hard to have that on the payment page and have the apply coupon just resubmit to the same page to load the coupon (or use AJAX.)

    Personally I'd recommend using AJAX for that, let me know if you have any questions and I'd be happy to help. :slight_smile:

    Thank you!

    Kind Regards

  • Olympusat

    Hi @Jack Kitterhing,

    Thanks for your reply.

    I am still in the process of sorting this out. I agree with you that I should use AJAX and after spending more time in the code, I believe this is the best method to do this. I haven't got to this point yet as I am still working on the gateway.

    Are there any pages that explain the hooks for the gateways? I seem to have it working but I wanted to be sure I am not missing anything. When I finish this, I will post my understanding of the hooks and class design here.


  • Rheinard

    Hi @Olympusat,

    Its great that you're building a gateway here. I have a few questions.

    1. Have you been using the Membership plugin with this site for long?
    2. Have you got a lot of members already and have they paid using existing gateways?

    The reason I am asking this is because we also have the Protected Content plugin which uses a MVC approach to how the gateways are built. Its a bit better laid out than in Membership.

    That said, if you're happy with Membership and you're gateway is just about finished, I'd be happy to help you get there :slight_smile:

    I don't know much about the Vindicia CashBox gateway. So I had a quick look and found this interesting document that could steer my answer into a number of directions:

    In this spec document, which method are you using? The typical CashBox implementation or the HOA implementation?

    If you're answer is typical, then you'd want to look at the gateway in Membership as your model. If you're using the HOA implementation then the PayPal gateway is the better one to mimic.

    Regardless of the method, you'd want to make sure that your payment return checking works. Its often easy with gateways to perform the transactions, but making sure that it gets captured or notifications contain the right information can be problematic.

    I'd also be happy to take a look at the code for you if you want.


  • Olympusat

    Hi @Rheinard,

    I am already using the as a guide for my Vindicia CashBox gateway. Yes, I am using the typical method for this gateway. Currently, I am able to get the user to make the transaction but I have not completed the gateway yet as I am still learning as I go. Since I am pressed for time, I am making some hard-coded edits where I would prefer not to (paying member mode, I am only using serial so I am not coding for the others. Plus a few other areas like settings) but I plan to improve this after the site launch.

    To answer your other questions. This is a new site and I have never used the membership plugin before. This site is the first time I am using it. I am migrating content and users from the old site which is a Drupal install. I wrote an importer from Drupal 7 to WordPress and this takes a lot of work off my end but it does bring up a concern of how to carry over the users' entitlements. I'll tackle this when I get there for now. I have a little over 40,000 users to carry over.

    This brings me to another question that I haven't been able to locate in the gateway yet. I want to do a cron job every night (I am using a real cron system for WordPress cron jobs, not the poor mans cron) to fetch the data from Vindicia to see if users have cancelled their account. This check only needs to be done once a day as customers are allowed access until their range has expired. Does the gateway provide this functionality? Or is this something I will need to build myself? My only concern is I haven't looked at the database yet to see how data is stored in this plugin. I am hoping it is integrated and I just need to build the method to handle the request. If not, could you provide me any details on a proper workflow for this plugin?

    I haven't gone much past the transaction for the user since this is the part I am still currently working on. I have the payment return hooks commented out currently as I haven't gotten to this part yet and I am really not clear when these are suppose to happen. Currently, I do not see any transactions in my gateway.

    Not sure if it helps but I am using this for my constructor:

    public function __construct() {
            // Construct the parent
            // Add settings
            $this->_add_action('M_gateways_settings_'.$this->gateway, 'settingsPage');
            // If I want to override the transactions output - then I can use this action
            //add_action('M_gateways_transactions_' . $this->gateway, array(&$this, 'transactions'));
            // Check if active
            if ($this->is_active()) {
                // Add action for button on the subscription confirmation page
                $this->_add_action( 'membership_purchase_button', 'render_subscribe_button', 1, 3 );
                // Add action to show Vindicia payment form
                $this->_add_action( 'membership_payment_form_'.$this->gateway, 'render_payment_form', 10, 3 );
                // Payment return (is this needed?)
    //            add_action('membership_handle_payment_return_' . $this->gateway, array(&$this, 'handle_vindicia_return'));
    //            add_filter('membership_subscription_form_subscription_process', array(&$this, 'signup_free_subscription'), 10, 2);
                $this->_add_ajax_action( 'processpurchase_' . $this->gateway, 'process_purchase', true, true );
                $this->_add_ajax_action( 'purchaseform', 'render_popover_payment_form' );
                // Gateway specific scripts
                $this->_add_action( 'wp_enqueue_scripts', 'enqueue_scripts' );

    When I complete this gateway, I will share the code with you. Perhaps this is something you could add to the core plugin but it will need to be optimized because I am doing some dirty practices (hard-coding to my setup) due to a very tight deadline.

    Thanks for your reply and hopefully you can push me in the right direction.

  • Rheinard

    Hi @Olympusat,

    Wow. Tremendous effort converting form Drupal to WordPress (I'm a former Drupal dev too... back in Drupal 5 days). It sounds like you know what you want from the gateway and if serial is what most subscriptions will be that is a good place to start.

    As per my previous post, Membership uses payment notifications. So once a transaction occurs, it relies on the notification messages from the payment gateways. Membership doesn't run code against gateways to check for payment details. For the very reason you identified... the unreliable cron system. Plus, because we have a number of gateways, this opens up room for a lot of errors.

    How this then gets handled in Membership is that we have a URL rewrite. Anything pointing to gets redirected to index.php?paymentgateway= and the rest of the parameters. You can find this in membershipincludes/classes/membershipadmin.php line 6946.

    When a notification then comes in it triggers the 'membership_process_payment_return' action, which consequently causes the Membership_Gateway::process_payment_return() to execute. This would be a good method to look at as it then fires the individual actions for each of the different gateways.

    If you're using cron then you can of course skip this, but then you're completely writing your own code outside of how Membership handles it. If CashBox does send notifications (I'm sure they do) it might be best to tap into how Membership handles it.

    The notification URL could then be... which would ultimately fire an action called 'membership_handle_payment_return_cashbox' which you can hook into to handle the payment return. Then you'll have access to the POST vars coming from cashbox and respond appropriately.

    Hope this helps. It should also answer your question in line 15 of your code snippet.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.