#ToxicMint-duplicates
1 messages · Page 1 of 1 (latest)
Yup!
Well,
in the app.post method for creating payment intent
Oh, the typo of ```js
query: 'name:test name',
is just me troubleshooting, I've tried all manner of quote combinations
So we don't recommend using Search for read-after-write flows. We mention this here: https://stripe.com/docs/api/customers/search. But sounds like you may not be doing write/read on your Customers
So it may be okay for your use case
app.post("/create-payment-intent", async (req, res) => {
const customers = await stripe.customers.search({
query: 'name:\"test name\"',
});
console.log(customers);
res.send(customers);
});
Had all the payment intent code commented out, deleted for space here
I believe you want query: "name:'test name'" if I remember correctly
I can double check
Yeah, the idea is searching on an internal application ID stored in the customer metadata to see if the customer's been created yet, if it exists we'll use it, otherwise we'll just create a customer
Oh that should work fine
I've even been trying it with raw cURL requests and haven't had any luck with a response
I'm not getting any entries back in the data array when I'm calling a search
The Search API is not instant, so it depends how long ago you created those first
If you are really looking at emails, you would be better off with https://stripe.com/docs/api/customers/list#list_customers-email instead
I originally wanted to search on a metadata value, searching on name and email were just me trying to narrow down whether it was syntax problems or not
How long is the delay typically on the Search API?
usually a few minutes but sometimes it's more backed up (which we're looking into right now)
I wouldn't use the Search API for your example/use-case personally since you could still get duplicates as it's not real time
What would be the best way to go about preventing customers with duplicate metadata values then, if not Search then create if missing?
Caching this in your own database instead
We mostly are already, we're just looking for how we keep track of certain things for the accounting department
But looking now, I can see a metadata field in PaymentIntent, which should do exactly what I'm hoping for
awesome!
Thanks! So far loving stripe from a developer side, way better documentation that what we were battling with before.