My users will enter their payment method information when they sign up, and our system will charge them each month. (We are not using subscriptions because the amount will depend on usage.)
Unfortunately, it doesn't appear that Stripe has a concept of a default payment method. Since customers can have more than one payment method, how do I figure out which payment method to use?
I'm sure there's an API to query all the payment methods for a given customer, but what if there's more than one? How are people handling this?
UPDATE:
I tried the following to set the default payment method on the invoice.
InvoiceService invoiceService = new();
InvoiceCreateOptions invoiceCreateOptions = new()
{
DefaultPaymentMethod = session.SetupIntent.PaymentMethodId,
Customer = customer.Id,
};
Invoice invoice = await invoiceService.CreateAsync(invoiceCreateOptions);
CustomerGetOptions customerGetOptions = new()
{
Expand = ["invoice_settings.default_payment_method"],
};
customer = await customerService.GetAsync(customer.Id, customerGetOptions);
However, the customer returned on the last line still has InvoiceSettings.DefaultPaymentMethod
/InvoiceSettings.DefaultPaymentMethodId
set to null.
Stripe uses the invoice_settings.default_payment_method
property on a Customer to determine the default PaymentMethod to use for Subscriptions and Invoices. You don't use Subscriptions but can still use this property to keep track of a default payment method for a Customer for those one-off charges if a Customer has more than one PaymentMethod.
As an aside, if you did want to use Subscriptions, Stripe has a concept of usage-based billing where Customers can be charged at the end of a billing cycle/in arrears for usage they have accrued.