#cosmin-marginean_best-practices
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1239860146486644757
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi
I was wondering if this is the right way to model this use case in Stripe?
Yes this seems reasonable for me.
We modeled this as 1 Stripe customer with many Stripe subscriptions. This gives us A) but not B), because the Meter API only allow reporting against a customer ID, not subscription ID.
In the payload you can add custom fields, like subscription_id
Ah, that's good to know. But FYI, that's not specified in the documentation
Thank you though, I'll give that a try!
Happy to help!
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
So I've used these payloads as per your colleague's suggestion
"payload": {
"value": "10",
"stripe_customer_id": "cus_Q6UNgOw0ZK5UvI",
"subscription_id": "sub_1PGHOJKLBbXjYhNstXWrzWqR"
}
"payload": {
"value": "5",
"stripe_customer_id": "cus_Q6UNgOw0ZK5UvI",
"subscription_id": "sub_1PGHOIKLBbXjYhNsu4JGBDrw"
},
Same customer ID, different subscription IDs
Each of the subscriptions now shows the same amount 15 (10+5) though.
And in the "View upcoming invoice" there is no separation between the two
So technically it captured 15, which is correct, but there is no separation between the two subscriptions in the invoice (or anywhere on the dashboard for that matter when it comes to billing)
I tried with stripe_subscription_id btw, instead of subscription_id but it's the same effect
you can't specify both customer_id and subscription_id
you need to specify either or
Ah, of course!
otherwise the customer will be used as default
Yep, that makes sense, of course
That doesn't work without customer id though ๐
Unable to determine the customer this event is for. To fix, pass the customer ID in the event payload with key "stripe_customer_id".; request-id: req_5ieYYkL6qquV1X
Tried both stripe_subscription_id and subscription_id
hmmm, sorry I mislead you on this one
the metered billing is still new, even to us, so please bear with me
No worries, thank you for looking into this
just fyi, do both subscriptions have the same price?
that's why you're seeing the same usage on both subscriptions
Yes, our use case is that the customer can (must) purchase multiple of these
I'm not sure that would work with the Metered API though
since the usage is recorded for a MeterID+CustomerID
Yep, it seems so
and the MeterID is linked to a PriceID
Yes, you're right
why not use the same subscription and increase the quantity of the price
It's not possible sadly, because the customer needs individual metering for each of their subscriptions. And invoice should reflect that. Imagine they manage two stores and we direct traffic to their stores from our platform - we want to tell them how much traffic we've directed for each of the stores as part of the invoice (aggregated of course, and in the form of cost/usage)
So I'm guessing the only option is to create separate customers (which isn't ideal), which in turn means sending multiple invoices
you can actually create new prices/meter IDs
so basically let's say you have a merchant A with Store X and Z
you create a customer for A and then create a price under your product specifically for Store X and a meter for that and another one for Store Y
this way you can have one subscription to generate one invoice with the 2 prices
and the usage won't be aggregated between the two Stores
Ah yes, I thought of that, but I wasn't sure if it's practical. The only question there is: can we have tens of thousands of prices and meters in Stripe? (rough scale of the number of customers)
yes there is no limit to that
Golden! I'll give that a go and come back if any issues. Thank you so much!
one thing that can be beneficial though is to create a separate product for each customer
just for visibility on the dashboard
so you wouldn't have all of the prices under one product
but then again you would need this extra step (create a new product each time)
Yes, I think that makes sense. It's far from ideal as it means those products can't be configured in a single place, but it's something that I think we can live with
what you can actually do is something like a product/price template on Stripe or in your code
and replicate that each time
Yes, that's what I was gonna look into, that's the easy part to be honest ๐
The hard part is when we'll decide to change the pricing structure and have to modify thousands of products. But then again, that can be automated
you can always use metadata to reference the original price ID for example
and then use that metadata to list all the prices with that orginal price ID
from there you can then list the subscriptions and update them
Yes, that's true. Plus that kind of change needs to me "managed" anyway so I don't imagine it can/should be a few clicks anyway. Thank you again, very helpful suggestions!
now that we're talking about it, I wish there was a simple way to duplicate a price ๐ค
I will suggest that internally and see where this might lead
Yeah, that would brilliant!
would you mind sharing your account ID so I can reference it?
having a valid use-case for a real merchant can boost this