Expanding objects when listing Events

550 views
Skip to first unread message

Karl Bishop

unread,
Mar 16, 2017, 11:39:44 AM3/16/17
to Stripe API Discussion
I'm having difficulty using the expand parameter. Specifically I'm trying to list Events of type invoice.payment_succeeded and simultaneously expand the subscription and customer.

The Events I'm listing look something like this in Ruby:

#<Stripe::Event id=evt_12345678 0x00000a> JSON: {
  "id": "evt_12345678",
  "object": "event",
  "data": {
    "object": {
      "id": "in_12345678",
      "object": "invoice",
      "customer": "cus_12345678",
      "subscription": "sub_12345678",
      ...
      ...
      ...
    },
    ...
    ...
    ...
  },
  ...
  ...
  ...
}

I initially tried an API call like:
Stripe::Event.list(type: "invoice.payment_succeeded", expand: ['customer'])

...and got an error message saying:
This property cannot be expanded (customer). You may want to try expanding 'data.customer' instead.

I've since tried the following params and got the following error messages:
expand: ['data.customer'] - This property cannot be expanded (data.customer)
expand: ['data.object.customer'] - This property cannot be expanded (data.object)
expand: ['data.invoice.customer'] - This property cannot be expanded (data.invoice)

Does anyone know if it's possible to use expand in my situation?
In the docs it says expand "is available on all API requests"

Remi J.

unread,
Mar 16, 2017, 11:56:43 AM3/16/17
to api-d...@lists.stripe.com
Hey Karl,

We don't support the Expand feature on events unfortunately. Events are stored as a snapshot of the resource it describes when the event was created. Because of this, we don't support expanding sub resources as we don't have a snapshot of those and showing their up-to-date status wouldn't make sense in the event.

What you need to do is retrieve the resource associated with the events so that you can expand everything and see the latest state of said resource.

Hope this helps!
Remi

--
You received this message because you are subscribed to the Google Groups "Stripe API Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss+unsubscribe@lists.stripe.com.
To post to this group, send email to api-d...@lists.stripe.com.
Visit this group at https://groups.google.com/a/lists.stripe.com/group/api-discuss/.

Karl Bishop

unread,
Mar 20, 2017, 7:27:47 PM3/20/17
to Stripe API Discussion
Hi Remi,

OK thanks for the info - I guess I can see the reasoning because there might be some Event scenarios where retrieving the up-to-date resource would cause confusion.

In my scenario though, there's no circumstance under which expanding the resources directly would have caused more problems than doing a separate retrieval, so it's a shame to have to do additional API calls.
Perhaps an idea for the future would be to allow a 'force expand' parameter on Events, so developers can decide explicitly for themselves whether or not to accept the risk?

Anyways, one thing I'd definitely suggest is that the Docs and error messages be updated to reflect the nuance of Expand with respect to Events - just so others don't fall into the same pitfall as me.

Cheers,
Karl
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.
Reply all
Reply to author
Forward
0 new messages