(stripeCustomerId: string)
| 49 | stripe.paymentMethods.detach(paymentMethodId); |
| 50 | |
| 51 | export async function getDefaultPaymentMethodId(stripeCustomerId: string) { |
| 52 | const customer = await stripe.customers.retrieve(stripeCustomerId); |
| 53 | |
| 54 | if (customer.deleted) { |
| 55 | return undefined; |
| 56 | } |
| 57 | |
| 58 | const paymentMethodId = customer.invoice_settings.default_payment_method; |
| 59 | if (!paymentMethodId || typeof paymentMethodId !== "string") { |
| 60 | return undefined; |
| 61 | } |
| 62 | |
| 63 | return paymentMethodId; |
| 64 | } |
| 65 | |
| 66 | export const setDefaultPaymentMethod = async (stripeCustomerId: string, paymentMethodId: string) => |
| 67 | stripe.customers.update(stripeCustomerId, { |
no outgoing calls
no test coverage detected