Skip to content

Instantly share code, notes, and snippets.

@guanzo
Last active November 30, 2023 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guanzo/f134245cee5871d9f3e7e758742ff44f to your computer and use it in GitHub Desktop.
Save guanzo/f134245cee5871d9f3e7e758742ff44f to your computer and use it in GitHub Desktop.
const res = await stripe.subscriptions.update(subscriptions[0].id, {
default_payment_method: paymentMethods[0].id,
billing_cycle_anchor: 'unchanged',
proration_behavior:'always_invoice',
items: [
...subscriptions[0].items.data.map((item) => ({
id: item.id,
deleted: true,
clear_usage:
item.plan.usage_type === 'metered' ? true : undefined,
})),
{
price: opts.input.priceId,
},
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment