#mrr3dl1ne
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.
- mrredline-invoicepay-api, 1 hour ago, 16 messages
- mrr3dl1ne, 19 hours ago, 32 messages
Listing Payment Methods will only list PaymentMethod objects.
If you're working with Card objects and/or Source objects, you can retrieve a customer and look their default_source: https://stripe.com/docs/api/customers/object#customer_object-default_source
ok, what's the correct way to list all customer cards as well as show which is default?
ok, is there a way to use one call to get all their cards as well as default source?
or would I need two calls?
You can retrieve a customer and expand the sources property
ok thank you!
so here's my call: merchant_customer = self.stripe.Customer.retrieve(
billing_details.merchant_user_id,
expand=['sources']
)
but sources comes back as empty
"sources": {
"data": [],
"has_more": false,
"object": "list",
"total_count": 0,
"url": "/v1/customers/cus_PENdfvQr0jbWjM/sources"
I do show methods listed when viewing the customer
there's also no default source set
here's the full response
{ "address": null, "balance": 0, "created": 1703198290, "currency": "usd", "default_source": null, "delinquent": false, "description": null, "discount": null, "email": null, "id": "cus_PENdfvQr0jbWjM", "invoice_prefix": "E7C4E793", "invoice_settings": { "custom_fields": null, "default_payment_method": null, "footer": null, "rendering_options": null }, "livemode": false, "metadata": { "r3dlabs_user_id": "dc1976e8-9fb1-11ee-befd-0242ac120003" }, "name": null, "next_invoice_sequence": 10, "object": "customer", "phone": null, "preferred_locales": [], "shipping": null, "sources": { "data": [], "has_more": false, "object": "list", "total_count": 0, "url": "/v1/customers/cus_PENdfvQr0jbWjM/sources" }, "tax_exempt": "none", "test_clock": null }
Okay, so you will need to do this in two calls. stripe.Customer.list_payment_methods to list all PaymentMethods, and stripe.Customer.retrieve . If the customer's invoice_settings[default_payment_method] is empty, they don't have a default PaymentMethod set
ok, so help me understand the "setting a default payment" flow. I read that if there's only one card, it will be set as the default, is that not the case?
If I need to set it explicitly, how would I do that when using a SetupIntent?
My flow is:
- Customer fills out new payment method form and submits
- During the submit call my backend is called and creates the customer object on stripe, and then returns the setup intent to the front-end
- Front end uses the returned setupintent to complete adding the card
I never get the card id back because it happens on the front-end, so how should I then again update the customer object to set the default method?
Hi @proper seal I'm taking over this thread.
cool, hi Jack!
Once the setupIntent is confirmed successfully, you'll receive a payment_method.attached webhook event. In the event handler, you can set the payment_method to customer's invoice_settings[default_payment_method]