#Naitik

1 messages · Page 1 of 1 (latest)

steady galleonBOT
gentle root
mighty berry
#

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.

gentle root
#

Ok, you can use a schedule to cancel the subscription

mighty berry
#

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.

gentle root
mighty berry
#

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?

gentle root
mighty berry
#

I didnot get please check

gentle root
#

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

mighty berry
#

I got this response only after I added the card details and submitted

gentle root
#

When the chekcout sesison is completed, it status would become complete

mighty berry
#

when I check in stripe account I can see subscriptions in customer table but when I check logs didnt get subscrtion id

gentle root
#

You should check the checkout.session.complete event

mighty berry
#

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

gentle root
#

You should create a webhook endpoint and listen to checkout.session.complete event

#

I don't think you understand me.

mighty berry
#

What do you look for to know that a check out session is open and not complete?

gentle root