#mangle8582

1 messages · Page 1 of 1 (latest)

charred escarpBOT
#

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.

proud condor
#

Not sure I understand. What does cancel at period end have to do with upgrading price?

frank oracle
#

So i want to set a flag that the subscription was upgraded from Monthly to Yearly. To avoid refund directly from the app and do them from dashboard.

If i buy Monthly and then Upgrade imediately to Yearly it works.

But if i buy Monthly i update subscription with cancel on period end(User cancels subscription if he wants, then he renews it again) -> On webhook previous_attributes are no longer with monthly plan and i cannot set the flag

#

Maybe i can move it to invoice.paid?

proud condor
#

Are you doing the upgrade and the update to cancel at period end in different requests? That would make sense then. In that case, you'd get multiple customer.subscription.updated webhook events. One of them would contain the previous values (the event corresponding to the price upgrade)

frank oracle
#

Yea, i just want to set the flag and check on invoice.paid or customer.subscription.updated (On Upgrading the subscription), that the last subscription from which we upgraded from was monthly and not yearly so i can set the flag in my database

#

Because in this case, if user triggers customer.subscription.updated multiple times, i loose previous values of that customer.subscription from event and when i do the check is not good

proud condor
#

But your webhook endpoint should be processing all the events, no?

#

So you should be able to get the one where you do have previous values

#

Not sure I understand the problem

frank oracle
#

Yea, i was thinking about invoice.paid

proud condor
#

You'll be notified when there's an upgrade

frank oracle
#

User clicks on Upgrade button and presses Yes and then the upgrade happens, after that the webhooks are triggering.

Then i need to set my flag in my database for that subscription that is was upgraded from Monthly to Yearly

proud condor
#

yeah

#

I still don't understand the issue

#

You'll get a customer.subscription.updated event with previous attributes

frank oracle
#

Yea, if i update imediately. But if user cancels subscription and renews, the previous_attributes will be different, and i need plan.interval from previous event to check if it was an upgrade, otherwise how can i check if it was an upgrade?

proud condor
#

Even in that case you'd still get a customer.subscription.updated event with previous_attributes

#

It just won't be the same event where the user cancelled or the same event where user renewed

frank oracle
#

i will get the previous_attributes with cancel_on_period end only

#

evt_1OmeN0DmVlmqORBIZQftlkpz

#

check this event

proud condor
#

Yeah because that request wasn't an upgrade

#

It was to renew subscription

#

You'll get it in the event corresponding to the price upgrade

frank oracle
#

Then it's not good, because when it's renewed, it's not Monthly to Yearly anymore and i need the plan.interval to set the flag to false

proud condor
#

Have you considered storing data in metadata to keep track of these changes then?

frank oracle
#

On my Upgrade API endpoint when i update subscription to set the flag, then set metadata and check on renew metadata with the plan interval aftewards?

#
  1. Set metadata on upgrade
  2. But i need to check what plan interval was on webhook to see if it was monthly and set the flag
#

it would've been nice a property :))
upgraded: true
and then on renewal of yearly to have
upgraded: false

proud condor
#

I mean you shouldn't need to use metadata

#

I've told you several times that you'll get several subscription.updated events

#

One of them will have previous attributes with old plan

#

But yeah you can always use metadata to store whatever you want

frank oracle
#

Do you know which ones? Because i cannot see it at all anywhere

#

customer.subscription.updated won't have it at all

#

on renewal if i upgraded before

proud condor
#

I guess I don't understand why you need this data on renewal. Wouldn't you have already processed the upgrade event from before and flagged this in your db?

frank oracle
#

Yea.

  1. User hits upgrade -> updatedToYearly flag in my db is true
  2. 1 year passes with test clocks, i need to make it false, it's not upgraded anymore, i check plan.interval in previous_attributes, it's not there, i cannot set the flag to false
#

I'm doing prorated refunds on Monthly and Yearly and Upgrading the Subscription breaks my refunding process, because nextInvoice and invoiceUpcoming doens't have the old latest invoice prorated upgrade, it's the whole price, and i cannot refund the user the whole price.

So i'm left with a flag to redirect the user to customer support and refund him both of his payments Monthly and Yearly directly from Dashboard.

#

So for the first year when user upgrades he cannot refund directly from platform, because i cannot do this with Stripe.

#

So i'm left with setting a flag and talking to users to refund them manually, atleast for the first year after upgrading of the subscription

proud condor
#

Why not just reset the flag in your database yourself at end of the year?

#

But yeah you can use metadata for this too

frank oracle
#

end of the subscription end time right? Where can i catch this?

proud condor
#

I don't know your usecase

#

Do you want it reset at end of calendar year?

#

You should be able to look at the api spec yourself and get this data

frank oracle
#

current period end

proud condor
#

yep there you go then

frank oracle
#

I was thinking on doing this inside an webhook, otherwise i need to set up a cron

proud condor
#

You should get a webhook event when current period_end changes, right

#

customer.subscription.updated

frank oracle
#

But customer.subscription.updated is triggered on Upgrade as well, not only on Yearly Renewal

proud condor
#

That's correct

#

What's the problem with that?

frank oracle
#

When Upgrading i need to set the flag to true and i need to bypass it in the first custumer.subscription.updated to not reset the flag to false

#

And then on renewal to reset

proud condor
#

Yeah just build your logic on what's inside prevous attributes

frank oracle
#

Ok i will try, it would be nice to have a flag like this in the future, directly on the subscription.

upgraded: true

upgraded: false on renew

#

Thank you