Reputation: 81
I am implementing recurring payment for my e-commerce website with Stripe (quite used to manipulate the payment intent creation, confirm payment, listen to webhook flow for one time payment but first time with recurring/subscription payments). I use react for the front and firebase cloud functions for the back.
I want to be able to charge the amount that I calculate with my own system of products and discounts which is not exactly the same than Stripe's one in a given per month or per year basis after having created the customer on Stripe.
It seems after searching the web and reading stripe documentation that they really want to push you to create products and prices on stripe (with API or via the dashboard) and create a subscription with their respective Ids, but I have already a system and don't want to have data duplicated or having to change the products and prices to fit with Stripe APIs. My main resource is https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements&element=card#build
So my question is : Is there a way to create a subscription using something like
const subscription = await stripe.subscriptions.create({
customer: customerId,
items: [{
price: myCalculatedPrice, // like 73.50€
period: myCalculatedPeriod, // monthly or yearly
}],
});
I Read a lot of stripe documentation and tutorials beside of the habitual stackoverflow search without finding any response to my question.
Have a nice day!
Upvotes: 8
Views: 2720
Reputation: 1201
There is not a way to avoid using Prices/ Products with Subscriptions, https://stripe.com/docs/billing/subscriptions/overview.
You can create the Product first, https://stripe.com/docs/api/products/create and then pass the price_data
and that product id when you create your subscriptions, https://stripe.com/docs/api/subscriptions/create#create_subscription-items-price_data if you do not want to explicitly pass a Price id.
Upvotes: 3