chargebee / chargebee-typescript

Typescript library for the Chargebee API.

Home Page:https://apidocs.chargebee.com/docs/api?lang=typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API won't return contract_term on estimate.change_term_end method

julianCast opened this issue · comments

When we estimate change_term_end we get a estimate object
which would include subscription_estimate which would include contract_term.

But the response never contains contract_term.

Use case: Customers wants to change their next billing date, so they want to know a estimated contract_term end date before updating it.

Sample call:

  async getSubscriptionBillingDateEstimate(params: {
    subscriptionId: string;
    nextBillingDay: number;
  }): Promise<ChargebeeEstimate> {
    const result = await chargebee.estimate
      .change_term_end(params.subscriptionId, {
        term_ends_at: params.nextBillingDay,
      })
      .request();
      console.log(result.estimate)
  }

Sample output:

Estimate {
  created_at: 1700037915,
  object: 'estimate',
  credit_note_estimates: [],
  subscription_estimate: SubscriptionEstimate {
    id: 'W4UB4zTpX9vVt3hc',
    status: 'active',
    next_billing_at: 1702598400,
    object: 'subscription_estimate',
    currency_code: 'EUR',
    shipping_address: ShippingAddress {
      first_name: 'John',
      last_name: 'doe',
      email: 'johndoe@domain.com',
      phone: '+34666666666,
      line1: 'line 1',
      city: 'City',
      country: 'CC',
      zip: '00000',
      validation_status: 'not_validated',
      object: 'shipping_address'
    }
  },

  invoice_estimate: InvoiceEstimate {},
  next_invoice_estimate: InvoiceEstimate {}
}