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
    wp-content/plugins/membership/premium/gateway/stripeplan/class-ms-gateway-stripeplan.php

    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:

    $this->add_action(
    			'ms_gateway_toggle_stripeplan',
    			'update_stripe_data'
    		);

    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