#dai_best-practices
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/1280973623057715290
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- dai_best-practices, 5 hours ago, 12 messages
Going to provide sample code for reference
hi!
Our team is looking for guidance on API usage for an update on our existing Stripe integration.
Our existing Stripe integration consists of a subscriptions that provide access to a given product tier (e.g. basic and pro tiers).
We're looking to provide existing customers subscribed to the basic tier a trial period of the pro tier.
We existing billing requirements as part of this:
- We want to avoid modifying the existing billing cycle
- We want to allow full usage of their trial period regardless if they intend to upgrade
- Do not credit back for unused time
- Prorate for used time
dropping the sample code i've been testing with in test mode trying to achieve this
let subscription = await stripeApi.createSubscription({
customer: customer.id,
default_payment_method: paymentMethod.id,
items: [
{
price: monthly_basic_price,
quantity: 1,
},
],
trial_settings: {
end_behavior: {
missing_payment_method: 'cancel',
},
},
});
let subscriptionSchedule = await stripeApi.createSubscriptionSchedule({
from_subscription: subscription.id,
});
subscriptionSchedule = await stripeApi.updateSubscriptionSchedule(
subscriptionSchedule.id,
{
end_behavior: 'release',
phases: [
{
start_date: unix,
proration_behavior: 'none',
trial_end: trialEndUnix,
end_date: trialEndUnix,
items: [
{
price: monthly_pro_price,
quantity: 1,
},
],
},
{
billing_cycle_anchor: 'automatic',
proration_behavior: 'create_prorations',
items: [
{
price: monthly_basic_price,
quantity: 1,
},
],
},
],
}
);
i can also provide a brief diagram/illustration that helps to better describe what we're wanting to achieve
Yeah I think the only way you can accomplish this without resetting the billing cycle anchor would be to use a one-time coupon to comp for any amount that would be charged as opposed to a trial period
A trial period will always reset the billing cycle anchor
Interesting, I think I am following - how would you suggest aligning a coupon + scheduling the automatic update back to the basic plan if there is no intent to upgrade?
Still using a subscription schedule and add/removing the coupon per phase?
Yeah I think that is the only way
This is going to be pretty complicated
But can't really think of a different way to achieve this
Could I clarify with you whats causing the highest point of complexity? Is it maintaining the billing cycle?
I can perhaps speak w/ my teams about complexity that could shift HMW define requirements. The overall goal here though is provision a free period of upgraded access for customer on-demand without impacting their current billing scenario
Yes. By far the easiest thing to do here is to just use a trial period
But yeah, that would affect the billing period or billing cycle anchor in one way or another
Yeah I understand, thank you for the clarification regarding how trials reset billing cycle anchors, I wasn't fully aware of this
sounds like I can explore via this coupon strategy and otherwise present this otherwise blocker
That would be my recommendation