#meek-subscription-credit

1 messages · Page 1 of 1 (latest)

nocturne sparrowBOT
torpid mantle
#

A couple of ways to do that

#

Recommend reading that article too in case any other parts are of use. It does a solid job of outlining how to combine webhooks with subscriptions

vital karma
#

Does this run only on successful payments?

torpid mantle
#

It will help you identify when a subscription is upgraded or downgraded

#

So you can mark in your database that the sub was upgraded/downgraded at that moment

#

What's your end goal though? What are you trying to do?

vital karma
#

I want to update users credits in the database.

EX. They have a plan that is $20 for 50 credits per month

So once they sign up for a paid plan, they get ex. 50 credits
Each month, they also get 50 credits
They can upgrade or downgrade plan to get more or less credits and they should only receive the new credits if its an upgrade

#

I am having a hard time understanding which webhooks to listen to for all these different stages

torpid mantle
#

Ok that makes sense. One sec

vital karma
#

Thanks!

torpid mantle
#

There's several ways to do this. One way is to just listen to invoice.paid and inspect the price (price_123) used.

#

You'd also be keeping track of the customer's pricing tier in your database

#

So if you detect that the price they're paying now is different, update the pricing tier in your database

vital karma
#

Hmm interesting, looking at the previous attributes now. Brb

nocturne sparrowBOT
vital karma
#

So do you think this is a good way to go about this?

  1. Give 50 credits once they sign up for a 50 credits monthly paid plan -> add credits on customer.subscription.created webhook
  2. Each month, give 50 credits -> add credits on invoice.paid webhook
  3. Add credits on upgrade -> add credits on customer.subscription.updated webhook but only when the credits on previous_attributes is less
#

The issue i see with my solution is that invoice.paid on step 2 will get called for step 1 and 3

torpid mantle
#

Ok that gives a bit more detail into how things work thanks

#

When you upgrade the subscriptions, how do you handle prorations?

#

(trying to get a little more info so I can provide the best rec)

vital karma
#

So if the user upgrades, ex. if the new plan is $40 for 100 credits a month, then it will just add 100 to the current balance of credits and then continue charging them $40 a month

torpid mantle
opal pumice
#

meek-subscription-credit

vital karma
#

Currently I have nothing so i guess it is using the default create_prorations not too sure if thats the best option but that's what currently there

opal pumice
#

that's the default yes.

#

I think what's important is to be explicit about what you want your customer to pay when.

vital karma
vital karma
#

I just want to give them the appropriate credits

opal pumice
#

Sorry that's not really what I'm asking. I'm asking you to write down clearly when you expect the customer to pay what/how much
Like April 1st pays $10 for 50 credit, May 1st pays $10 for 50 credit, May 15 switches to $40 plan for 100 credits <insert what you expect>

vital karma
#

Ahhh I see....

April 1st pays $10 for 50 credit, May 1st pays $10 for 50 credit, May 15 switches to $40 plan for 100 credits -> Client gets charged $40 and they get 100 credits added to their account. June 15 pays $40 for 100 credits...

ect...

opal pumice
#

ohhhh you change the billing cycle on May 15, that's important!!! What about the $10 they paid for a month but mid month you chnaged the rule? Is it fine because they got the credits anyways?

vital karma
#

Yes exactly

opal pumice
#

okay so really what you need to do is update the Subscription to switch to the $40 price and pass billing_cycle_anchor: 'now' so that the new cycle is May 15 - June 15 and pass proration_behavior: 'none' because you don't want any credit for the previous $10
and then in the webhook you notice it's a new Invoice and you add 100 credit to your tracking

vital karma
#

Hmmm, few questions, I am using stripe checkout so will this work with that?

#

And Also could you do something like i did here #1083862390019473531 message outlining the steps so I can better understand what you mentioned above? Thank you and sorry for taking up so much time

opal pumice
#

Checkout is not relevant, you're talking about updating an existing Subscription which Checkout can never do