Skip to content

Instantly share code, notes, and snippets.

@dagingaa
Created February 5, 2020 08:42
Show Gist options
  • Save dagingaa/87811b4ca30d6b3798d42c253746fcdb to your computer and use it in GitHub Desktop.
Save dagingaa/87811b4ca30d6b3798d42c253746fcdb to your computer and use it in GitHub Desktop.

Revisions

  1. dagingaa created this gist Feb 5, 2020.
    20 changes: 20 additions & 0 deletions backdateStripeSubscription.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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();