#kakos_billing-meters-prices

1 messages ยท Page 1 of 1 (latest)

fading joltBOT
#

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

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

lapis cypress
#
  @CatchErrors
  public async createUsagePriceForSubscription(
    venueId: string,
    productId: string,
    price: number,
    currency: string
  ): Promise<MeterPriceCreation> {
    const meterUsage = await this.createMeterEvent(venueId);
    const usagePrice = await this.createUsagePrice(productId, price, currency);

    return new MeterPriceCreation(usagePrice.id, meterUsage.event_name);
  }

  @CatchErrors
  private async createMeterEvent(venueId: string): Promise<Stripe.Billing.Meter> {
    const meterEvent = await this.stripeAPI.billing.meters.create({
      display_name: `Meter of venue ${venueId}`,
      event_name: venueId,
      default_aggregation: {
        formula: "sum",
      },
      value_settings: {
        event_payload_key: "overFlowReservations",
      },
      customer_mapping: {
        type: "by_id",
        event_payload_key: "stripe_customer_id",
      },
    });
    return meterEvent;
  }
  @CatchErrors
  private async createUsagePrice(productId: string, unitAmount: number, currency: string): Promise<Stripe.Price> {
    const usagePrice = await this.stripeAPI.prices.create({
      product: productId,
      unit_amount: unitAmount,
      currency: currency,
      billing_scheme: "per_unit",
      tax_behavior: "inclusive",
      recurring: {
        interval: "month",
        interval_count: 1,
        usage_type: "metered",
      },
    });
    return usagePrice;
  }


#

I have included the related code

#

In the dashboard I see that the price is ticked as

hallow hollow
lapis cypress
#

oh I am so sorry I have missed it I am sorry!

#

thank you so much and again I am really sorry

hallow hollow
#

No worries! We have a lot of docs ๐Ÿ˜…

lapis cypress
#

hahah yea I got lost because I was reading the old usage and I was like damn it, I used a legacy billing

#

and I am trying to switch my billings so I was a bit confused but all good

#

thank you so much again!

hallow hollow
#

Sure thing. Have a good day ๐Ÿ™‚

lapis cypress
#

u2! Can I ask 1 last thing

#

if you happen to know please?

#

I notice a limitation on this new API billing I was wondering if you happen to know if it will be futher dev into it,
The limitation of same customer having multiple subscriptions with the same price on them

hallow hollow
#

Sure, what's up?

lapis cypress
#

or that is not a thing that will happen

hallow hollow
#

What do you mean by "if it will be futher dev into it,"?

#

It is a known pain point with Billing Meters and I know we are looking into how we can address it.

lapis cypress
#

to allow to track sub items instead of customer Id

hallow hollow
#

But I cannot provide any specific guidance about how we will update the API to better track usage per item.

lapis cypress
#

yea ofc, I understand thank you so much for the info!

#

I guess a workaround is to create unique prices for each new subscription

#

to be able to track each

#

with the current production API that is live

#

new price => new meter Object

#

with unique event_name to report on the same type of subscription that the same customer can have

#

Subscription tier 2 bought by customer id "abc" 2 times for 2 of their B2Bs

#

example

hallow hollow
#

yeah that would be the recommended approach. New Price and Meter objects for each Customer

lapis cypress
#

I see thank you again for your time! have an amazing rest of your day!

hallow hollow
#

You too ๐Ÿ‘‹

fading joltBOT