Hierarchy

Constructors

Methods

  • Cancel a scheduled downgrade.

    Returns Promise<string>

    Success message.

    Throws

    If the subscription has no schedule.

  • Cancel the last pending operation if the payment has failed.

    Works for subscription upgrade operations and not for recurring payment errors.

    Returns Promise<string>

    Success message.

    Throws

    If there's no pending payment.

  • Check if a coupon is valid by its promo code.

    Parameters

    • Optional code: string

      Customer-facing code for the coupon (promo code).

    Returns Promise<BillingCoupon>

    Throws

    If the coupon code is not valid or not found.

    Throws

    If coupon is specific to a an account.

    Throws

    If coupon can only be applied to new subscriptions.

  • Edit the resource allocation for the profiles in an account.

    The resource allocation array doesn't need to have an object for each of the account's profiles, as long as the sum of the allocated amounts for the services doesn't exceed the account's service limit.

    The resource allocation object for a profile doesn't need to have all the services.

    Parameters

    Returns Promise<string>

    Success message.

    Throws

    If passed an object that is not an allocation array.

    Throws

    If the account only has one profile.

    Throws

    If one of the profile IDs in the allocation array doesn't exist in the account.

    Throws

    If the allocated amount for one of the services exceeds the available amount.

  • Edit an account's billing information.

    Parameters

    • billingInformation: Partial<Omit<BillingInformation, "updated_at" | "account" | "payment_method">>

      Data to be updated in the account's billing information.

    Returns Promise<string>

  • Edit an account's payment method.

    Parameters

    • stripeCardToken: string

      Token for the new payment method added via Stripe API.

    Returns Promise<string>

    Success or error message.

    Throws

    If token is invalid or Stripe can't create the payment method with it.

  • Edit an account's subscription to change plan, services or add-ons.

    Only one of either plan, services, or addons can be in subscription.

    Parameters

    Returns Promise<void>

    Throws

    If the subscription has a pending operation.

    Throws

    If updating more than one of plan, services and add-ons at the same time.

    Throws

    If purchasing add-ons or changing service limits on the Free plan.

    Throws

    If using an invalid coupon.

  • Get the payment history for an account.

    The route uses pagination and the lastId parameter should be the stripe_id parameter from the last history entry.

    Parameters

    • Optional queryObj: {
          amount?: number;
          lastId?: string;
      }

      Object to configure the amount of entries fetched and the ID of the history entry for pagination.

      • Optional amount?: number
      • Optional lastId?: string

    Returns Promise<BillingPaymentHistoryEntry[]>

    Array with payment history entries or an empty array when no entries are available.

    Throws

    If lastId is passed and is invalid.

  • Get information for the account subscription schedule for downgrades.

    In the response, subscription reflects how the entire subscription will look at the end of the billing cycle when the downgrade is applied. If there is a scheduled downgrade for either plan, services or add-ons, everything is returned and not only the changes.

    Returns Promise<BillingSchedule>

  • Remove an account's payment method from the Stripe subscription.

    Only removes the card if the account is on the Free plan or if it has enough credit balance.

    Returns Promise<string>

    Success or error message.

    Throws

    If subscription is active with an upcoming invoice.

    Throws

    If account doesn't have a payment method.

  • Retry payment for an operation where the payment was unsuccessful.

    Works for payment errors in recurring payments or in subscription upgrade operations.

    Returns Promise<string>

    Success message.

    Throws

    If account has no subscription.

    Throws

    If there's no pending payment.

    Throws

    If payment method is declined or for other payment processing errors.