#drewdan_usage-tiers

1 messages · Page 1 of 1 (latest)

viral shoreBOT
#

👋 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/1280919575961141278

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

winged robin
#

Do you have an Invoice ID I can look at?

craggy plover
#

these are my tiers

#

and this is the invoice it generated:

#

any tips you could give would be amazing 🙂

craggy plover
#

it's in test mode

winged robin
#

Can you list the steps you took to get here and why you're expecting the amount to be exactly 50?

craggy plover
#

The idea with this is, we have "interactions" in our system. A user gets a certain amount as part of their subscription, and then anything above this limit is charged per interactions.

So I have a product and a price for the core subscription, which is a flat rate either monthly or annually.

Then I have a product called Interactions which is tiered, with the first 100 interactions being charged £0.00 and then anything over 101 or more at £0.50

I have a meter setup, which is assigned to this price and then I report the usage via the API in my application.

The limit for this plan is 100 interactions, so I thought, it would only start charging £0.50 after interaction 101

#

and as there are 101 interactions, the first 100 are free, so should total £0.00, and then the one additional one should be £0.50

#

if that makes any sense

#

the invoice is certainly £0.00 when the Qty is 100

craggy plover
#

does that provide you enough context?

winged robin
#

I think so. Apologies for the wait here. Meters are a relatively new product and the server is rather busy. I'm digging in now

#

Okay, so I think I see what's happening. You setup a tier that bills after usage exceeds 100. You reported usage for 101 units, which means they are getting billed for (100 x 0.50) + 0.50

Once that usage amount is reached, the customer is billed for all the usage up to that point, plus the one unit of usage that was reported over 100 (e.g. the 101st unit that was reported)

#

Does all that make sense so far?

viral shoreBOT
worldly gale
#

drewdan_usage-tiers

craggy plover
#

Can you see my price if I share the ID: price_1PvKbeJbBfypbb7Z12aUHpe5

#

seems I cannot share the code in here I am using to create the product, and price, but hopefully you will be able to see the data from this.

I am currently using graduated pricing

#
$stripe->prices
                ->create(
                    [
                        'product' => $interactionProduct->id,
                        'billing_scheme' => 'tiered',
                        'currency' => 'gbp',
                        'recurring' => [
                            'usage_type' => 'metered',
                            'interval' => 'month',
                            'meter' => $interactionMeter->id,
                        ],
                        'tiers_mode' => 'volume',
                        'tiers' => [
                            [
                                'unit_amount' => 0,
                                'up_to' => 100,
                            ],
                            [
                                'up_to' => 'inf',
                                'unit_amount' => 40,
                            ],
                        ],
                        // might have to make some changes to make the webhook use the product metadata, not the price
                        'metadata' => [
                            'internal_name' => 'month' . '-' . strtolower($key) . '-overage-2024-05-23',
                        ],
                    ],
                );
#

ah here we go

#

so the product has a name of Interactions, and this is the only associated price

worldly gale
#

what does "a name of interactions" mean? Can you share an exact Price id

craggy plover
#

price_1PvKbeJbBfypbb7Z12aUHpe5

#

prod_QmuQld48xGA2AS

#

is that what you need?

worldly gale
#

yeah you use tiers_mode: 'volume' for that Price and not tiers_mode: 'graduated' like I recommended

craggy plover
#

ah! I'm blind

#

let me give that a go now, but that looks to be my issue

#

Thank you both very much, that is exactly what was wrong and now it is working exactly as it should!

#

Apologies for missing that quite obvious error!