#drackosh_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1441408383147184238
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- drackosh_api, 2 hours ago, 15 messages
hi there!
the information you are looking for would be in the PaymentMethod object.
which you can find on the associated PaymentIntent (payments.data.payment.payment_intent)
I have
invoice.payments?.data[0]?.payment:: {
payment_intent: 'pi_3SQmnl3dUbPh0HoB0O4VvzRG',
type: 'payment_intent'
}
And then what Stripe api to call with what argument?
To get the actual payment method type (PayPal, Credit Card, etc) and the last 4 digits if it was a credit card
you retrieve the full PaymentIntent object with expand: payment_method. then in the API response you'll get the PaymentMethod object with a lot of information (type, last4, etc.)
[BILLING_HISTORY_GET] Error: This property cannot be expanded (payment_method). You may want to try expanding 'data.payment_method' instead.
at ignore-listed frames {
type: 'StripeInvalidRequestError',
raw: [Object],
rawType: 'invalid_request_error',
code: undefined,
doc_url: undefined,
param: undefined,
detail: undefined,
headers: [Object],
requestId: 'req_OZEkXuWT8FLQpM',
statusCode: 400,
userMessage: undefined,
charge: undefined,
decline_code: undefined,
payment_intent: undefined,
payment_method: undefined,
payment_method_type: undefined,
setup_intent: undefined,
source: undefined
}
My code:
const invoices = await stripe.invoices.list({
customer: session.user.stripeCustomerId,
limit: limit,
starting_after: cursor ?? undefined,
expand: ['data.payments', 'payment_method'],
})
there's no payment_method on the Invoice itself. it's on the related PaymentIntent
I don't understand what I need to specify in the expand exactly
const invoices = await stripe.invoices.list({
customer: session.user.stripeCustomerId,
limit: limit,
starting_after: cursor ?? undefined,
expand: ['data.payments.data.payment.payment_intent'],
})
Gives [BILLING_HISTORY_GET] Error: You cannot expand more than 4 levels of a property. Property: data.payments.data.payment.payment_intent at ignore-listed frames {
once you have the PaymentIntent ID, make an extra API request to retrive the PaymentIntent with the payment_method expended.