#WpgJetsFan13-sub-trial
1 messages ยท Page 1 of 1 (latest)
๐
Yep you can add $0 prices
Hmm the Sub Schedule should work, no?
What error did you get for the Sub Schedule test?
@still bridge let me know if you are still around! The Sub Schedule route should work fine here.
I'm here, just was away for a bit. Let me catch up
Sure thing
Yeah, I created a $0 schedule on a daily interval, then with subscriptionschedule I added the two phases, but it said that I could not use two different interval types
let me see if I can reproduce the error. I've changed my code since I wrote this
I tested myself and it worked fine.
I created a Price with a custom 3 week interval
And a Price with a yearly interval
So yeah, recommend just double checking your code. If you hit an error again then feel free to toss me the request ID and I can take a look at what you are doing
I think maybe I'm confused about creating the subscription
I have:
const paidId = 'price_1LcFpZCT5ZiUAGNjGkfy7k0C';
const freeId = 'price_1LcaEYCT5ZiUAGNjZn5e9DAC';
let subscription = await client.subscriptions.create({
customer: customer.id,
items: [
{price: freeId, quantity: 1},
{price: paidId, quantity: 1}
],
billing_cycle_anchor: Math.floor(anchorDate.getTime()/1000),
proration_behavior: 'none'
});
Ah yeah not quite
You need a Subscription Schedule
Not a Subscription
The Subscription Schedule will create the Subscription
and then I create a schedule like:
schedule = await client.subscriptionSchedules.update(schedule.id, {
phases: [
{
items: [
{price: freeId, quantity: 1}
],
iterations: 21,
start_date: 'now'
},
{
items: [
{price: paidId, quantity: 1}
],
iterations: 12,
}
],
end_behavior: 'release'
});
I was creating the subscription first like:
let schedule = await client.subscriptionSchedules.create({
from_subscription: subscription.id
});
Yeah you don't create the Sub first
Because otherwise you hit the error of having different intervals together
Ok, so the thing is, I'm just using this demo method to test stuff, but in production we are using a checkout session
So I had another question answered yesterday, basically I listened for the customer.subscription.created webhook, then I add the schedule from_subscription
then I modify the schedule. Otherwise I could't attach a schedule to it
so that's why I have to use an existing subscription
I'm a bit confused if I should create it with both price plans under items
Sorry let's back up
It's a very odd edge case, but that's what my boss wants I guess. I would think it would be much easier to just have a free trial.
So you are starting a Sub via a Checkout Session
And it is a $0 Sub
And you are using the Checkout Session to collect the card details
well, I haven't tested this part with a checkout session. But yes, we are collecting card details, it creates a subscription. But the subscription has no schedule when you use checkout
it just repeats indefinitely
Right okay
So then you would add the Schedule after that
What was throwing me off is that you were creating a Sub
But you are just doing that for testing purposes?
Because you don't want to run through the Checkout Session
I'd recommend just testing with an actual Checkout Session, but that's fine.
Yeah, sorry about that. I'm just doing it that way because I didn't feel like setting up webhooks
No reason you need webhooks to test here
You would go and complete it though yourself ๐
yeah true
I mean... you'll need Webhooks eventually with either process
That said, sure, either way is fine. Let's focus on the Schedule
You create the Sub with just the $0 price
Then you add a schedule
Which will add the second phase which will include the annual price
oh, I see. I'm gonna give that a try
I think that should be ok. I was thinking if I start the free trial today, then it would end Sept. 20. Then I'd want to set the billing anchor to October 1 and prorate the rest of the month
But it wouldn't let me set a billing anchor so far in the future
Maybe I can just set it to Sept. 1 since it's charging $0 anyway
Well, I had to update the schedule and input the current phase that was created automatically when I attached it to the subscription. So the first phase was only 3 seconds long ๐ But it shows the 21 day phase followed by the 12 month phase, which is essentially what I wanted
well, what my boss wanted ๐
Thanks!