#Naitik
1 messages · Page 1 of 1 (latest)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
For example:
user have to pay total 600$ but they don't have right now so he will choose subscription option for 6 months.
So he have to pay 100 $ every month.
After completion of 6 months period I have to automatic cancel subscription.
Ok, you can use a schedule to cancel the subscription
I am not using direct subscription API because I have to enter the payment card details of the user. so I am managing subscriptions in checkout session API.
You can create a schedule from subscription https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-from_subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But the problem is when I use checkout session API I am not getting subscription id directly I am getting customer id session id etc.
If i use subscription api then everything works. do you know we can open stripe link for payment details using subscription api?
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-subscription once the checkout session is completed, you'll get the subscription ID from the checkout session object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I didnot get please check
The chekcout session status is still open.
As I said before, once the checkout session is completed, you'll get the subscription ID from the checkout session object
I got this response only after I added the card details and submitted
When the chekcout sesison is completed, it status would become complete
when I check in stripe account I can see subscriptions in customer table but when I check logs didnt get subscrtion id
You should check the checkout.session.complete event
What changes do I have to make in the code to complete it?
const session = await stripeClient.checkout.sessions.create({
customer: customer.id,
payment_method_types: ["card"],
subscription_data: {
trial_end: startDateTimestamp
},
line_items: responses,
mode: "subscription",
success_url: `${baseUrl}/payment/success?type=subscription&session_id={CHECKOUT_SESSION_ID}&customerID=${customer.id}`,
cancel_url: `${baseUrl}/payment/cancel?session_id={CHECKOUT_SESSION_ID}`,
});
here is the code and make sure mode is subscription
You should create a webhook endpoint and listen to checkout.session.complete event
I don't think you understand me.
If you are new to webhooks, please read this doc to get started https://stripe.com/docs/webhooks
What do you look for to know that a check out session is open and not complete?
Check its status https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-status
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.