lmsqueezy/lemonsqueezy.js

Outdated method updateSubscription

Closed this issue · 3 comments

According to the docs, this function should take this parameters

{
  variant_id?: string; // The ID of the Variant you want to switch this subscription to. Required if changing a subscription's product/variant.
  pause?: {
    mode: 'void' | 'free';
    resumes_at?: string; // An ISO 8601 formatted date-time string indicating when the subscription will continue collecting payments.
  } | null; // You can set the pause object to null to unpause the subscription.

  cancelled?: boolean; // Set as true to cancel the subscription. Set to false to resume a subscription (before the ends_at date).

  trial_ends_at?: string; // An ISO 8601 formatted date-time string indicating when the subscription's free trial should end.

  billing_anchor?: number | null | 0; // Use an integer representing a day of the month (1-31) to change the day on which subscription invoice payments are collected. Use null or 0 to reset the billing anchor to the current date.

  invoice_immediately?: boolean; // If true, any updates to the subscription will be charged immediately. Defaults to false.

  disable_prorations?: boolean; // If true, no proration will be charged and the customer will simply be charged the new price at the next renewal. Defaults to false.
}

but it's

export type UpdateSubscription = Partial<{
  /**
   * The ID of the [Variant](https://docs.lemonsqueezy.com/api/variants) you want to switch this subscription to. Required if changing a subscription's product/variant.
   */
  variantId: number;
  /**
   * An object containing the payment collection pause behavior options for the subscription. Options include:
   *
   * - `mode` - Defines payment pause behavior, can be one of:
   *    - `void` - If you can't offer your services for a period of time (for maintenance as an example), you can void invoices so your customers aren't charged.
   *    - `free` - Offer your subscription services for free, whilst halting payment collection.
   * - `resumes_at` (optional) - An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) formatted date-time string indicating when the subscription will continue collecting payments.
   *
   * You can set the pause object to `null` to unpause the subscription.
   */
  pause: {
    mode: "void" | "free";
    resumesAt?: string | null;
  };
  /**
   * Set as `true` to cancel the subscription. You can resume a subscription (before the `ends_at` date) by setting this to `false`.
   */
  cancelled: boolean;
  /**
   * - Use an integer representing a day of the month (`21` equals `21st day of the month`) to change the day on which subscription invoice payments are collected.
   * - Use `null` or `0` to reset the billing anchor to the current date. Doing this will also remove an active trial.
   *
   * Setting this value to a valid integer (1-31) will set the billing anchor to the next occurrence of that day. For example, if on the 21st of January you set the subscription billing anchor to the 1st, the next occurrence of that day is February 1st. All invoices from that point on will be generated on the 1st of the month.
   *
   * If the current month doesn’t contain the day that matches your `billing_anchor` (for example, if the `billing_anchor` is 31 and the month is November), the customer will be charged on the last day of the month.
   *
   * When setting a new billing anchor day, we calculate the next occurrence and issue a paid, prorated trial which ends on the next occurrence date. When the trial ends, the customer is charged for the full prorated amount.
   */
  billingAnchor: number | null;
  /**
   * If `true`, any updates to the subscription will be charged immediately. A new prorated invoice will be generated and payment attempted. Defaults to `false`. Note that this will be overridden by the `disable_prorations` option if used.
   */
  invoiceImmediately: boolean;
  /**
   * If `true`, no proration will be charged and the customer will simply be charged the new price at the next renewal. Defaults to `false`. Note that this will override the `invoice_immediately` option if used.
   */
  disableProrations: boolean;
}>;

https://github.com/lmsqueezy/lemonsqueezy.js/blob/main/src/subscriptions/types.ts#L273

trial_ends_at is missing

trial_ends_at is missing

Hi, @jramosss.

See PR.

Resolved with #75