#John-paymentmethod-retrieve

1 messages ยท Page 1 of 1 (latest)

hearty spear
#

Hi there! Can you share your code snippet where you are making that request?

#

Sounds like you may be looping?

#

Something on your end is triggering it multiple times.

tame pollen
#
    static async findWithPaymentMethod({
        paymentMethodID
    }: { paymentMethodID: string }) {
        const self = this;
        if (!System.Util.isStringWithCharacters(paymentMethodID)) throw new System.ModuleError(self, 'ISICP-102', `Invalid payment method ID.`);

        try {
            return await stripe.paymentMethods.retrieve(paymentMethodID)
                .catch(err => {
                    throw new System.ModuleError(self, 'ISICP-405', `Unable to find customer.`, err);
                });
        }
        catch (err) {
            throw new System.ModuleError(self, 'ISICP-406', `Unable to find customer.`, err);
        }
    }
#

That's the function that references the stripe library

#

here's the code referencing it

#

            const stripePaymentMethod = await StripeCustomer.findWithPaymentMethod({ paymentMethodID })
                .catch(err => {
                    SuperUser.notify({ message: `ClickFunnels merchant registration FAILED, unable to find customer in Stripe with Payment Method ID: ${JSON.stringify(err)}` });
                    throw new ModuleError(self, 'SASUCF-11', `Unable to create Merchant Profile.`, err);
                })
#

No loops.

hearty spear
#

What is triggering stripePaymentMethod?

tame pollen
#

There's an inbound HTTP request to our webhook from the ClickFunnels application.

#

Our webhook is receiving customer data that was generated by the ClickFunnels -> Stripe integration. We are then taking the PaymentMethod from that request to find the cus_ ID for the customer that was created, then saving that customer ID to our application

#

The data coming from ClickFunnels doesn't contain the Stripe customer ID. It only contains the payment method ID. So we're having lookup the customer that was created, by using the paymentMethod.retrieve() function

#

I'll check the ClickFunnels webhook log to see if it's sending dozens of requests to us, which is the only way that this code could be invoked dozens of times. There's no other loops or other code that iterates.

#

Here's what the stripe logs show:

hearty spear
#

Can you provide me one of those request IDs?

tame pollen
#

req_Y0vvt6IARi7Ibp

#

This one failed ^

hearty spear
#

What do you mean by "failed"?

tame pollen
#

req_mCguwf4yIB9hMo <-- this one succeeded, but we're seeing rate limit errors in our logs

#

These requests all appear identical.

#

The top request has a customer object

hearty spear
#

Both of those are successful requests. One is a customer update and one is a customer retrieval. Neither of those are paymentmethod retrievals.

#

So those requests don't align with the above code that you are talking about.

tame pollen
#

Interesting. Ok, one moment. Need to do an assessment of some different processes here.

#

Brb.

hearty spear
#

๐Ÿ‘

tame pollen
#

Thanks btw!

hearty spear
#

No rush, I'll be here ๐Ÿ™‚

#

Of course!