#Stone.D-Customer

1 messages · Page 1 of 1 (latest)

modern citrus
true falcon
#

Customer customer = null;
customer = Customer.retrieve(userVo.getStripeCustomerId());

    PaymentMethod defaultPayment = null;
    if (customer.getInvoiceSettings() != null && customer.getInvoiceSettings().getDefaultPaymentMethod() != null) {
        defaultPayment = PaymentMethod.retrieve(customer.getInvoiceSettings().getDefaultPaymentMethod());
    }
#

tan 你好

#

这是我的代码,

#

但是这可能不是正确的,如果:我有两个支付方式,在Dashboard删掉默认的支付方式,使用Api获取不到Default payment

modern citrus
#

Hi @true falcon Let's continue conversations in English, so that my colleagues can easily follow-up when you need help and I'm not around.

#

Can you tell me what do you want to achieve here? are you trying to retrieve a payment method for subscription?

true falcon
#

ok,

#

I think the scenario: on the app side, after the user logs in, the payment method is displayed, and the default payment method is displayed on the interface.

#

No attempt was made to retrieve the payment method for the subscription

#

The above picture is the implemented interface, showing the list of payment methods and the default payment method

modern citrus
#

OK. Thanks for the context.

#

Your code looks OK to me.

true falcon
#

What's the difference between customer.getInvoiceSettings().getDefaultPaymentMethod() And default_source?

#

Which is the most reliable

modern citrus
#

Sources is the legacy API which is already replaced by PaymentMethods API. You shouldn't use it anymore.

#

It's just that the Stripe Dashboard is using the Sources API, that's why the payment method that you created via Dashboard is set to customer as the default_source

true falcon
#

OK, Thanks a lot.

#

💯 👍