#ishu22g
1 messages · Page 1 of 1 (latest)
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.
- ishu-test-cards, 13 minutes ago, 11 messages
- ishu22g-future-payments, 3 days ago, 30 messages
Hello! What's the issue? Are you getting an error?
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
Do you have a request ID we can take a look at?
Okay let me find it
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
If I try to fetch paymentMethod by using
stripe.customers.retrievePaymentMethod(
stripeCustomerId,
stripePaymentMethodId,
)
From the request, I get an error
Here is the failed request: https://dashboard.stripe.com/test/logs/req_NNPnmrhB8UaAm9?t=1704761804
👋 Taking over this thread, catching up now
Basically, my current test flow is this:
- Create customer
- Create a real setupIntent using API
- Create a mock setupIntent, which already has paymentMethod for the same customer
- Replace mock setupIntent with real setupIntent ( in my service)
- Call API to fetch paymentMethod for the replaced setupIntent
- Fetch paymentMethod by Id from Stripe
I am getting error at Step #6
Hi @solar quiver
Can you try using Payment Method Retrieval Request? https://stripe.com/docs/api/payment_methods/retrieve
For example:
const paymentMethod = await stripe.paymentMethods.retrieve(
'pm_xxx'
);
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Let me check
Btw I am using this https://stripe.com/docs/api/payment_methods/customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
It worked
Thanks @solar quiver
The issue with the errored one was that the payment method was created on cus_PL9wzOstpu1Or5, but your request set the customer as cus_PL9wbchTKG54rt in https://dashboard.stripe.com/test/logs/req_NNPnmrhB8UaAm9
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
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
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
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}',
})
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?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Here is one
Could it be that I am search way too early and the other customer is not indexed yet?
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.
@solar quiver , can you please confirm why did this request fail?
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Thanks for waiting! Looking into it now
If you make the same request now, does it work? https://dashboard.stripe.com/test/logs/req_f9BJaOA4ZwNXV8
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
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
Interestingly enough, I don't see this payment method in customer's resource but I see it in the setupIntent created for testing:
https://dashboard.stripe.com/test/customers/cus_PLBM7QPlsv7apx
https://dashboard.stripe.com/test/setup_intents/seti_1OWUzbDSxrfK5JvAYHaljvpJ
Oh! I know what the issue is. When creating the payment method with Setup Intent, its status still remains as requires_confirmation: https://dashboard.stripe.com/test/logs/req_IzOtyBMyJXKPVn, i.e. the payment method is not saved to the customer yet
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Only when the Setup Intent becomes suceeeded, then the payment method will be saved onto the customer and available for retrieval