#WpgJetsFan13-sub-trial

1 messages ยท Page 1 of 1 (latest)

whole parcel
#

hello, give me a min

grizzled beacon
#

๐Ÿ‘‹

#

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.

still bridge
#

I'm here, just was away for a bit. Let me catch up

grizzled beacon
#

Sure thing

still bridge
#

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

grizzled beacon
#

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

still bridge
#

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'
});
grizzled beacon
#

Ah yeah not quite

#

You need a Subscription Schedule

#

Not a Subscription

#

The Subscription Schedule will create the Subscription

still bridge
#

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
    });
grizzled beacon
#

Yeah you don't create the Sub first

#

Because otherwise you hit the error of having different intervals together

still bridge
#

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

grizzled beacon
#

Oh okay

#

That's fine

#

Then just create the Sub with the $0 price

#

Wait

still bridge
#

I'm a bit confused if I should create it with both price plans under items

grizzled beacon
#

Sorry let's back up

still bridge
#

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.

grizzled beacon
#

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

still bridge
#

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

grizzled beacon
#

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.

still bridge
#

Yeah, sorry about that. I'm just doing it that way because I didn't feel like setting up webhooks

grizzled beacon
#

No reason you need webhooks to test here

still bridge
#

just to know when the session is complete

#

or when the subscription is created

grizzled beacon
#

You would go and complete it though yourself ๐Ÿ™‚

still bridge
#

yeah true

grizzled beacon
#

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

still bridge
#

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

grizzled beacon
#

You want both a free trial and a $0 price?

#

I'm confused ๐Ÿ˜…

still bridge
#

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!