#alanx4654

1 messages · Page 1 of 1 (latest)

coral orchidBOT
swift ore
#

I want to get brand、last4 fields from customer's subscription

ember stream
#

Hello! You can see the most recent card that was used to pay a subscription by expanding latest_invoice.payment_intent.payment_method

swift ore
#

So I need to use this latest_invoice id to retrive more data ?

#

or how to expand...
Cause I can't only get latest_invoice by retrive Subscription data

swift ore
#

I got this...why

ember stream
#

Hmm... let me take a look

#

You're getting an error because you're retrieveing a Customer, not a Subscriptoin

#

You need to be expanding latest_invoice.payment_intent.payment_method when you expand the subscription

swift ore
#

I think I need to use this subscription.latest_invoice.payment_intent

#

{
"id": "cus_OHjVYoKEbHyOEm",
"object": "customer",
"address": {
"city": null,
"country": "US",
"line1": null,
"line2": null,
"postal_code": "96746",
"state": null
},
"balance": -12498,
"created": 1689671857,
"currency": "hkd",
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": "zzzz@xxxx.com",
"invoice_prefix": "51B854DC",
"invoice_settings": {
"custom_fields": null,
"default_payment_method": null,
"footer": null,
"rendering_options": null
},
"livemode": false,
"metadata": {},
"name": "zzzzzz",
"next_invoice_sequence": 7,
"phone": null,
"preferred_locales": [
"en-US"
],
"shipping": null,
"tax_exempt": "none",
"test_clock": null
}

#

But I can't find any card info here

ember stream
#

Really I wouldn't recommend doing this from the Customer retrieval - we only allow you to expand 4 levels deep, and from the CUstomer object you'd have to do subscriptions.data.latest_invoice.payment_intent.payment_method which is too many levels and won't work

swift ore
#

yep I know , but your recomendation didnt work: latest_invoice.payment_intent.payment_method

#

Any ideas?

ember stream
#

Yeah as I said - you can't do that if you're retrieving the Customer (cus_123)

#

You need to be doing that for the SUbscription (sub_123)

#

There's no way to get the PaymentMethod information used for the latest Invoice from a single call if you're starting with the customer ID - you'd have to split it into two calls