#dimiszk
1 messages · Page 1 of 1 (latest)
Hi there!
How do you plan to create the subscriptions? With a Checkout Session (recommended), or directly calling the Subscription endpoint?
With a Checkout Session
Then you can create a Checkout Session by passing line_items.price with a price ID, or use line_items.price_data and line_items.price_data.product_data if you don't want to create products/price in Stripe.
But then i must create a price on stripe? (how do i get the price ID). I don't want to create anything on stripe except the recurring payment.
No, you don't have to create a price ID! Like I said you have two different options:
- Create a Checkout Session by passing
line_items.price, this requires a price ID - or create a Checkout Session with
line_items.price_dataandline_items.price_data.product_data. In this case no need to create any products/price in Stripe, you directly set the price/currency/etc. in the API call.
Ι am very confused with the API... Could you give me a json sample?
Sure, give me a few minutes.
In Node.JS it would look something like this:
const session = await stripe.checkout.sessions.create({
mode: "subscription",
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
line_items: [{
price_data: {
currency: "eur",
unit_amount: 500,
recurring: {
interval: "month"
},
product_data: {
name: "test"
}
},
quantity: 1,
}],
});
Thank you very much !!! I 'll give it a try. I am using .NET.
You'll need to adapt the code a little. You can see a simpler example here (using price ID) in .NET
https://stripe.com/docs/api/checkout/sessions/create?lang=dotnet