Syn
Syn

Reputation: 1128

Stripe API subscriptions flow?

Using Node.js

I got a question with the flow of the API.

My web app allows users to use the site for free but gives them a choice to "subscribe" to other users and view their premium content which charges them monthly.

Looking at the stripe API, to add a subscription to a user, I would need customer object. Would the proper flow of this be:

  1. User signs up and in the backend, create a stripe customer for said user and save the id into my user object database.

  2. When user subscribes to another user, grab their customer id from the database and create the subscription.

Also side question, does this allow for multiple subscriptions of the same product? Because a user can subscribe to multiple users

Thanks!

Upvotes: 0

Views: 578

Answers (1)

duck
duck

Reputation: 5470

Your understanding of Customers sounds correct; you collect a user's credit card details, create a Customer object, then using that id, sign the Customer up for a Subscription.

With a Stripe Subscription you can use quantity or have multiple subscription items attached to a single Subscription. So if the user already has an active subscription, you could grab this and increase the quantity or add a second plan.

e.g. you could bill a user for Plan A and Plan B on a single Subscription, or 2 x Plan A, etc

see:

https://stripe.com/docs/api/subscription_items/create#create_subscription_item-quantity

https://stripe.com/docs/api/subscription_items/create

Upvotes: 2

Related Questions