#Hemant-subscription-end-date
1 messages ยท Page 1 of 1 (latest)
Hello! When you say an "end date" do you mean the date that the subscription will be cancelled?
yes
When you create a subscription you can set cancel_at (see https://stripe.com/docs/api/subscriptions/create#create_subscription-cancel_at) to a future timestamp to have the subscription be automatically cancelled at that time
Let me check that Karbi. Thanks ๐
This does not work @pine fog . I have create session like this :
SessionCreateParams params = SessionCreateParams.builder().setMode(SessionCreateParams.Mode.SUBSCRIPTION)
.setSuccessUrl(successURL).setCancelUrl(cancelURL)
.addLineItem(SessionCreateParams.LineItem.builder().setQuantity(1L).setPrice(prodPrice).build())
.build();
session = Session.create(params);
Ah sorry about that - I missed the fact you were using Checkout Sessions to create your subscription. In that case, your best option is to update the subscription to set cancel_at AFTER it's been created.
Let me try that @pine fog . Let me come back to you with success or failure ๐
Sorry to bother you @pine fog . How can i retrieve subscription for that particular instance ?
You can wait until the checkout session has been completed (which will trigger the checkout.session.completed event) and you can find the Subscription ID on the Checkout Session object https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-subscription
The checkout.session.completed event is something you'd get from a webhooks (see https://stripe.com/docs/webhooks).