#dbjpanda
1 messages · Page 1 of 1 (latest)
Hi there!
Do they pay upfront, and then get to use all the token within the month?
If they pay upfront, then I recommend using a Standard Pricing, and then keeping track of how many tokens they can use on your end.
And if you want a proration based on the number of tokens, then you should use proration_behavior: none, and compute the proration yourself.
Yes, they pay upfront.
Where should I set the proration_behaviour ?
I let user use a customerPortal link session to update their subscription.
Oh I didn't notice you were using the Customer Portal. Not sure how that works in this case... let me check.
With the Customer Portal, you can set the proration_behavior in your configuration: https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-features-subscription_update-proration_behavior
I am also using stripe hosted customer portal.
Yes, the link I shared above is for the customer portal
So you mean, while creating a portal session, I should pass the proration_behaviour:none parameter ?
However I want the user to prorate on the basis of the token.
My idea was to:
- Step 1: set your customer portal configuration to disable proration when upgrading/downgrading subscription
- Step 2: compute on your end the proration, and charge the customer accordingly
But trying to think if there's a better option...
Actually, I am using the Firebase Stripe extension. So I have very few customisation capabilities.
This extension provides only createCheckoutSession() and createPortalLink() function
You can pass a configuration hash to the createPortalLink function that maps to the link @bitter lark shared above: https://github.com/stripe/stripe-firebase-extensions/blob/next/firestore-stripe-payments/functions/src/index.ts#L341
That will allow you to control the proration behaviour of updates
@fiery orchid That's sound interesting. But how can I generate the configuration hash? Is there any exposed function for that provided by the extension?
There is not, you'd need to create that separately
Well, and what should I pass in the proration_behaviour? Is it the price after I calculate on the basis on left token and the number of token the user wants to upgrade or downgrade?
let's say the pricing :
5USD / Month - 2000 Token
19 USD/ Month - 50000 Token
A user purchased 5 USD/Month -2000 Token
After few days, he/she wants to upgrade his/her subscription to 19 USD/ Month - 50000 Token
His/her Token left is 1000 token from the first subscription.
What kind of billing are you using? Or how are you modelling these tokens in Stripe?
I am using Standard Billing. User chooses a subscriptions and pays upfront fee.
I add "token" as meta data to Price inside Stripe
Then there's no way to prorate that token usage automatically, you'd need to handle that yourself
The proration applies to the previous payment made before the upgrade: https://stripe.com/docs/billing/subscriptions/prorations
Well, then what would you suggest to achieve this? Is it even achievable using that extension?
Or may be Package Pricing?
You likely want usage based billing: https://stripe.com/docs/billing/subscriptions/usage-based
At the end of the cycle, you report the usage to Stripe.
And how do I report it using the Firebase-Stripe Extension?
No, there's no support for that in that extension. You'd do it directly in the API
@fiery orchid Thank you for your clarification and patience. I have one last question.
If I go for usage based billing, while a user upgrades or downgrades, how do you send the usage report and create a portal link at a single http query. Or is it required to send the usage report first in a separate query and then create a portal link call in a second http query?
I guess you'd likely want to make then in the same HTTP call so that if the usage record fails, then it throws and prevent the portal session
It's really an implementation details, up to you
It seems I also need to build the portal, because Stripe hosted customer portal does not permit usage based billing.
Ah, yeah 😦
Is there any api that will cancel an existing subscription(provided a subscription id) and create a new subscription with new price id in one go instead of cancelling and then creating a new checkout session.
Hi 👋 jumping in as my teammate needs to step away soon. No, there is not an endpoint that will both cancel an existing Subscription and create a new one. That will require two separate requests, one to cancel the current Subscription, and another to create the new Subscription.