# Charge addon at term end

> For the complete machine-readable documentation index, see [llms.txt](https://apidocs.chargebee.com/llms.txt).


[Idempotency Supported](/docs/api/v2/pcv-1/idempotency)

Adds a "non-recurring addon" charge to a subscription which will be added to the invoice generated at the end of the current term. If there are any applicable coupons in the subscription, an appropriate discount will be applied.

To collect the charges for the non-recurring addon immediately, [use this API](/docs/api/v2/pcv-1/invoices/create-invoice-for-a-non-recurring-addon).

If any subscription changes happen before the end of the current term, these charges will be collected along with it.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/subscriptions/__test__KyVnHhSBWkfvE2Rn/charge_addon_at_term_end \
     -u {site_api_key}:\
     -d addon_id="non_recurring_addon" \
     -d addon_quantity=3 \
     -d addon_unit_price=100
```

#### .NET

```dotnet
using ChargeBee.Api;
using ChargeBee.Models;

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Subscription.ChargeAddonAtTermEnd("__test__KyVnHhSBWkfvE2Rn")
		.AddonId("non_recurring_addon")
		.AddonQuantity(3)
		.AddonUnitPrice(100)
		.Request();

Estimate estimate = result.Estimate;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    subscriptionAction "github.com/chargebee/chargebee-go/v3/actions/subscription"
    "github.com/chargebee/chargebee-go/v3/models/subscription"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := subscriptionAction.ChargeAddonAtTermEnd("__test__KyVnHhSBWkfvE2Rn", &subscription.ChargeAddonAtTermEndRequestParams{
        AddonId : "non_recurring_addon",
        AddonQuantity : chargebee.Int32(3),
        AddonUnitPrice : chargebee.Int64(100),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Estimate := res.Estimate
    }
}
```

#### Go

```go
package main

import (
  "fmt"
  "github.com/chargebee/chargebee-go/v4"
)

func main() {
  config := &chargebee.ClientConfig{
    SiteName: "{site}",
    ApiKey: "{site_api_key}",
  }    
  client := chargebee.NewClient(config)
  req := &chargebee.SubscriptionChargeAddonAtTermEndRequest{
    AddonId : "non_recurring_addon",
    AddonQuantity : chargebee.Int32(3),
    AddonUnitPrice : chargebee.Int64(100),
}
  res, err := client.Subscription.ChargeAddonAtTermEnd("__test__KyVnHhSBWkfvE2Rn", req)
      if err != nil {
        fmt.Println(err)
    } else {
        Estimate := res.Estimate
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Subscription.chargeAddonAtTermEnd("__test__KyVnHhSBWkfvE2Rn")
            .addonId("non_recurring_addon")
            .addonQuantity(3)
            .addonUnitPrice(100L)
            .request();

        Estimate estimate = result.estimate();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.estimate.Estimate;
import com.chargebee.v4.models.subscription.params.SubscriptionChargeAddonAtTermEndParams;
import com.chargebee.v4.models.subscription.responses.SubscriptionChargeAddonAtTermEndResponse;

public class SubscriptionChargeAddonAtTermEnd {

    public static void main(String[] args) {
        ChargebeeClient client = ChargebeeClient.builder()
            .apiKey("{site_api_key}")
            .siteName("{site}")
            .build();

        SubscriptionChargeAddonAtTermEndParams params = SubscriptionChargeAddonAtTermEndParams.builder()
            .addonId("non_recurring_addon")
            .addonQuantity(3)
            .addonUnitPrice(100L)
            .build();

        SubscriptionChargeAddonAtTermEndResponse response = client
            .subscriptions()
            .chargeAddonAtTermEnd("__test__KyVnHhSBWkfvE2Rn", params);

        Estimate estimate = response.getEstimate();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

const chargebee = new Chargebee({
    site: "{site}",
    apiKey: "{site_api_key}",
});

try {
    const result = await chargebee.subscription.chargeAddonAtTermEnd("__test__KyVnHhSBWkfvE2Rn", {
        addon_id: "non_recurring_addon",
        addon_quantity: 3,
        addon_unit_price: 100
    });

    console.log(result);
    const estimate = result.estimate;
} catch (err) {
    console.log(err);
}
```

#### PHP

```php
<?php

require __DIR__ . '/vendor/autoload.php';

use Chargebee\ChargebeeClient;

$chargebee = new ChargebeeClient(options: [
    "site" => "{site}",
    "apiKey" => "{site_api_key}",
]);
$result = $chargebee->subscription()->chargeAddonAtTermEnd("__test__KyVnHhSBWkfvE2Rn", [
    "addon_id" => "non_recurring_addon",
    "addon_quantity" => 3,
    "addon_unit_price" => 100
]);
$estimate = $result->estimate;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Subscription.charge_addon_at_term_end("__test__KyVnHhSBWkfvE2Rn",
    cb_client.Subscription.ChargeAddonAtTermEndParams(
        addon_id="non_recurring_addon",
        addon_quantity=3,
        addon_unit_price=100
    )
)
estimate = response.estimate
```

#### Ruby

```ruby
require 'chargebee'

ChargeBee.configure(:site => "{site}",
  :api_key => "{site_api_key}")

result = ChargeBee::Subscription.charge_addon_at_term_end("__test__KyVnHhSBWkfvE2Rn",{
  :addon_id => "non_recurring_addon",
  :addon_quantity => 3,
  :addon_unit_price => 100
})

estimate = result.estimate
```

## Sample Response

```json
{
  "estimate": {
    "created_at": 1517505625,
    "invoice_estimate": {
      "amount_due": 1195,
      "amount_paid": 0,
      "credits_applied": 0,
      "currency_code": "USD",
      "customer_id": "__test__KyVnHhSBWkfvE2Rn",
      "line_item_discounts": {},
      "line_item_taxes": {},
      "line_items": [
        {
          "amount": 300,
          "customer_id": "__test__KyVnHhSBWkfvE2Rn",
          "date_from": 1517505624,
          "date_to": 1517505624,
          "description": "non_recurring_addon",
          "discount_amount": 0,
          "entity_id": "non_recurring_addon",
          "entity_type": "addon",
          "id": "li___test__KyVnHhSBWkg3f2Ru",
          "is_taxed": false,
          "item_level_discount_amount": 0,
          "object": "line_item",
          "pricing_model": "per_unit",
          "quantity": 3,
          "subscription_id": "__test__KyVnHhSBWkfvE2Rn",
          "tax_amount": 0,
          "unit_amount": 100
        },
        {..}
      ],
      "object": "invoice_estimate",
      "price_type": "tax_exclusive",
      "recurring": true,
      "round_off_amount": 0,
      "sub_total": 1195,
      "taxes": {},
      "total": 1195
    },
    "object": "estimate",
    "subscription_estimate": {
      "currency_code": "USD",
      "id": "__test__KyVnHhSBWkfvE2Rn",
      "next_billing_at": 1519924824,
      "object": "subscription_estimate",
      "status": "active"
    }
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/subscriptions/{subscription-id}/charge_addon_at_term_end

## Input Parameters

- `addon_id` (required, string, max chars=100)
  The ID of the non-recurring addon to be charged.

- `addon_quantity` (optional, integer, min=1)
  The number of addon units to be charged. Mandatory for quantity based addons.

- `addon_unit_price` (optional, in cents, min=0)
  Amount that will override the Addon's default price. The unit depends on the [type of currency](/docs/api/getting-started) .

- `addon_quantity_in_decimal` (optional, string, max chars=33)
  The decimal representation of the quantity of the [non-recurring addon](https://www.chargebee.com/docs/charges.html#non-recurring-addon ). Provide the value in major units of the currency. Must be provided when the addon is quantity-based. This parameter can only be passed when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.

- `addon_unit_price_in_decimal` (optional, string, default=Addon Amount in Decimal, max chars=39)
  When [price overriding](http://chargebee.com/docs/price-override.html ) is enabled for the site, the price or per-unit price of the [non-recurring addon](https://www.chargebee.com/docs/charges.html#non-recurring-addon ) can be set here. The value [set for the addon](/docs/api/v2/pcv-1/addons/addon-object#price) is used by default. Provide the value as a decimal string in major units of the currency. This parameter can only be passed when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.

- `date_from` (optional, timestamp(UTC) in seconds)
  The time when the service period for the addon starts.

- `date_to` (optional, timestamp(UTC) in seconds)
  The time when the service period for the addon ends.

## Returns

- `estimate` (Estimate object)
  Resource object representing estimate
