#windlepoons - payment method
1 messages · Page 1 of 1 (latest)
Example event: evt_1Knmu0JNcmPzuWtRmfqDJiWZ
It makes for some very clumsy code (with lots of doc strings to explain to coworkers that Stripe API's are weird), that even though the object type is payment_method, the id has to be checked as well before attempting a fetch to determine the appropriate Stripe retrieval API to use.
So a payment method can be a variety of different types. I don't fully understand the question.
Also, card can be retrieved via the API, just not the Payment Methods API: https://stripe.com/docs/api/cards/retrieve
The situation is that we're attempting to fetch the latest state of an object when we're notified by Stripe, to ensure we're operating based on latest information (given latencies in webhook API's, etc). It's turning into a mess of code to do this, as we have to examine the id, not the object type, to then use the correct API to fetch the object.
Feature request.... API that fetches a Stripe object by id, regardless of type. heh
Cause now we have to do string checks to then use the appropriate Stripe API call to fetch it. We had previously assumed that the object string would tell us the type of object, but it does not.
In our case, we cache the payment method data to the customer, this detached event doesn't include what the payment method id was. Is that available somewhere?
Are you still referencing this event (evt_1Knmu0JNcmPzuWtRmfqDJiWZ) from above?
Yep
That's an interesting point. I'm actually suprised that you can't supply a card_ to the Payment Methods API 🤔
Let me dig on this a little bit
So if I understand you correctly, you're trying to make sure your cache is synced with Stripe and in order to do that your integration is listening to payment_method.detached and then attempting to update based on the new state of the payment method yes?
@jovial oriole you should be able to retrieve a card_ via the Payment Methods API. Do you have a request that shows this isn't working for you?
yep
req_ttwzYzE12DxbMk
if the card was removed (it was detached), is this what would happen?
There's no payment method id on this, which makes it more difficult to locate the payment method in our cache to remove, as we keyed it by the payment method id on the customer.
Hi, steppin in here. Give me a minute please to review this request
Sure
Still digging here
okey
the card was deleted
When the card is deleted it can't be retrieved via the API anymore
How come the event doesn't include the payment method id so I can easily remove it from my cache?
All the other payment_method webhook events include a payment method id.
it does
I don't see one on evt_1Kn1QLJNcmPzuWtR2S1PVUTW
You deleted the card here: https://dashboard.stripe.com/logs/req_GwMO4Vrq4jCt8u
The event you mentioned has the card id https://dashboard.stripe.com/events/evt_1Knmu0JNcmPzuWtRmfqDJiWZ
Same for the new one you mentioned
The card id, but not the payment method id.
yeah that's the thing you're mixing all of this up really
When it was added, the event had a pm_* as the object id.
A card_123 is a PaymentMethod
When its removed, it is a card_* format as object id.
it's a compatibility layer that's all
oh, hmmm, I thought it had a pm_* format id when it was added. 🤔