#simon-_api

1 messages ยท Page 1 of 1 (latest)

potent gobletBOT
#

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

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

gleaming gulch
#

I'm not sure I understand the question. What do you mean by "attach a Product to an Event"? Stripe has Product objects and Event objects. The Events are generated by actions that occur on the account and you can't update them, so I'm not sure what you're actually hoping to achieve

river burrow
#

Sorry I meant attaching a Product to a Meter.

wise hawkBOT
river burrow
#

Or is a Meter a Product?

gleaming gulch
#

Why do you need the Product to be attached to the Meter object?

river burrow
#

It is unclear how you charge at the end of the month for usage of a Meter along with a Subscription. If you could step me through that process then I can have some more informed questions. Is it a Callback at the end of the month to a webhook that would list all Meter Events the User has had and update the subscription Invoice before it is sent out?

past tartan
#

๐Ÿ‘‹ stepping in here as two-shoes needed to step away

river burrow
#

Hi bismarck

past tartan
#

Bascially you report usage to your Meter throughout the billing period, then the Invoice that is generated at the end of the period will have a quantity based on the reported usage.

#

So all you really do is create the Subscription and use the Metered Price and then report usage via Meter Events during the period and then the rest happens automatically.

river burrow
#

Ah okay, so to link the Price to the Meter you would do it via the Subscription at creation. To do this it would be the Price id you pass into the subscription items array:

  customer: '{{CUSTOMER_ID}}',
  items: [
    {
      price: '{{PRICE_ID}}',
    },
  ],
  expand: ['pending_setup_intent'],
});
past tartan
#

Yep

river burrow
#

I guess I just got confused as I am not creating Products or Prices currently and instead relying on passing product and price data at Checkout together with a striper customer id. and listening for the checkout.session.completed event on my backend and then retrieving products purchased with stripe.checkout.Session.retrieve. Is this just creating new duplicate Products and Prices at every Checkout? I.e. not the way to do it for reporting purposes on the Dashboard?
For reference here is my product_list that is used for both Subscription and Guest accounts:

const products_list = {
  subscriptions: [
    {
      name: 'Professional',
      description: 'Professional',
      id: 'sku_professional01',
      price: 999,
      currency: 'USD',
      product_data: {
        metadata: {
          type: 'plan',
          provider: 'professional'
        }
      },
      price_data: {
        recurring: {
          interval: 'month'
        }
      }
    }
  ],
  guest: [
    {
      name: 'report_detail',
      description: 'Report Detail',
      id: 'sku_basic01',
      price: 999,
      currency: 'USD',
      product_data: {
        metadata: {
          type: 'one time',
          provider: 'guest',
          report: 'reportFaPropDetail',
        }
      },
      price_data: {
      }
    }
  ],
  professional: [
    {
      name: 'report_detail',
      description: 'Report Detail',
      id: 'sku_basic01',
      price: 299,
      currency: 'USD',
      product_data: {
        metadata: {
          type: 'one time',
          provider: 'guest',
          report: 'reportFaPropDetail',
        }
      },
      price_data: {
      }
    }
  ]
}
past tartan
#

Yes if you use price_data and product_data then you are creating new Products and Prices each time inline

river burrow
#

ok got it

#

so not optimal

past tartan
#

Mostly up to you if you want to do it that way, but yeah it will make reporting aggregation much more challenging

#

If you only have a set catalogue then you would generally create Product/Prices up front and just pass the relevant ID to line_items for your Checkout Session

river burrow
#

ok thanks a lot this has been really helpful!