#Rita Ly
1 messages ยท Page 1 of 1 (latest)
Or get just list of reasons, even without invoices.
I'm using JS / typescript or python
You can list invoices by status with this endpoint
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
but what about the reason why payment failed?
And then you could retrieve the payment intent on each invoice, they will each have a latest_charge property that shows info about the latest charge including the decline that it ran in to
Oh so that's how the list api's work?
So something similar to this can be redundant then?
I tired curl with status but returns {}
could you provide me just simple curl example ? ๐๐ป
-u rk_live_... : \โจ
-d status=uncollectible \
-d limit=3
status not allowed and also there's no field in response like latest_charge
Do you have a specific ID of an invoice that you would expect to show up there?
If you click on one in your dashboard the ID (in_123) will be in the URL
latest_charge is on the payment intent object not the invoice https://stripe.com/docs/api/payment_intents/object#payment_intent_object-latest_charge
So to be clear, the invoice objects will have a payment intent property https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent
And those payment intents will have charges, the charges will have decline codes
ok, but when I'm on invoice view I'm interested why the invoice wasn't paid - that info is visible on invoice (screen above)
I'd like to get the reason why payment failed
That page is pulling information from the payment intent and its charge
okey! so how can I get this information via API ?
could you write me steps in that case, because e.g export invoices with all fields to csv also doesn't include that quite crutial information ?
๐
I think it might be easier to show this with one invoice. Can you copy the ID of the invoice from your screenshot (in_123)? That ID will be in the URL for that invoice's dashboard page
So can you try making this call but on that ID? https://stripe.com/docs/api/invoices/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
And include expand=['payment_intent.latest_charge'] as per this section? https://stripe.com/docs/api/expanding_objects
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ok, give me sec
why do I need Having the 'rak_charge_write' permission would allow this request to continue. write to read charge info?
It sounds like you are using a restricted key that doesn't have proper permissions. Unfortunately sometimes our error messages there are inaccurate
We are working to improve them there. You don't actually need write permissions. Likely that rak_charge_write includes read permissions that you need here and we picked that over rak_charge_read to include in the error message
I can add myself any key, but quite strange that I need write permission to read ๐ and I'm sure that our BI team has only read
You should only need read permissions. That error message is incorrect
now
curl https://api.stripe.com/v1/charges/ch_3MrxqEKpJcQYpR3W0yYDtM5B
-u rk_live_XXX:
-d expand=['payment_intent.latest_charge']
gives me error
unexpected expand array ๐
(I added full access for testing)
{
"error": {
"message": "Invalid array",
"param": "expand",
"request_log_url": "https://dashboard.stripe.com/logs/req_R9Bhw4FwvlKdGj?t=1680530052",
"type": "invalid_request_error"
}
}
So I linked to two separate docs before, the first one is the call that you actually need to make here: https://stripe.com/docs/api/invoices/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
no problem this param is no needed witout it I see the reason
With the expand argument from the second doc
So try something like this
-u rk_....: \
-d expand=['payment_intent.latest_charge']```
aaaa
{
"error": {
"message": "Invalid array",
"param": "expand",
"request_log_url": "https://dashboard.stripe.com/logs/req_bRXoUn2LSzifaS?t=1680530755",
"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.