#AM.retrieve-pm
1 messages · Page 1 of 1 (latest)
I do.
I have both
But want to verify the token matches the payment method.
essentially I save the token in the db while the user is going through the 3D secure process. I then update the db with the pm id once my webhook is triggered with a setup_intent.succeeded event. But to update the correct card in my db I need to match the pm to the token.
Got it
Let me check
Can you clarify what you mean by 'token'?
Can you share the ID of the PaymentMethod (pm_xxx)?
Sure, give me a sec.
I currently get back a string 'tok_xxx' from stripe when a user enters their card details. This is a legacy application.
Here is a an example tok_xxx and matching pm_xxx. I only know they match because I am generating them during testing. The paymentMethod id is returned from the payload of the setup_intent.succeeded event.
tok_1JttX9Jk2S5ksjC97pOZjzqQ
pm_1JttXAJk2S5ksjC9GJbweDyj
Hello, catching up on this thread. Thanks for the IDs will look in to them in a moment
👍
Apologies, I am still looking in to this. Not seeing a great way at the moment.
So is there info from the token creation that you are trying to link up with the specific SetupIntent/PI other than this token?
I can think of a workaround but want to see if there is a built in way to do this first
No worries, take your time. Well, I want the paymentMethod id to be saved in the db instead of the token id. I need the paymentMethod id as the app allows users to manage their cards and so when they delete a card the only way for me to find the corresponding card in stripe and delete it is using the pamentMethod id.
Gotcha. I'd recommend putting the token_id or whatever other identifying info you want in to the metadata param of your SetupIntent
Sorry to interject, but are you attaching the PMs to Stripe Customer objects?
(I assume yes otherwise they're not reusable)
Yes.
Is there a reason why you can't store the Stripe Customer ID in your database with the associated user?
You can then retrieve all PMs for that Customer: https://stripe.com/docs/api/payment_methods/customer_list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I have the customer ID saved in the users table. I also have a table of cards each with their pm ID. I don't think your method will work @shy lark as I would not be able to verify which card from the cards table the pm belongs to.
Right, but why do you need to store the PM IDs if they're attached to the Customer ID (which you have in a table)?
Just trying to understand, as there's no easy way to do what you originally asked
The reason is because when a user is going to pay for something in the system. They choose a card. The system then uses the paymentMethod ID to identify which of the customer's paymentMethods to use. If I do not store them in the db. When a user selects a card I will not know which paymentMethod it belongs to in stripe.
You can use the API I linked to above to list them from the Stripe API using the Customer ID. That way you don't need to worry about keeping them sync'd in your own DB
That is a fantastic point but the system is very old and uses the cards for so many other features. It would be a huge task to change how this aspect works. Is the method mentioned by your colleague about storing the token ID in the setupIntent metadata not a valid solution?
Yeah, that will work. It's just more cumbersome and requires more implementation code on your end. I was just coming at it from a different perspective
But if you have legacy stuff you need to support then I guess that's the best path forward
Alright I will give that go now, and thanks for the help. Will definitely keep on board your suggestion for when I inevitable rework the system.
No problem! Let us know if it helps with your issue