Relationship between source and card?

1,299 views
Skip to first unread message

Martin Jambon

unread,
Nov 9, 2016, 9:50:41 AM11/9/16
to Stripe API Discussion
Hi,

I'm confused about the relationship between a source and a card.

Intuitively, a card should be one kind of source, i.e. a subtype of source. However, the documentation doesn't seem to agree with me:
  • the source and card objects contain incompatible fields and subfields
  • didn't find a call for listing all the sources
  • a source has a status field but cards don't
  • the customer object comes with the fields `default_source` and `sources` which are cards and not sources
  • there are events only for sources (customer.source.*)
Based on the example of a source given for bitcoin, a source is an object with its own ID, that contains a tag and a value corresponding to that tag:

{
  <source id and other fields>
  type: bitcoin
  bitcoin: <bitcoin id and other data>
}

and I'm guessing we'd have the following for a card:

{
  <source id and other fields>
  type: card
  bitcoin: <card id and other data>
}

Is this correct? If so, how can we retrieve all the sources for a customer?

Our goal is to determine whether a valid payment source is available, cache the result and be notified of any change.

(we're using API version 2015-02-18)

Martin

Olivier Bellone

unread,
Nov 9, 2016, 2:24:01 PM11/9/16
to api-d...@lists.stripe.com
Hey Martin,

I think there's some ambiguity here. "Source" can mean two different things depending on context:

- it can refer to the `sources` attribute for a customer [1], which contains the list of payment sources for that customer. Each of these "sources" can have different types: `card`, `bank_account`, `alipay_account`, `bitcoin_receiver` or... `source` (see next point).  So when iterating over the list of sources for a customer, you should check each entry's `object` attribute to get the correct resource type for that payment source.

- it can also refer to the new `source` top-level resource [2] that we recently introduced. Right now, sources are only used for Bitcoin payments (they deprecated the old `bitcoin_receiver` type), but we have plans to add support for more payment methods through this resource in the future rather than adding new resource types. You will be able to know the payment method a source represents through its `type` attribute.

I hope this clarifies things!



--
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...@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/.

Martin Jambon

unread,
Nov 9, 2016, 2:53:24 PM11/9/16
to api-d...@lists.stripe.com
Thanks, Olivier. It's just what I needed to know.
Reply all
Reply to author
Forward
0 new messages