#tungtn1099

1 messages · Page 1 of 1 (latest)

mellow jungleBOT
serene briar
#

Well you could check the previous_attributes hash on the payload. If it's a downgrade/upgrade then there'll likely be an items field in that hash

slow marten
#

Weird, my event data object is missing that hash

serene briar
#

Can you share an example?

slow marten
#

Oh wait, should it be outside of the event.data.object?

serene briar
slow marten
#

Alright I see, thanks!

#
previous_attributes: {
      billing_cycle_anchor: 1697861376,
      current_period_end: 1713672576,
      current_period_start: 1697861376,
      items: [Object],
      latest_invoice: <redacted>,
      plan: [Object]
    }

It says

serene briar
#

Probably safe to just ts-ignore that

slow marten
#

got it, thanks

serene briar
#

Or feel free to type it yourself based on the fields you need to check

slow marten
serene briar
#

I don't understand. You'd just create your own interface and then cast previous_attributes:

interface SubPrevAttr {
  items: Stripe.ApiList<SubscriptionItem>
}

event.data.previous_attributes as SubPrevAttr
#

Sorry can't remember the exact interface names