#mauriver21
1 messages ยท Page 1 of 1 (latest)
That depends entirely on how you want to go about it.
Or how you want to filter
Charges are the ones with a relatively binary status property so if you simply want to see all payments where charge.status == 'failed', that might be the best place to start
I've noticed on this flow when I create a failed payment intent, inmediatly it doesn't get reflected the failed status on the charge. It takes between 10 - 15 seconds to update the charge with failed status when doing this.
await simulateFailedPaymentIntent(customerId);
const charges = await stripe.charges.search({
query: 'status:"failed"',
expand: ['data.customer', 'data.payment_intent'],
});
console.log(charges.data.find(charge => charge.customer.id === customerId)) //undefined
so I was thinking it would better to search from failed payment intents, but there is no a failed payment intent status
Right, because Payment Intents are designed to be recoverable. Additionally you may see different performance if you use the List API. Search tables are not real time due to the time to index
Thxs for the confirmation
having this clear I will add a delay to my unit test
you were so helpful ๐
I'm glad I was able to shed a little ๐ก on the subject
I tried directly list so now I don't need the delay due to what you mention, search tables are not real time. Is this clarification documented on stripe?
const charges = await stripe.charges.list({
status: "failed",
expand: ['data.customer', 'data.payment_intent'],
});
๐ stepping in as Snufkin needed to step away
That's correct that Search API is not real-time. We do mention this in the API Ref: https://stripe.com/docs/api/charges/search
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Np!