#monshery - storing payment id
1 messages · Page 1 of 1 (latest)
Can you explain exactly what it is you need help with here? Things you said makes sense, but I'm not sure what guidance you're seeking or what problem you're having
Since we dont want to have duplicate fulfilment we update-lock transaction row, that means that if webhook is too quick it wont be able to access that transaction as its in a lock
Due to the above issue i am thinking of removing webhooks for payments
and simply upon success request, i would repeatedly do
const paymentIntent = await stripe.paymentIntents.retrieve(intentId);
and check if status is success
Perhaps you could set this up in your database with generated keys that you use as metadata or idempotency keys and map to that rather than the payment intent id you might not know yet
That would be my suggestion
Hmm
key on your own ID in metadata
I see what you mean
generate it ahead of time
yep
hmm
metadata: { monshery_id: 'payment_1234'}
which will be in the webhook events
Yea i already do that
but with the transaction ID
so then in the webhook i look up the transaction ID
The issue is
if somehow a user made a successful purchase
but the webhook for some odd reason didnt work
we wont have a way an easy way to track the intentId
Will sort of result in"lost in the system" transaction
we will have to somehow query stripe for all paymentIntents with metadata: {transactionId: 'xxx'}
What i am contemplating doing is, when i do
const paymentIntent = await stripe.paymentIntents.retrieve(intentId);
and when i get a successful response i do a interval that do:
const paymentIntent = await stripe.paymentIntents.retrieve(intentId);
every like 1 second to check for paymentIntent.status === 'success'
what do you think ?
Hello ?
hey there sorry hopping around
No why would you need this?
You create the payment intent with the custom id in metadata
then when you get PI events, you look at the metadata for your own id, not the PI id
and look up that way, then save the PI id if you don't have it already
Is there a gap somewhere that doesn't cover that you can explain?
yea there's a gap
So if the webhook didnt work for some reason
and i dont have the paymentIntentId
I will have to query stripe for the ID i set in meta
Where do you need that ID though?
You'd get the payment intent ID in the response
And you can set it in your db then if not yet set
Nevermind i was trying to solve something i shouldnt
If after 1 h i dont get a response from stripe/webhook. i will just let the client know to talk to our support
as its extremely unusual
That's fair - but i think for any case where the ID was relevant you should be able to access it
Are you all set here then?