#alanx4654
1 messages · Page 1 of 1 (latest)
I want to get brand、last4 fields from customer's subscription
Hello! You can see the most recent card that was used to pay a subscription by expanding latest_invoice.payment_intent.payment_method
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
{
"error": {
"message": "This property cannot be expanded (latest_invoice).",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_dz9kka1pUm7jbk?t=1689702993",
"type": "invalid_request_error"
}
}
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I got this...why
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
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
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
yep I know , but your recomendation didnt work: latest_invoice.payment_intent.payment_method
and this is the error I got:
{
"error": {
"message": "This property cannot be expanded (latest_invoice).",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_dz9kka1pUm7jbk?t=1689702993",
"type": "invalid_request_error"
}
}
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Any ideas?
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