#anil8486
1 messages · Page 1 of 1 (latest)
Hi ,
I am using stripe.checkout.sessions.create , i am getting cors error.
I am using node js
Where is the error? In the browser console? Does the Checkout Session page loads correctly?
No
Yea in the browser console
I have created a api (/subscription) inside this i have checkout.sessions.create
So the Checkout Session page is not loading?
Yes its not loading
Can you share the Checkout Session ID or URL here?
Do i need to redirect from the front end?
There are two main ways to do the redirect:
- Return the checkout.url from your backend, and then on the frontend update the
window.location - Or do a <form action="xxx" method="POST"> on the frontend and the backend can do a redirect
We are talking about a Checkout Session redirect here. Wny are you asking about Subscription? Is this a new question?
Yes , by checkout.sessions.create i am doing mode: "subscription" , so how can i get the subscription id
It's in the Checkout Session object: https://stripe.com/docs/api/checkout/sessions/object?lang=php#checkout_session_object-subscription
But that object we are getting before subscription is created that's why its null
I don't understand.
First you create the Checkout Session and redirect the user to the Checkout page. Once the user submit the form, you will get a Subscription object in the Checkout Session.
When users submit the form, they will be redirected to the success_url you set: https://stripe.com/docs/api/checkout/sessions/create?lang=php#create_checkout_session-success_url
Then you can listen to the checkout.session.completed webhook event to run any code you want.
You can learn more abou this here: https://stripe.com/docs/payments/checkout/fulfill-orders
Okay thanks.
This will be for first month,,
Like its subscription do i need to use other web hooks
You can learn about subscription webhooks here: https://stripe.com/docs/billing/subscriptions/webhooks
But in general we recommend listening to invoice.paid to know when the customer renews the subscription.