#andrew - list customer cards

1 messages ยท Page 1 of 1 (latest)

shadow jetty
#

Are you using a payment method integration pattern?

#

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

marble isle
#

Is the default label here in reference to the invoice default?

#

And yes, I'm using payment methods

shadow jetty
#

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)

marble isle
#

yep I use payment methods as recommended by the latest guides

shadow jetty
#

๐Ÿ‘

#

You should retrieve the customer from teh API then and inspect that attribute

marble isle
#

when I list the payment methods, how do I get it to include the customer?

#

it appears to be nil by default

shadow jetty
#

What does you list request look like?

#

Yea, that's null/nil until you set it explicitly

marble isle
#
i := paymentmethod.List(&stripe.PaymentMethodListParams{
        Type:     stripe.String("card"),
        Customer: stripe.String(customerFromDB.StripeCustomerID),
    })
shadow jetty
#

(the dashboard might have it's own default for dashboard payments, which is why i suggest not focusing too much on it)

marble isle
#
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

shadow jetty
#

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

marble isle
#

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?

shadow jetty
#

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)

marble isle
#

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?

shadow jetty
marble isle
#

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?

grim gyro
#

Hi there! I'm stepping in for @shadow jetty as he needed to step away. Give me a moment to get caught up.

marble isle
grim gyro
#

Are you planning on saving cards based on card_present payments and then using those cards later on?

marble isle
#

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

grim gyro
#

And you aren't planning on using Subscriptions/Invoices, correct?

marble isle
#

No subscriptions, but maybe invoices

#

almost certainly invoices

grim gyro
#

Okay gotcha.

#

So if you are creating one-off payments without using invoices then a default payment method is no longer really a thing.

#

Now in terms of the flows

#

There are two different flows.

#

One if you take a card via Terminal

#

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.

marble isle
#

There's no public flow for saving a payment method to a customer?

grim gyro
#

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.

marble isle
#

Gotcha. So I should just email support saying I need MOTO?

marble isle
#

okay thanks

grim gyro
#

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.

marble isle
#

ah okay understood! thanks for the tip

grim gyro
#

๐Ÿ‘

marble isle
#

once MOTO is enabled, do I still use the checkout or elements flows for saving a card?

grim gyro
#

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.

marble isle
#

great!

#

thanks for all your help @grim gyro I really appreciate it