#failfayli_api

1 messages ¡ Page 1 of 1 (latest)

nova sableBOT
#

👋 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.

keen helm
#

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)

devout mirage
#

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:

Learn how to use subscription schedules to automate changes to subscriptions over time.

Learn how to use subscription schedules.

keen helm
#

ok, thank you