#bmizerany
1 messages Β· Page 1 of 1 (latest)
Hi there, you need to attach the payment method to the customer before setting this payment method as the default_payment_method, this applies even to test pms
Ah okay thank you.
Is that the only way in tests? I'm using checkout and this is normally handled by Stripe
I guess the answer is to "mimic checkout" in tests?
What do you want to achieve here?
I'd like to write a regression test prove I'm updating the default payment method of a customer to the recent payment method add/updated in a checkout session I sent them through
Checkout page won't prefill the customer's default_payment_method, it'll pre-fill the payment method that the customer used previously in checkout.
right
so I have to do taht after
which is what I'm attempting to do AND test π
I have been able to attach pm_card_us
in fact, I was when creating the customer using payment_method=pm_card_us
then when I update the customer to set the default payment_method it says it isn't allowed because it is not attached
Here is another run of the test:
req_Qxp3LHuUnI2Jrr
and then:
req_SqzGimueH6Dib6
the first "attaches" pm_card_us
the second attempts to set it as the default
https://stripe.com/docs/api/payment_methods/attach?lang=curl#customer_attach_payment_method you should use this API to attach a payment method, and it would return you a pm ID which you can use to set as the default payment method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Isnβt βpm_card_usβ and existing and valid payment id?
Iirc the docs say it is
@keen star so what does the payment_method param on POST /v1/customers do?
If it isn't attaching a payment method, which is what the docs say?
BTW I'm not surprised if it doesn't work as advertised or at all, I've found plenty of those in Stripe, but it would be good to know that for sure instead of trying to force it to work
I don't see a payment_method on the Customer Update API reference (https://stripe.com/docs/api/customers/update?lang=curl#update_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.
Here is another run after attaching:
req_Eqq4i5wjacjQ3E -> req_OGr8D4itntPTMU -> req_gGTtQWryTXRbM7
The attach happens in the 2nd request, and succeeds
then fails to acknowledge the pm on the 3rd
The 2nd request gives you a payment method ID ('pm_1Mwdg0CouQWSdzy15Wv7unk5'), and you need to use that ID to attach it to the customer
I am so confused. I thought pm_card_us IS a valid payment method ID
so I do not need to attach. It is attached, by default, to all customers old, and yet to be in Test Mode
It is a special test payment method ID.
I know
but a payment method ID none the less
it seems like the docs could be more clear
Thanks for your feedback.
or prefix the id with testcard_ not pm_
but it is accepted in places where pm_s are accepted, just not on default payment method
which is odd
I think that might be unintended
It would be nice to use it as if it was a valid payment method on a customer that has already attached it... in fact, I did attach it, it's just that it needs to be converted to another ID, which is not normal in production
You can't use pm_card_us in production.
@keen star I am very aware of that
My point is that to use pm_card_us in Test I have to do things in test I would not do in production or that even make sense to do in production, which is not what the docs say about how to reason about test cards.
The docs imply they are valid attached cards for all customers at all times in test mode
so that one does not have to go through the "deprecated" attach API in test mode only. I say "deprecated" because it is documented in the API you and I referenced that it is succeeded by SetupIntents and PaymentIntents, however... those are not "testable" given the nature of PCI, so in tests.. use pm_card_us and friends.
I did, and I'm seeing unexpected behavior
Based on all of this, it seems like it's a valid bug in Test Mode
or the docs are lacking
The docs imply they are valid attached cards for all customers at all times in test mode can you share with me the doc that makes you think that these cards are already attached?
That's the thing.. it seems "implied" because it does not say I have to attach them
And they API calls the default payment method a "default_payment_method"
so ... pm_card_us as far as one can tell from the docs, a valid payment method
π Taking over this thread, catching up now
anyway... I'll try the converstion from payment method to payment method
and see if that fixes it
hi @smoky bobcat
Thanks for the feedback, I'll pass along to the docs team and see how we can improve it.
@keen star if you look at the request response, it shows the "converted" pm_ id
which is also very confusing
this happens before attaching
any chance either of you could help me understand what this is for? It doesn't seem to do anything if I set it to a valid payment method. It succeeds even with pm_card_us
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I need to go, please let @smoky bobcat know if you need any help
any chance either of you could help me understand what this is for? It doesn't seem to do anything if I set it to a valid payment method. It succeeds even with pm_card_us
Do you mean the purpose of setting payment_method withpm_card_usin Create Customer API?
Thank you, @keen star !
@smoky bobcat Yes. It seems (now that I know the test payment methods need to be resolved to another payment method in test mode vs live) that setting payment method on create customer is just a "shortcut" for attach and resolve?
This is to attach a payment method to a customer. In general, we recommend using https://stripe.com/docs/api/payment_methods/attach?lang=curl#customer_attach_payment_method to attach a payment method to the customer. It allows multiple payment methods saved onto the 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.
I have a test proving payment_method does something, not nothing.
The whole confustion here is that pm_card_us and friends are called Payment Methods, but that are just cards
just pm_s per se
and nowhere in the docs about test cards does it say they have to be attached
that I could find
there is no where that says I have to resolve a test card to a new pm_123 either
anyway... I've got a test working even though it's not representative of what is actually happening in live mode. thank you both.