#pierre_best-practices

1 messages ยท Page 1 of 1 (latest)

warped pythonBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

sleek dome
#

Here's a screenshot of the current checkout session, for reference.

#

And here's how I am setting up the checkout session


        params.line_items = Some(vec![
            CreateCheckoutSessionLineItems {
                price: Some(env::var("STRIPE_FLAT_PRICE_ID").unwrap()),
                quantity: Some(1),
                ..Default::default()
            },
            CreateCheckoutSessionLineItems {
                price: Some(env::var("STRIPE_METER_PRICE_ID").unwrap()),
                ..Default::default()
            },
        ]);
warped pythonBOT
granite obsidian
#

Hi, can you confirm exactly what your customers would like to see instead?

sleek dome
earnest mica
#

Hi there ๐Ÿ‘‹ jumping in as my teammate needs to step away soon. Please bear with me a moment while I get caught up here.

sleek dome
#

Hmmm, I think the simulator got fixed in the stripe dashboard, because it seems that even with 0, the customer is billed 49euros now

#

When I tried few weeks back, 0 would put the amount at 0 euros

#

Ah no, still not with "graduated"

earnest mica
#

Taking a step back, is volume or graduated better for your use case here?

#

I want to be sure we're aligned in what we're looking into.

sleek dome
#

Here's the final goal:

  • To have a base price of 49euros, that includes the first 100k request, even if no request is performed.
  • Then, after the first 100k requests, there is tiers that makes the cost per unit decrease
earnest mica
#

Then, after the first 100k requests, there is tiers that makes the cost per unit decrease
Will the price of the first 100k requests be impacted by the price decrease, or only requests beyond the initial 100k?

sleek dome
#

Because we sell other things than API services, but want to have a single subscription / product

#

And, looking at the two screenshots above, it's not clear why "tiered" would start at 0euros if no metered usage even though the first unit is 0

earnest mica
#

Which is why I'm curious what you see when you actually create the Subscription, my team doesn't spend too much time in the dashboard, so I'm not familiar with or confident in what it shows.

sleek dome
#

Ah

earnest mica
#

I am going to try to stand up a test of mine own, but this flow is a bit complex and may take me a bit to piece together between other threads.

sleek dome
earnest mica
sleek dome
#

Ah, bummer. Thanks!

earnest mica
#

Before I get too far into building this test. Are you planning on using Usage Records (legacy approach), or Meters and Meter Events (new approach) for reporting usage to us?

sleek dome
#

Don't bother, I created a new price

#

I am trying it out now

#

And here is the tiers table

#

What I'd need is "For the first 0 to 100,000"

earnest mica
#

I just created a Price using tiers in this fashion:

  recurring: {
    interval: 'month',
    usage_type: 'metered',
  },
  product_data: {
    name: 'Tiered Price testing'
  },
  billing_scheme: 'tiered',
  tiers_mode: 'graduated',
  tiers: [{
    up_to: 100000,
    flat_amount: 4900,
  },{
    up_to: 'inf',
    unit_amount: 1,
  }]```

And when the usage is 0 the $49 flat fee is shown on the upcoming Invoice.
#

You're saying that's not what you see when you create the Subscription for that Price but haven't reported usage yet?

earnest mica
#

Can you share the ID of the Subscription from your test?

sleek dome
earnest mica
#

I always recommend testing in testmode rather than in livemode. Based on what I'm seeing in my testing, the first tier is used even if the usage is 0 when a Subscription is actually created. I think the dashboard just shows a misleading value when it shows that the first tier starts at 1. But I want to ensure you're seeing the same behavior when you're actually creating a Subscription.

I'm adapting my test to use a meter now to ensure that doesn't make a difference in the behavior I'm seeing.

sleek dome
earnest mica
#

What is that a screenshot of?

#

Oh, that's the Checkout Session?

sleek dome
#

Yes!

earnest mica
#

That's expected. Since everything is under a metered Price, and those bill in arrears (at the end of the billing period), the customer doesn't pay the flat fee until the end of the month. So the amount due on the first Invoice is 0.

sleek dome
#

Ah, I see, that's definitely not what I want either

#

I guess I am stuck with two prices then

earnest mica
#

Oh, yeah, if you want them to pay the flat fee up front, you need two Price objects.

sleek dome
#

It'd help if I could attach a price to the names in the checkout sessions

#

It's very confusing atm

earnest mica
#

You could tack on a one-time price that only applies to the first invoice. I'm not sure if that would be more or less confusing for your users.

#

You can create them under different Product objects with different names.

sleek dome
sleek dome
#

Thanks, I will explore that. You were extremely helpful!

earnest mica
#

Happy to help!

sleek dome
#

That's certainly a lot better

#

Well, I didn't expect the fix to be that easy. I ignored that subscriptions could contain two products

#

Thanks again!

earnest mica
#

Any time!