#andrew - list customer cards
1 messages ยท Page 1 of 1 (latest)
Are you using a payment method integration pattern?
If so, you'd list a customers payment method (saved cards) by specifying type=card in the list request:
https://stripe.com/docs/api/payment_methods/customer_list
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But there is no general concept of a default payment method. There is a customer invoice default payment method, used only for paying invoices:
https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-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.
Which you can set using one of the attached payment methods
So one time payment intents, you always need to provide a payment method id explicitly
Is the default label here in reference to the invoice default?
And yes, I'm using payment methods
It depends! If you're using the old "Sources" API it might be referring to the default_source, which behaves differently. This is why I asked which integration you used. Overall dashboard behaviour is a bit different and we should focus on the API. Which customer property are you looking at in the API?
So that should map to the invoice settings default PM, then
(if you don't use Sources)
yep I use payment methods as recommended by the latest guides
when I list the payment methods, how do I get it to include the customer?
it appears to be nil by default
stripePaymentMethod := i.PaymentMethod()
defaultStripePaymentMethodID := stripePaymentMethod.Customer.InvoiceSettings.DefaultPaymentMethod.ID
What does you list request look like?
Yea, that's null/nil until you set it explicitly
i := paymentmethod.List(&stripe.PaymentMethodListParams{
Type: stripe.String("card"),
Customer: stripe.String(customerFromDB.StripeCustomerID),
})
(the dashboard might have it's own default for dashboard payments, which is why i suggest not focusing too much on it)
stripePaymentMethod := i.PaymentMethod()
defaultStripePaymentMethodID :=
stripePaymentMethod.Customer.InvoiceSettings.DefaultPaymentMethod.ID
how do I get the Customer here in Go to be not nil
or actually all I know is I am getting a nil pointer dereference... I'll try to narrow down which thing is nil
Can you explain the flow you're using here, ie why you need to access this from the payment method? (vs requesting the customer directly)
Unless you use expansion, the customer on a payment method is just the ID, not the object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
We are showing a list of saved cards to the user and need to have the concept of a default and would prefer to leverage one of the existing defaults from Stripe if possible. I am building an endpoint that returns a list of cards and needs to indicate which is the default one.
Would it be more efficient to make one request for customer and then another for listing payment methods or to expand the customer on the payment methods list?
That's up to you! You can use the invoice default for this if you like, but remember you need to provide it explicitly on one time payment intents
in your list request you should be able to send expand[]=data.customer to get the full customer objects
but note you could also list the customers and get this for all of them (or up to 100 at a time)
Got it. I was planning to use the Stripe save card flow of the checkout flow... does that not by default assign one as the default?
No that's different, that's saving it for future Checkout session:
https://stripe.com/docs/payments/checkout/customization#link-with-stripe
Learn about the different ways you can customize your Stripe Checkout integration.
Alright I guess I'm confused. Backing up a sec, given I have customers in Stripe and want to save cards (including keeping track of the default card) and I am building a POS that leverages Stripe terminals, what should I be using?
Hi there! I'm stepping in for @shadow jetty as he needed to step away. Give me a moment to get caught up.
For context, I was thinking I'd use this: https://stripe.com/docs/payments/save-and-reuse?platform=checkout
Are you planning on saving cards based on card_present payments and then using those cards later on?
Yes that & also we want the clerks using the POS to be able to enter in credit card info to save for a customer
seems like for that I could use either elements or checkout
for context, I am trying to build a dashboard like this where it shows the cards and allows them to add new ones and set one as default
And you aren't planning on using Subscriptions/Invoices, correct?
Okay gotcha.
So if you are creating one-off payments without using invoices then a default payment method is no longer really a thing.
You would always pass the paymentmethod that you want to charge to the PaymentIntents API: https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method
However, for invoices you can use a default. You would set it as the customer's invoice_settings.default_payment_method: https://stripe.com/docs/api/customers/create#create_customer-invoice_settings-default_payment_method
Now in terms of the flows
There are two different flows.
One if you take a card via Terminal
For that you are going to want to take a look at the guide here: https://stripe.com/docs/terminal/features/saving-cards/overview
The other flow you are referring to for your clerks to enter CC details is what is referred to as MOTO.
That flow actually isn't a public flow and you will need to reach out to our Support team to get your account approved and configured to use that flow.
There's no public flow for saving a payment method to a customer?
Sure there is when the customer enters their credit card details in an online form.
But if your clerks are handling those details then the flow is different.
Gotcha. So I should just email support saying I need MOTO?
okay thanks
It is important to qualify these transactions correctly because otherwise they can trigger 3DS which your clerk can't complete
Then the transaction will fail.
ah okay understood! thanks for the tip
๐
once MOTO is enabled, do I still use the checkout or elements flows for saving a card?
No, there will be specific docs on how to collect card details with MOTO that will be provided to you once your account is approved for the feature.