Auto recurring using Membership 2 Pro for POST api call

I am developing payment gateway for the Membership 2 Pro. Payment gateway doesn't handle auto recurring. so I have to make it happen using Membership 2 Pro for POST api call to payment gateway. Can you please guide me by giving overview of how membership 2 Pro handle auto recurring payment?

  • Panos

    Hi Hazem Tasmem ,

    I'm afraid it's a very wide question so I'll try provide some guidance to start with.

    You can use as guide the stripe subscriptions gateway located in

    You'll need to set the class properties (variables) accordingly in your php file. Also don't forget to include your gateway's api files if it provides any.

    The most important method is process_purchase(). You'll need to create a method with the same name as it is called by MS_Controller_Gateway when payment notification is received from gateway. This is where it sets the subscription invoice as paid.

    It's also required to use the action hook 'ms_gateway_toggle_' . $gateway_id
    where $gateway_id is the id you gave to your gateway. In the stripe file gout can see an example:


    where the stripeplan is the id of the gateway.

    Regarding recurrence, it's depended on your gateway. For example stripe supports recurring payments and you can see the args stripe requires in the update_stripe_data_membership() method :
    $plan_data['interval_count'] = $interval_count;

    If your payment method does not support recurring payments then you could use WordPress schedules to request payments.

    Hope this helps :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.