#mangle8582

1 messages ยท Page 1 of 1 (latest)

dreamy chasmBOT
#

Hello! We'll be with you shortly. 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.

opaque gull
#

Hello

sleek shuttle
#

Hello

opaque gull
#

Really the best thing to do is to charge via a one-time item and set a trial

#

Why don't you want to do that method?

sleek shuttle
#

I was thinking that was better if user pays imediately and adds one year on top of monthly that he already paid.

Because otherwise when trial ends, i need to show him a message that he will be charged for yearly at a particular date, i need to show him that it's trial and he didn't paid yet, he will be confused

opaque gull
#

You can still have them pay immediately and then set the trial for 13 months

sleek shuttle
#

With billing_cycle_anchor: 'now', ?

#

But then if they want a refund for Yearly, he will get the money back?

#

If it's a trial?

opaque gull
#

You use the trial to set the billing cycle anchor

#

It will be moved to whenver the trial ends

sleek shuttle
#

billing_cycle_anchor can be 'now' or 'unset' right?

opaque gull
#

unchanged

#

Yes

#

But mostly you just omit it or you use now

sleek shuttle
#

billing_cycle_anchor: 'now',
proration_behavior: 'none',
trial_end: nextBillingCycleEnd

I cannot use billing_cycle_now if trial end is afterwards

#

Trial end (1734034930) cannot be after billing_cycle_anchor (1699907156)

opaque gull
#

Correct, you omit billing_cycle_anchor in that case

#

Any time you set a trial it will automatically set the billing cycle anchor to the end of the trial

sleek shuttle
#

Yea, it worked, the endDate looks nice, the thing is that i don't see that the user paid in stripe dashboard in test mode

opaque gull
#

Correct, because you didn't add an Invoice Item or a one-time Price to charge them

sleek shuttle
#

Can you give me link for that or paste some code please?

opaque gull
#

Those are the two options

sleek shuttle
#

items: [
{
price
}
]

I'm sending the priceId of yearly into the Subscription Update

#

Creating an invoice item will automatically charge the user?

opaque gull
#

Correct, you can send 2 items

#

Yes if you create an Invoice Item then it will be picked up by the next finalized Invoice

sleek shuttle
opaque gull
#

Yep two different objects within your array. One for each Price (one for the yearly Price and one for the one-time Price)

sleek shuttle
#

After i create the price, it can be used only once right?

#

It won't hang somewhere in Stripe dashboard

opaque gull
#

Nope, Prices can be used unlimited times

#

Unless they are archived

#

A one-time Price means it will only charge the Customer once

#

Unlike a recurring Price which you use for a Subscription

sleek shuttle
#

Oh, i get it and i need to create it each time an user upgrades right? Or create it in dashboard somewhere and use it?

opaque gull
#

You just have to create it once.

#

Then you pass that Price ID in your Subscription update request

sleek shuttle
#

Oh okay

#

Thank you, i will try it.

opaque gull
#

๐Ÿ‘

sleek shuttle
#

The price specified is set to type=one_time but this field only accepts prices with type=recurring

coarse coyote
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needed to step away. Please bear with me a moment while I catch up on the context here.

sleek shuttle
#

Sure, thanks!

coarse coyote
#

Thank you for your patience, but I think that new error may be different form the rest of the discussion (though related). Can you share the code you're running that encountered that error, or share the ID of the request (req_) that surfaced that error?

sleek shuttle
#

items: [
{
price of the annual recurring subscription
},
{
price: 'price_1OC76PDmVlmqORBIachFKg1A'
}
]

const stripePayload = {
    payment_behavior: 'pending_if_incomplete',
    expand: ['latest_invoice.payment_intent'],
    ...subscriptionData,
    proration_behavior: 'none',
    trial_end: nextBillingCycleEnd
  };
coarse coyote
#

Is that to create a Subscription? (I don't see the Stripe function you're calling in that snippet)

sleek shuttle
#

sub_1OC77RDmVlmqORBIxPdiwHQ4

#

const updatedSubscription = await stripe.subscriptions.update(
subscriptionId, stripePayload
);

#

evt_1OC76PDmVlmqORBIULmvxZ8m

I see this event in Webhooks on Test mode local

coarse coyote
sleek shuttle
#

And keep
items: [
{
price of the annual recurring subscription
},
]

the reccuring one here?

coarse coyote
#

If that price is also being changed, then yes.

sleek shuttle
#

What do you mean being changed?

It's the price of the recurring subscription i want to upgrade to.
The add_invoice_items is the one time only to force a imediate payment while i add one year after the end time of the monthly subscription

#

Also:
const nextBillingCycleEnd = currentSubscription.current_period_end + 365 * 24 * 60 * 60;

Start Date:11/13/2023 11:11 PM
Reactivation Date:12/12/2024 10:52 PM

Now i need to calculate it manually, and i know that invoice is beeing created at the current_period_end and after 1 hour the client starts to be charged for that invoice.

To be on par with stripe logic, what calculations should i do to match it?

#

I will test with test_clock and add 1 year with moment.js after current_period_end

coarse coyote
#

You said you were updating Subscriptions, but I'm still a bit unclear exactly what you're updating about them, so I wasn't sure if you were also trying to change the Price that the Subscription Item is currently using. If you aren't changing that value, then it doesn't need to be in the update request.

You can't just add 365 days to the timestamp, sometimes years have more days than that and we take that into account.

sleek shuttle
#

True, with moment.js seems to work adding one year i think

#

So I'm trying to update Monthly to Yearly but keep the Monthly time and add 1 year to the 1 month already paid while paying imediately

#

So i have annual recurring price and i've created one time yearly price with 59.99$ the same as recurring

#

When i'm updating subscription to yearly i'm calculating with moment.js to add 1 year after monthly current period end. And by adding add_invoice_items, it pays imediately, it adds trial for 1 year and remaining monthly time and all good

#

Is this okay and reliable?

coarse coyote
#

Yeah, I'm not spotting anything that is a concern with that approach. I would just recommend double checking with Test Clocks that it's behaving exactly as you wish (I recommend that for all Subscription integrations, as they can be complex and seeing the flow can be hugely beneficial).

sleek shuttle
#

Sure

Start Date:11/13/2023 11:26 PM
Reactivation Date:12/13/2024 11:16 PM

#

With moment js with add 1 year

#

it's 10 minutes behind

coarse coyote
#

Not sure if you had a question you were trying to ask there, but there also appears to be a difference in the Month used there.

sleek shuttle
#

Yea, i will try to see if i can manage to do it manually so it will not trigger webhooks before the endtime or something

#

Is there a way to add this without me setting trial_end unix so i can avoid calculations?

#

Because i could make a mistake, or miss a case

coarse coyote
#

Not easily, the only other approach that comes to mind is to leverage Subscription Schedules (another type of object that can be used to schedule changs that should be made to a Subscription), but those won't handle the immediate payment requirement well.

sleek shuttle
#

Got it, so this is the best solution for me right now