#windlepoons - payment method

1 messages · Page 1 of 1 (latest)

limpid pendant
jovial oriole
#

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.

limpid pendant
#

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

jovial oriole
#

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?

limpid pendant
#

Are you still referencing this event (evt_1Knmu0JNcmPzuWtRmfqDJiWZ) from above?

jovial oriole
#

Yep

limpid pendant
#

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?

jovial oriole
#

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.

rustic timber
#

Hi, steppin in here. Give me a minute please to review this request

jovial oriole
#

Sure

rustic timber
#

Still digging here

jovial oriole
#

okey

sharp spear
#

the card was deleted

#

When the card is deleted it can't be retrieved via the API anymore

jovial oriole
#

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.

sharp spear
#

it does

jovial oriole
#

I don't see one on evt_1Kn1QLJNcmPzuWtR2S1PVUTW

sharp spear
jovial oriole
#

The card id, but not the payment method id.

sharp spear
#

yeah that's the thing you're mixing all of this up really

jovial oriole
#

When it was added, the event had a pm_* as the object id.

sharp spear
#

A card_123 is a PaymentMethod

jovial oriole
#

When its removed, it is a card_* format as object id.

sharp spear
#

it's a compatibility layer that's all

jovial oriole
#

oh, hmmm, I thought it had a pm_* format id when it was added. 🤔

sharp spear
#

that card was created back in early 2020

#

My guess is that you are mixing up historical data and new data, especially as there are a lot of logs on that customer recently

jovial oriole
#

ahhhh, ok, that makes sense

#

thanks!