#ishu22g

1 messages · Page 1 of 1 (latest)

haughty starBOT
#

Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

atomic thunder
#

Hello! What's the issue? Are you getting an error?

plain path
#

Hi,

I created setupIntent using API and want to automate the test flow.

#

When I create it using the request you suggested, I get paymentMethod Id == null

#

So basically no payment method gets associated with the setupIntent, even if I use

payment_method: 'pm_card_visa',

while creating setupIntent, as you suggested

atomic thunder
#

Do you have a request ID we can take a look at?

plain path
#

Okay let me find it

haughty starBOT
atomic thunder
#

You can see the payment_method in the response

#

It's pm_1OWTcWDSxrfK5JvA1DumYvpL

plain path
#

If I try to fetch paymentMethod by using

stripe.customers.retrievePaymentMethod(
stripeCustomerId,
stripePaymentMethodId,
)

From the request, I get an error

solar quiver
#

👋 Taking over this thread, catching up now

plain path
#

Basically, my current test flow is this:

  1. Create customer
  2. Create a real setupIntent using API
  3. Create a mock setupIntent, which already has paymentMethod for the same customer
  4. Replace mock setupIntent with real setupIntent ( in my service)
  5. Call API to fetch paymentMethod for the replaced setupIntent
  6. Fetch paymentMethod by Id from Stripe
#

I am getting error at Step #6

#

Hi @solar quiver

solar quiver
plain path
#

Let me check

#

It worked

#

Thanks @solar quiver

solar quiver
plain path
#

Okay let me check that

#

Yes, you are right

#

I am trying to find the pre-existing customer using

stripe.customers.search({
query: metadata['userId']:'${userId}',
})

When it doesnot return one, I create a new one

#

Am I doing something wrong in the search?

#

Both have same userId in the metadata

solar quiver
#

Why don't you save the customer ID in your database after creating one, instead of searching at Stripe?

#

For example at Step 1, you'll save the customer ID after the creation

plain path
#

I will eventually thats the goal. That resource is not there yet

#

I am working on payment flow first

#

But still would be interested to know if the request above have any issues with it

#

stripe.customers.search({
query: metadata['userId']:'${userId}',
})

solar quiver
#

Stripe will return the list of customers that match the search query

#

If you have two customers with the same metadata, both will be returned in the response

#

Was there any result returned in your response? Can you share the request ID (req_xxx) of your customer search?

plain path
#

Here is one

#

Could it be that I am search way too early and the other customer is not indexed yet?

solar quiver
#

The request looks fine to me. But yes, that could be possible that the customer is not indexed for searching yet.

#

The recommended integration moving forward will still be saving the customer ID in your database instead of searching at Stripe.

plain path
#

Okay

#

I think I need to implement that first

#

Thanks

plain path
#

@solar quiver , can you please confirm why did this request fail?

solar quiver
#

Thanks for waiting! Looking into it now

plain path
#

Yes, I get same error

#

Just tried

#

Btw, I was planning on logging off soon

#

If I receive any messages later, I will respond tomorrow morning

solar quiver
#

Only when the Setup Intent becomes suceeeded, then the payment method will be saved onto the customer and available for retrieval