#failfayli_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1318793548769792063
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
if (mode == "subscription")
{
// Add the one-time subscription setup fee line item
options.LineItems.Add(new SessionLineItemOptions
{
Price = "price_1QWxOQEFI0S2QMkfME4j1MR6", // Setup fee price ID
Quantity = 1,
});
// Determine the first billing date
if (DateTime.TryParse(model.StartAt, out DateTime startAtDate))
{
// Calculate the first billing date based on the StartAt date
var firstBillingDate = startAtDate.AddHours(-24);
options.SubscriptionData = new SessionSubscriptionDataOptions
{
Metadata = new Dictionary<string, string>
{
{ "SquareBookingId", model.SquareBookingId },
{ "ServiceType", model.ServiceType }
},
TrialEnd = firstBillingDate,
};
}
else
{
throw new ArgumentException("StartAt date is invalid.", nameof(model.StartAt));
}
}
this is working, but it essentially means customers can only make subscriptions starting >72 hours from now (trial end must be 48 hours in the future + my business logic of billing occurring 24 hours before i want the subscription to actually start)
Checkout Session doesn't support creating the subscription in the future date. This can only be done with Subscription Schedule API which allows scheduling a subscription to start in future. I'd recommend checking these guides:
- Subscription Schedule: https://docs.stripe.com/billing/subscriptions/subscription-schedules
- Start subscription in the future using Subscription Schedule: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#start-subscription-future
- Including billing cycle anchor: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#resetting-anchor
ok, thank you