#bruhhhhh_invoice-paymentintent-lookups

1 messages ยท Page 1 of 1 (latest)

pure groveBOT
#

๐Ÿ‘‹ 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/1397702840260100206

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

barren ore
#

Hi! What info / ID type are you starting the search with?

strong badge
#

i'm starting with payment intent ID and charge ID respectively for the two logic paths specified above

pure groveBOT
strong badge
#

i want an implementation of the two logic flows without having to loop through all invoice objects. ideally, i want the most performant implementation possible.

night lion
#

Hi ๐Ÿ‘‹

I'm taking over as my colleague needs to go

pure groveBOT
night lion
#

You can get to the Invoice without paginating through the List Invoice API

#

In both cases you will need the Payment Intent ID but you can find this in the payment_intent property on the Charge object.

strong badge
#

i'm a bit confused on how to can get to a unique invoice based on a Payment Intent Id

night lion
#

Getting to that bit

#

Oh, hold up. Can you tell me what API version you are using?

strong badge
#

i'm on Node.js SDK 18.0.0

#

i can upgrade to a higher version if need be

night lion
#

Okay that SDK version is pinned 2025-03-31.basil

#

Just making sure because, prior to the .basil release, the answer was different. But this works

strong badge
#

just to double confirm. my NodeJS SDK version is Node.js SDK 18.0.0 โ€ข Basil. are you saying there is a way to get to a Stripe Invoice object from a Stripe Payment Intent object?

night lion
#

The issue you are having is that as of the .basil API changes, specifically this one, we no longer have a direct link between Payment Intents and Invoices.

The way you find what Invoice a Payment Intent is related to is through the Invoice Payments object.

strong badge
#

gotcha, let me try this and get back to you. thanks!

#

i might potentially get back to you tmr depending on how quickly i'm able to verify this hypothesis

night lion
#

No worries! Someone will be here when you a follow up or new question.

strong badge
#

thank you!

night lion
#

Happy to help ๐Ÿ™‚

strong badge
#

does the Stripe NodeJS sdk support filtering simultaneously while listing invoices?

night lion
#

If you are referring to filtering the Invoice Payments, you pass the Payment Intent ID as a parameter in the List API.

#

If you're talking about something else, could you share more details?

strong badge
#

i think that answers your question for now! thanks!

night lion
#

Great! ๐ŸŽ‰

strong badge
night lion
#

Yeah, that wording could be more clear

#

In Python (my โค๏ธ language), it looks like

invoice_payments = stripe.InvoicePayment.list(
  payment= {
    "type": "payment_intent",
    "payment_intent": "pi_XXXXXXXXX" # <- this is where you put the ID
  }
 )
strong badge
#

hmm i'm trying the following curl, but it's not working for me

curl "https://api.stripe.com/v1/invoice_payments" \ -u "sk_lMP:" \ -H "Stripe-Account: acct_1P08oKEcXPR7OoBw" \ -G \ -d limit=10 \ -d data.payment_intent='pi_3Ro0sdEcXPR7OoBw01Oz0NVO' \ -d "expand[]=data.payment"
night lion
#

What does the API response look like?

strong badge
#
{
  "error": {
    "code": "parameter_unknown",
    "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
    "message": "Received unknown parameter: payment_intent",
    "param": "payment_intent",
    "request_log_url": "https://dashboard.stripe.com/acct_1P08oKEcXPR7OoBw/logs/req_IHk8e8iRcj6SEC?t=1753312074",
    "type": "invalid_request_error"
  }
night lion
#

Okay yeah you aren't passing the parameter correctly. You are just putting payment_intent: pi_XXXX.

You need to provide the entire payment parameter. This includes a nested payment.payment_intent as well as payment.type

#

It's what I did in my Python example above, but with JavaScript object syntax

strong badge
#

oh interesting

night lion
#

I think in Node it would look something like this:

const invoicePayments = await stripe.invoicePayments.list({
  invoice: 'in_103Q0w2eZvKYlo2C5PYwf6Wf',
  payment: {type: "payment_intent", payment_intent: "pi_XXXXXXXXXXX"}
});
strong badge
#

when i try

curl "https://api.stripe.com/v1/payment_intents" \
  -u "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:" \
  -H "Stripe-Account: acct_1P08oKEcXPR7OoBw" \
  -G \
  -d limit=10 \
  -d payment_intent=pi_3Ro0sdEcXPR7OoBw01Oz0NVO \
  -d type=payment_intent \
  -d "expand[]=data.payment"

```,
I'm getting 

{
"error": {
"message": "This property cannot be expanded (data.payment).",
"request_log_url": "https://dashboard.stripe.com/acct_1P08oKEcXPR7OoBw/logs/req_tP2rqbWRI4w9Og?t=1753313067",
"type": "invalid_request_error"
}
}

night lion
#

Your CURL request is still wrong

#

You aren't passing the nested payment parameter. I think it should look something like this:

curl "https://api.stripe.com/v1/payment_intents" \
  -u "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:" \
  -H "Stripe-Account: acct_1P08oKEcXPR7OoBw" \
  -G \
  -d limit=10 \
  -d payment[payment_intent]=pi_3Ro0sdEcXPR7OoBw01Oz0NVO \
  -d payment[type]=payment_intent \
  -d "expand[]=data.payment"
#

And you cannot expand the payment property

strong badge
#

gotcha thanks!