Where are Stripe tokens from Memberhip 2 Pro stored ?

I'm interested in incorporating Memberships 2 Pro into a site I'm building to handle recurring subscriptions to give access to features of the site, But to do this I'd need to have a way to access the Stripe tokens for the members (Customer ID and Card ID)

  • StrangeBiscuit

    Hmm...how does it process the recurring billing then? I thought Stripe Subscriptions requires both a Customer ID and Card ID in the API call to charge the card on file.

    I'm asking because we're building a subscription-based multi-vendor marketplace platform and in addition to set monthly recurring subscription fees we also need to charge a little additional each month based on usage (a fraction of a dollar per order of each vendors products).

    As such, I need to write a function that loops through the users, counts up their orders and makes a custom call to Stripe to bill these fees. That's why I'm looking for a membership solution where I can programmatically access the users Stripe tokens (Customer ID and Card ID is what I believed were needed) in the function.

    Believe I could probably do this by combining WooCommerce Subscriptions and WooCommerce Membership but I'd prefer to do it all-in-one via Memship 2 Pro if I can.

  • Ash

    Hello StrangeBiscuit

    M2 doesn't charge the card for recurring payment. It's stripe where the subscription is created and who charges the card in a regular recurring interval. And when a payment is made, stripe sends the post data to the webhook URL. That post data contains all the information that M2 needs to renew the subscription in the plugin's end.

    I am not sure if you can charge the card with the information, but I have asked the developer if has any idea to give you any suggestions. We appreciate your patience.

    Have a nice day!


  • Paul Kevin

    Hey there StrangeBiscuit ,

    Hope you are well today. Previously Membership would use a cron to handle Stripe subscriptions. With the customer id saved in the members details, this is used to retrieve the Stripe customer object:

    $member = MS_Factory::load( 'MS_Model_Member', $user_id );
    $customer_id 	= $member->get_gateway_profile( self::ID, 'customer_id' );
    $customer 	= Stripe_Customer::retrieve( $customer_id );
    if ( isset( $customer->deleted ) && $customer->deleted ) {
    	$customer = null;
    	$member->set_gateway_profile( self::ID, 'customer_id', '' );

    The above gets the customer using the Stripe php api and checks if the customer still exists. If the customer is deleted, we set the customer as null.

    You can view the old method in premium\gateway\stripeplan\class-ms-gateway-stripeplan.php from line 627 on the function "request_payment". We dont use this method anymore as webhooks are more reliable.

    Warm Regards
    Paul Kevin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.