#bugkiller.
1 messages ยท Page 1 of 1 (latest)
Sure
stripe.Customer.modify(
customer_id,
invoice_settings={"default_payment_method": setup_intent.payment_method},
)
so I can make it as default payment method when user adds card
but my question is
cards = stripe.PaymentMethod.list(
customer=stripe_customer.id,
type="card",
)
I'm getting all cards with thsi api and it's listed in our website
so I'd like to know if user wants to make one of it as default payment method
what api should I use?
Slight correction. You need to use this api instead: https://stripe.com/docs/api/payment_methods/customer_list?lang=python
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You're using the one for treasury flows above
So needs to be this:
"cus_123",
type="card",
)```
what's the difference?
The difference is that the one you're using is for treasury flows. You can read the description in the api spec
stripe.Customer.list_payment_methods
stripe.PaymentMethod.list
between these 2
I still don't understand your question though. Just use that endpoint to list cards and give the customer the choiec on which to select
stripe.PaymentMethod.list
here this doesn't give me payment method id
stripe.Customer.modify(
customer_id,
invoice_settings={"default_payment_method": setup_intent.payment_method},
)
here I need to pass it
Id of the payment method is like "pm_...." right?
yeah
ah, it has.
my fault.
I only got "card" obeject form array of payment method
it dind't have it
got it.
Thanks a lot and sorry for a dummy question.
No problem!
Sure what is it?
how to delete card from customer then
stripe.PaymentMethod.detach(card_id)
tried with this but I think this is wrong because it's not related to customer
That's correct. There's not really a way to delete a payment method, but detaching is what you want. It effectively deletes it. Detaching from a customer makes it unusable
yeah, but my question is
stripe.PaymentMethod.detach(card_id)
this doesn't have anything about detaching from whcih customer..
Well a payment method can only be attached to 1 customer
So it doesn't matter
We internally know which customer it's attached to already
If the goal is to detach it from the customer and make it unusable, yeah
cards = stripe.Customer.list_payment_methods(
AttributeError: type object 'Customer' has no attribute 'list_payment_methods'
?
You might be using an old version of the sdk
Which version of stripe-python do you have?
stripe==2.56.0
Ok try upgrading to 5.5.0 (latest)
it will not break many stuff right ๐
Is this a new integration or a large existing one?
Ah then yeah don't upgrade unless you've done thorough testing/review of breaking changes
That's an old version so I'm not sure the syntax for listing a customer's payment methods
Maybe you did have it right on that version
I already upgraded. we need to afford because too many version change on it
again, for origin question
list payment method will give id like "pm_.." right?
correct?
but for me, "id" is like "card_.."
Can I pass this id to modify customer's default payment method??
how?
Recommend you just try it
Cards are the older version
Our api has changed and we recommend creating payment methods now not cards
But you can still use the older card objects
I'm testing for my migration
so not using old api
session = stripe.checkout.Session.create(
payment_method_types=['card'],
mode='setup',
customer=stripe_customer.id,
# setup_intent_data={
# },
success_url=os.getenv('BACKEND_HOST') + '/api/execute-add-card-stripe-session/?session_id={CHECKOUT_SESSION_ID}',
cancel_url=os.getenv('BACKEND_HOST') + '/api/cancel-add-card-stripe-session/'
)
card is added with this code
Am I wrong?
it's been added by creating checkout session as above code
and it's added 'card'
so , I dont' understand. I'm still on old way?
?
your api example shows id="pm_..."
in my test, id is always "card_..."
You can still pass card id to be default payment method
Your integration is fine
Can you paste that card id from your screenshot actually? Want to check something
this is test mode so test cards
424242424242..
and
5555 5555 5555 4444
do you need anything else more?
Those aren't card id's
or card id?
Just send the card_123 id from the screenshot here #1136327518341845063 message
card_1NKfFGBTGnRwDyDi4ha0QQg6
pm_1Nai48BTGnRwDyDiWRrUFEKI
once user makes subscription with card, it will be added to customer by dfault right?
I think that case "id" will be "card_." not "pm_."
as I think
Ok. So looks like Stripe Checkout still creates Card objects not PaymentMethod objecst
That's fine though, Card objects can still be set as default PM for subscriptions
Yes but not set as default PM
for me, for customer (not for subscription
What do you mean?
not for
default payment method for subscription
it's for
default payment method for customer (stripe customer)
saying my purpose.
What's your question?
"That's fine though, Card objects can still be set as default PM for subscriptions"
you siad can still be set as default PM for subscription
we can set default payment method for subscription level, or customer level
so what I want is customer level
so just tackling your message to know exactly
yes, of course. but asked your document says 'id of payment method'
so don't wanted to pass card id there
if your doc is like 'id of payment method OR card id" then I would tried without asking ๐
now trying
will let you know soon result
Yeah, it works. thanks. I've recommended you to update your doc
thanks for your help again
No problem. That's helpful feedback