#defekt7x - Subscription metadata

1 messages ยท Page 1 of 1 (latest)

buoyant egret
crisp patio
#

The only way I can get this to work is to listen for a invoice.created webhook and do the following:

async onInvoiceCreate(event: Stripe.Event) {
    const data = event.data.object as Stripe.Invoice;
    const invoiceId = data.id;

    await this.stripe.invoices.update(invoiceId, {
      metadata: {
        ItemCode: 'code here',
      },
    });

    return true;
  }

I'm not sure if that's ideal but let me know if there's anything that I'm missing here

buoyant egret
#

Yeah that delay does not sound ideal.

#

Let me take a look

#

Okay so how are you interacting with the metadata in question?

#

What do you want it to do?

crisp patio
#

Our integration with Avalara will pick it up. I don't personally have to do anything with it, but Avalara looks for those values to determine which tax code to use

#
exotic cliff
#

๐Ÿ‘‹ Just hopping in here - give me a minute to catch up

#

When you set the metadata of the subscription I belive that will automatically copy over that metadata to the invoice line items.

crisp patio
#

Oh, really? I do have some subscription metadata already, and it's definitely not getting set on the invoice metadata but how do I check the invoice line items metadata? Is there a spot for that in the dashboard that I can easily see?

exotic cliff
#

Can you send over the subscription ID? I can take a look real quick

crisp patio
#

Here's a subscription ID: in_1Knn7XCaXW5ee6rAC6b9iBru you'll see the ItemCode invoice metadata and that's because of the webhook that I created and posted above. If we're looking for subscription metadata that should get copied over to the invoice line items, then we're looking for 2 values: productId and trial_period_days

#

oh sorry that's an invoice ID

exotic cliff
#

That's okay - that gives me enough to start looking

crisp patio
#

Amazing. I'll add ItemCode to the main subscription metadata then. Thanks so much!

exotic cliff
#

๐Ÿ‘ happy to help!