stripe

// Set up a customer object var customer = await stripe.customers.create({ email: 'customer@example.com', });// Save the customer's payment method var paymentMethod = await stripe.paymentMethods.attach( 'pm_card_visa', {customer: customer.id}, );// Set the default payment method on the customer await stripe.customers.update(customer.id, { invoice_settings: { default_payment_method: paymentMethod.id, }, });// Create a subscription for the customer var subscription = await stripe.subscriptions.create({ customer: customer.id, items: [{plan: 'plan_123'}], expand: ['latest_invoice.payment_intent'], });

Leave a Reply