#elBR

1 messages · Page 1 of 1 (latest)

sudden echoBOT
cloud lagoon
#

Hi there!

#

PaymentMethods object (pm_xxx) is the newest and recommended way to handle payment methods. Cards (card_xxx) also works, but it's older.

#

You can use both pm_xxx and card_xxx to accept payments.

radiant mural
#

there is another one source_xxx

#

what about that?

cloud lagoon
#

That's an even older integration.

#

What exactly are you trying to achieve here?

radiant mural
#

the problem is that I see different types of cards created during the flow

#

when I create a payment method directyle it gets created as card_xxx

#

when the card is created along with a subscription create is gets created as pm_xxx

#

when I pay an one-off invoice it gets created as source_xxx

#

the problem is that I cannot get the default payment method

#

when I check for default source and the card is pm_xxx I get an error saying that the source does not exist

#

If I use default payment method and the default is a source_xxx I get no default as a result

#

is really a mess

#

can you please give me a solution on how can I determine the default card?

cloud lagoon
#

Thanks for the additional information. There are two places to check on the customer object:

  • invoice_settings.default_payment_method, that could either contain a pm_xxx or a card_xxx
  • source, that could contain a src_xxx
radiant mural
#

I should call all the two APIs?

#

what approach does Stripe use on dashboard for fetching the default payment method?

#

does they call two API on themselves?

cloud lagoon
radiant mural
#

no I am not asking that

#

I am asking how can I check user's default payment method

#

what API endpoint should I call?

#

to get the default payment method, ignoring the fact that i can have card_xxx, pm_xxx, source_xxx

cloud lagoon
#

You need to check two things: the source of the customer and the invoice_settings.default_payment_method. You can get both with one API call.

radiant mural
#

no, this is the problem

#

If I use that and user has the default card with source_xxx, I will get nothing as user's default card

#

invoice_settings.default_payment_method will ignore payment methods that has the id source_xxx or card_xxx

cloud lagoon
#

I'm sorry I don't understand the issue.

  • If a customer has a source_xxx, then just check customer.source to find it.
  • And if the customer doesn't have a source, check invoice_settings.default_payment_method to find a pm_xxx or card_xxx.
    Note that it's also possible for customers to have no default payment method set.
radiant mural
#

but since default payement method is unique between all type of cards, why should I check invoice_settings.default_payment_method as well as customer.source

#

isn't there any api endpint that would give me the default one

#

I am curious to know, what API call does Stripe use on dashboard to show the default payment method?

cloud lagoon
#

why should I check invoice_settings.default_payment_method as well as customer.source
I agree this is not ideal. but if your integration is using both pm_xxx and source_xxx, then you need to check both places.

#

Don't know exactly how the dashboard works, but they probably do the same thing: check both source and invoice_settings.default_payment_method. Both can be done in one API call.

radiant mural
#

ok

#

I have another question on general

#

what approach should I use to create a payment method

#

I have a backend and a frontend

#

Currently I create a setupintent on by backend and then I confirm that on frontend

#

should I create it directly on froneted using createPaymentMethod?

#

this one?

#

is the flow that I follow is better?

cloud lagoon
#

Currently I create a setupintent on by backend and then I confirm that on frontend
This is the recommended flow.

radiant mural
#

is it true that if I create a subscription and I pay the invoice on Stripe, the card gets created as src_xxx?

fallow onyx
#

👋 taking over for my colleague. Let me catch up.

radiant mural
#

please let me know

#

Stripe used 2 kinds of defaults, just checked

#

it used default_source and default_payment method

#

so custoer can have two default cards on the same time

fallow onyx
#

quick question how are you settling the invoice? are you using Charge automatically or Send Invoice?

radiant mural
#

I am paying the invoice manually on Stripe

fallow onyx
#

how exactly? on the dashboard or on the Hosted Invoice Page?

radiant mural
#

here

fallow onyx
#

so you're using the Hosted Invoice Page

#

that's why you're seeing the src_xxx objects

#

since this product still uses Sources for the most part and card_xxx for the any invoice paid with a card

radiant mural
#

Buy why Stripe is using so many card types that are confusing

#

now I have a strange problem

#

I have these 4 payement methods

#

as long as I use Stripe Dashboard to make a payment method as default, then after I fetch payment methods on my application I get all payment methods with invoice_settings.default_payment_method: null

#

instead if I run the api call from my application and update invoice_settings.default_payment_method then everything works fine

#

why if I choose the default card on Stripe Dashboard makes invoice_settings.default_payment_method: null for all payment methods

#

this is weird

#

customer_id: cus_MhHyeFwtBvmEOC

#

this is the customer I am using

fallow onyx
#

first let's get a couple of things clear here, Hosted Invoice Page isn't the Stripe Dashboard (just to avoid the confusion)
and the "Default" you see here isn't the invoice_settings.default_payment_method but instead the default_source on the customer object

#

does that answer your Q?

#

fyi
this card was created through the dashboard hence the card_xxx https://dashboard.stripe.com/test/logs/req_cjTEMyXjpoelHZ
whereas this card was created through the Hosted Invoice Page hence the src_xxx
https://dashboard.stripe.com/test/logs/req_aOTEO6KTScL8vi