#mangle8582
1 messages · Page 1 of 1 (latest)
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.
- mangle8582, 1 hour ago, 25 messages
- mangle8582, 3 hours ago, 58 messages
- mangle8582, 6 days ago, 37 messages
- mangle8582, 6 days ago, 38 messages
Not sure I understand. What does cancel at period end have to do with upgrading price?
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?
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)
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
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
Yea, i was thinking about invoice.paid
You'll be notified when there's an upgrade
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
yeah
I still don't understand the issue
You'll get a customer.subscription.updated event with previous attributes
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?
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
i will get the previous_attributes with cancel_on_period end only
evt_1OmeN0DmVlmqORBIZQftlkpz
check this event
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
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
Have you considered storing data in metadata to keep track of these changes then?
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?
- Set metadata on upgrade
- 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
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
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
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?
Yea.
- User hits upgrade -> updatedToYearly flag in my db is true
- 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
Why not just reset the flag in your database yourself at end of the year?
But yeah you can use metadata for this too
end of the subscription end time right? Where can i catch this?
I don't know your usecase
Do you want it reset at end of calendar year?
Or current period end? https://docs.stripe.com/api/subscriptions/object#subscription_object-current_period_end
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You should be able to look at the api spec yourself and get this data
current period end
yep there you go then
I was thinking on doing this inside an webhook, otherwise i need to set up a cron
You should get a webhook event when current period_end changes, right
customer.subscription.updated
But customer.subscription.updated is triggered on Upgrade as well, not only on Yearly Renewal
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
Yeah just build your logic on what's inside prevous attributes