Skip to content

Instantly share code, notes, and snippets.

@dagingaa
Created February 5, 2020 08:42
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 dagingaa/87811b4ca30d6b3798d42c253746fcdb to your computer and use it in GitHub Desktop.
Save dagingaa/87811b4ca30d6b3798d42c253746fcdb to your computer and use it in GitHub Desktop.
Backdates a Stripe subscription without triggering proration. Probably the easiest way to undo a mistake if you ended up screwing something up royally and need to reset.
const stripe = require("stripe")("api_key");
const CUSTOMER = "";
const PLAN = "";
const quantity = 1;
const startTimeInSecondsSinceEpoch = 0;
const billingCycleAnchorInSecondsSinceEpoch = 0;
async function foo() {
const subscription = await stripe.subscriptions.create({
customer: CUSTOMER,
items: [{ plan: PLAN, quantity }],
backdate_start_date: startTimeInSecondsSinceEpoch,
billing_cycle_anchor: billingCycleAnchorInSecondsSinceEpoch,
proration_behavior: "none",
});
console.log(subscription.id);
}
foo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment