Stripe API subscriptions flow? - stripe-payments

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:
User signs up and in the backend, create a stripe customer for said user and save the id into my user object database.
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!

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

Related

Stripe Customer Portal - show specific subscription

I have one Stripe Customer, that attached to many companies into my project. Every company has its own subscription. So one Customer has many Subscriptions.
But during manage subscriptions on Customer Portal page I want to see just one subscription related to company (for now I see all Subscriptions related to the Customer).
Is there way (param) to show just one subscription related to specific Company (maybe by its ID) on Customer Portal page?
It's not possible right now to restrict the subscriptions managed in a Customer Portal session. You pass the customer parameter on creation and all subscriptions associated to that Customer object are manageable.

Can I find if a user subscription is active or not with their email in stripe?

I am trying to create subscription for my app. My plan is to :
(1)Ask email and phone , save it in their pc.
(2)show details about 2 subscription plans (monthly,yearly)
(3)creating a button for both and sharing subscription link created by stripe (automatically stripe does that)
(4)Check user have active subscription either in monthly or yearly.
(5)if yes continue to app, else show the page with details.
Now I want to know how to know that if that user have active subscription or not with only their email and phone number.(without stripe customer id)
And also I don't want to use html , js in my app that's why I am choosing python for this.
Thanks in advance whoever going to help me.
You can list Customers in the Stripe API and filtering by the email parameter. This will give you an array of Customers with that email address.
You can then list Subscriptions on those Customers using the customer parameter.
You can use auto-pagination to iterate through the "pages" of lists you get back from the API (the limit parameter on list API calls defaults to 10).

Make payment to different bank accounts through razorpay payment gateway integration in node.js

Suppose I am a middle man like amazon e-commerce.
I have bank details of many retailers.
But I want my customers to pay directly to retailers.(Not paying to me in between)
How can I achieve this?
I have already checked razorpay routes. But there is no api to add bank accounts in razorpay.
You have to Add Bank Accounts information of each retailer using Razorpay Dashboard.
Under Route Menu option -> Accounts -> Add Accounts.
Note: Every account added here must be activated with KYC.
Once you add accounts, you will get unique 'Account_ID' for every account you have added. You can use them to transfer/split/route payments.
Refer image given

Migrating stripe subscription to be SCA compliant

I have a subscription, I collect card details on signup with a 7 day trial, after which the subscription bills monthly.
From what I understand the subscription API is not SCA compliant. Instead
An off_session payment Intent must first be setup when collecting card details.
At the end of each month a scheduler must be triggered to attempt to charge the registered card.
Is this the case? Am I now responsible for scheduling payments?
Update
For those who want some starter code, I created a working playground here with subscriptions, frontend (react) and backend (express) on glitch.
It's not true that Stripe's Subscription API is not SCA-ready, it is, and you don't have to set up your own scheduling like that. The docs you linked to are generally aimed at processing one-off payments(like saving a customer's details and then allowing them to use them again when they re-visit your site to purchase something new, for example) as opposed to recurring ones.
https://stripe.com/docs/billing/subscriptions/payment describes how to set up a subscription in a way that is SCA-ready. While the customer is on-session on your payment page, you collect card details and create a subscription for the customer, which will generally attempt a payment for the first billing period. You then check the status of the subscription after it's created, and handle the outcomes:
the subscription is active and the payment was successful, so you can proceed with provisioning your service to the customer.
the subscription is incomplete — for SCA purposes, let's say this is because 3D Secure authentication was required for that first payment. In this case, the latest_invoice of the subscription exposes a PaymentIntent property, and you use that PaymentIntent in conjunction with your frontend code using stripe.js to walk the customer through authenticating the payment, and that activates the subscription.
the subscription is trialing — if the subscription doesn't involve an initial payment, like when using a trial period for example, you can also check if the subscription has a pending_setup_intent. You can use this on your frontend to have the customer complete a 3D Secure authentication, so that future payments(like the first one after the trial) are more likely to successfully claim an exemption and not require having the user authenticate at that point.
You can also instead use Stripe Checkout to easily collect payment details and set up a customer and subscription for you, while also handling any initial authentication that's needed : https://stripe.com/docs/payments/checkout/server#create-subscriptions
As for the recurring payments, Billing can handle that for you. You can configure you settings to automatically email the customer to complete 3D Secure if it's encountered on a recurring payment. So you can absolutely build an SCA-ready solution with the subscriptions API on Stripe.

Combine Stripe Subscribe and Connect in one stage

Is there a way for me as a platform to sign someone up to a subscription plan (my customer) then also authenticate them with connect.stripe so that they are a connected account?
Not directly, no. Subscriptions with Stripe are associated with a Customer object, which is entirely distinct from an Account object representing a Connected Account.
You can certainly create a customer object and an account object, and then store the two IDs (cus_xxx) and (acct_xxx) together in your own system to link them together as the same person, but there is no linkage in Stripe's API for this relationship.

Resources