#cosmin-marginean_best-practices

1 messages ยท Page 1 of 1 (latest)

near roseBOT
#

๐Ÿ‘‹ 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.

chrome bladeBOT
worldly hill
#

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

kind plume
#

Ah, that's good to know. But FYI, that's not specified in the documentation

#

Thank you though, I'll give that a try!

worldly hill
#

Happy to help!

near roseBOT
lunar pilot
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

kind plume
#

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

lunar pilot
#

you can't specify both customer_id and subscription_id

#

you need to specify either or

kind plume
#

Ah, of course!

lunar pilot
#

otherwise the customer will be used as default

kind plume
#

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

lunar pilot
#

hmmm, sorry I mislead you on this one

#

the metered billing is still new, even to us, so please bear with me

kind plume
#

No worries, thank you for looking into this

lunar pilot
#

just fyi, do both subscriptions have the same price?

kind plume
#

Yes, that's correct

#

It's one single type of subscription/product

lunar pilot
#

that's why you're seeing the same usage on both subscriptions

kind plume
#

Yes, our use case is that the customer can (must) purchase multiple of these

lunar pilot
#

I'm not sure that would work with the Metered API though

#

since the usage is recorded for a MeterID+CustomerID

kind plume
#

Yep, it seems so

lunar pilot
#

and the MeterID is linked to a PriceID

kind plume
#

Yes, you're right

lunar pilot
#

why not use the same subscription and increase the quantity of the price

kind plume
#

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

lunar pilot
#

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

kind plume
#

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)

lunar pilot
#

yes there is no limit to that

kind plume
#

Golden! I'll give that a go and come back if any issues. Thank you so much!

lunar pilot
#

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)

kind plume
#

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

lunar pilot
#

what you can actually do is something like a product/price template on Stripe or in your code

#

and replicate that each time

kind plume
#

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

lunar pilot
#

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

kind plume
#

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!

lunar pilot
#

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

kind plume
#

Yeah, that would brilliant!

lunar pilot
#

would you mind sharing your account ID so I can reference it?

#

having a valid use-case for a real merchant can boost this

near roseBOT
kind plume
#

Yes, one sec

#

acct_1P7e08KLBbXjYhNs