# Create checkout to update a subscription

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


[Idempotency Supported](/docs/api/idempotency)

Create a Chargebee hosted page to accept payment details from a customer and checkout to update the subscription.

The following steps describe how best to use this API:

Provide [item prices](/docs/api/item_prices), [coupons](/docs/api/coupons) and a host of other details such as billing and shipping addresses to be prefilled for the customer on the checkout page. You may also provide `pass_thru_content` containing information and IDs from your systems that must be associated with the checkout page.

**Warning** The first item price in the list (parameter `subscription_items[item_price_id][0]`) must be an `item_price` of [item\_type](/docs/api/item_prices/item_price-object#item_type) `plan`.

-   Send the customer to the Checkout `url` received in the response. They can now add a payment method or use an existing one, to complete the checkout.
    
-   The subscription is updated and the customer is redirected to the `redirect_url` with the `id` and `state` attributes passed as query string parameters.  
    Although the customer will be redirected to the `redirect_url` after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as `[subscription_created](/docs/api/events)` or `[invoice_generated](/docs/api/events)` to verify a successful checkout.
    
-   [Retrieve the hosted page](/docs/api/hosted_pages/retrieve-a-hosted-page) at this stage to get the subscription and invoice details.
    

### Impacts

**

#### Subscription and Ramps: Impact on existing scheduled changes[](#subscription-and-ramps-impact-on-existing-scheduled-changes)

**

-   If the subscription has existing scheduled changes, the behavior depends on whether [Ramps](/docs/api/ramps) are enabled:
    -   **Ramps disabled**: Any existing scheduled change on the subscription is deleted.
    -   **Ramps enabled with compatibility mode**:
        -   If only one ramp is present:
            -   If the ramp was created using this API, the ramp is deleted.
            -   If the ramp was created using the [Create a ramp API](/docs/api/ramps/create-a-ramp), and the date-time of the new change is before the date-time of the ramp, then the ramp is moved to `draft` status if the [auto-draft conditions](/docs/api/ramps/ramp-object#auto-draft) are met.
        -   If multiple ramps are present: all ramps after the date-time of the new change are moved to `draft` status if the [auto-draft conditions](/docs/api/ramps/ramp-object#auto-draft) are met.
-   For more details, see [Ramps API compatibility mode](/docs/api/subscriptions#ramps-compat-mode).

### Use Cases

#### Edit billing address[](#edit-billing-address)

If the [`billing_address`](/docs/api/customers#billing_address) attribute for the `customer` resource is already set, then the `billing_address` cannot be edited by the user during the Checkout session. To allow customers to update their billing address, use one of the following options:

##### Chargebee Hosted Pages[](#chargebee-hosted-pages)

-   Integrate [Chargebee.js](https://www.chargebee.com/checkout-portal-docs/cbportal-api-ref.html) into your website or application. Use the [`openSection()`](https://www.chargebee.com/checkout-portal-docs/cbportal-api-ref.html#opensection-options-callbacks) function with `options.sectionType` set to `ADDRESS` to display the Customer Portal's address section.
-   Integrate the [Customer Portal](https://www.chargebee.com/docs/billing/2.0/hosted-capabilities/portal-integration) into your website or application. The Portal enables customers to manage their address information.

##### Customer API[](#customer-api)

-   Use the [Update billing info API](/docs/api/customers/update-billing-info-for-a-customer) and provide the appropriate `billing_address` parameters.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_existing_for_items \
     -u {site_api_key}:\
     -d "subscription[id]"="__test__KyVnGWS4EgP3HA" \
     -d "subscription_items[item_price_id][0]"="basic-USD" \
     -d "subscription_items[quantity][0]"=4 \
     -d "subscription_items[unit_price][0]"=1000
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.CheckoutExistingForItems()
		.SubscriptionId("__test__KyVnGWS4EgP3HA")
		.SubscriptionItemItemPriceId(0, "basic-USD")
		.SubscriptionItemQuantity(0, 4)
		.SubscriptionItemUnitPrice(0, 1000)
		.Request();

HostedPage hostedPage = result.HostedPage;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    hostedpageAction "github.com/chargebee/chargebee-go/v3/actions/hostedpage"
    "github.com/chargebee/chargebee-go/v3/models/hostedpage"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := hostedpageAction.CheckoutExistingForItems(&hostedpage.CheckoutExistingForItemsRequestParams{
        SubscriptionItems : []*hostedpage.CheckoutExistingForItemsSubscriptionItemParams{
            {
                ItemPriceId : "basic-USD",
                Quantity : chargebee.Int32(4),
                UnitPrice : chargebee.Int64(1000),
            },
        },
        Subscription : &hostedpage.CheckoutExistingForItemsSubscriptionParams{
            Id : "__test__KyVnGWS4EgP3HA",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        HostedPage := res.HostedPage
    }
}
```

#### 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.HostedPageCheckoutExistingForItemsRequest{
    SubscriptionItems : []*chargebee.HostedPageCheckoutExistingForItemsSubscriptionItem{
        {
            ItemPriceId : "basic-USD",
            Quantity : chargebee.Int32(4),
            UnitPrice : chargebee.Int64(1000),
        },
    },
    Subscription : &chargebee.HostedPageCheckoutExistingForItemsSubscription{
        Id : "__test__KyVnGWS4EgP3HA",
    },
}
  res, err := client.HostedPage.CheckoutExistingForItems(req)
      if err != nil {
        fmt.Println(err)
    } else {
        HostedPage := res.HostedPage
    }
}
```

#### 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 = HostedPage.checkoutExistingForItems()
            .subscriptionId("__test__KyVnGWS4EgP3HA")
            .subscriptionItemItemPriceId(0, "basic-USD")
            .subscriptionItemQuantity(0, 4)
            .subscriptionItemUnitPrice(0, 1000L)
            .request();

        HostedPage hostedPage = result.hostedPage();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.hostedPage.HostedPage;
import com.chargebee.v4.models.hostedPage.params.HostedPageCheckoutExistingForItemsParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageCheckoutExistingForItemsResponse;
import java.util.List;

public class HostedPageCheckoutExistingForItems {

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

        HostedPageCheckoutExistingForItemsParams.SubscriptionParams subscriptionParams =
            HostedPageCheckoutExistingForItemsParams.SubscriptionParams.builder()
                .id("__test__KyVnGWS4EgP3HA")
                .build();

        HostedPageCheckoutExistingForItemsParams.SubscriptionItemsParams subscriptionItem0 =
            HostedPageCheckoutExistingForItemsParams.SubscriptionItemsParams.builder()
                .itemPriceId("basic-USD")
                .quantity(4)
                .unitPrice(1000L)
                .build();

        List<HostedPageCheckoutExistingForItemsParams.SubscriptionItemsParams> subscriptionItemsList =
            List.of(subscriptionItem0);

        HostedPageCheckoutExistingForItemsParams params = HostedPageCheckoutExistingForItemsParams.builder()
            .subscription(subscriptionParams)
            .subscriptionItems(subscriptionItemsList)
            .build();

        HostedPageCheckoutExistingForItemsResponse response = client.hostedPages().checkoutExistingForItems(params);

        HostedPage hostedPage = response.getHostedPage();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.hostedPage.checkoutExistingForItems({
        subscription_items: [
            {
                item_price_id: "basic-USD",
                quantity: 4,
                unit_price: 1000
            }
        ],
        subscription: {
            id: "__test__KyVnGWS4EgP3HA"
        }
    });

    console.log(result);
    const hostedPage = result.hosted_page;
} 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->hostedPage()->checkoutExistingForItems([
    "subscription_items" => [
        [
            "item_price_id" => "basic-USD",
            "quantity" => 4,
            "unit_price" => 1000
        ]
    ],
    "subscription" => [
        "id" => "__test__KyVnGWS4EgP3HA"
    ]
]);
$hostedPage = $result->hosted_page;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.HostedPage.checkout_existing_for_items(
    cb_client.HostedPage.CheckoutExistingForItemsParams(
        subscription_items=[
            cb_client.HostedPage.CheckoutExistingForItemsSubscriptionItemParams(
              item_price_id="basic-USD",
              quantity=4,
              unit_price=1000
            )
        ],
        subscription=cb_client.HostedPage.CheckoutExistingForItemsSubscriptionParams(
            id="__test__KyVnGWS4EgP3HA"
        )
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::HostedPage.checkout_existing_for_items({
  :subscription => {
    :id => "__test__KyVnGWS4EgP3HA"
  },
  :subscription_items => [
    {
      :item_price_id => "basic-USD",
      :quantity => 4,
      :unit_price => 1000
    }
  ]
})

hosted_page = result.hosted_page
```

## Sample Response

```json
{
  "hosted_page": {
    "created_at": 1517478504,
    "embed": false,
    "expires_at": 1517482104,
    "id": "__test__lxYzKMHM7UcueYo6mZabybQOacdfXv7LtV",
    "layout": "in_app",
    "object": "hosted_page",
    "resource_version": 1517478504000,
    "state": "created",
    "type": "checkout_existing",
    "updated_at": 1517478504,
    "url": "https://yourapp.chargebee.com/pages/v4/__test__lxYzKMHM7UcueYo6mZabybQOacdfXv7LtV/"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/hosted_pages/checkout_existing_for_items

## Input Parameters

- `layout` (optional, enumerated string)
  Specifies the UI layout for the hosted page. This overrides [the layout](https://www.chargebee.com/docs/billing/2.0/hosted-capabilities/hosted-checkout#ui-layout-options) configured in Chargebee Billing.
  Possible enum values:
    - `in_app`
      Renders the hosted page in an in-app layout.
    - `full_page`
      Renders the hosted page in a full-page layout.

- `mandatory_items_to_remove` (optional, string, max chars=100)
  Item ids of [mandatorily attached addons](/docs/api/attached_items) that are to be removed from the subscription.

- `replace_items_list` (optional, boolean, default=false)
  If `true` then the existing `subscription_items` list for the subscription is replaced by the one provided. If `false` then the provided `subscription_items` list gets added to the existing list.

- `invoice_date` (optional, timestamp(UTC) in seconds)
  The document date displayed on the invoice PDF. The default value is the current date. Provide this value to backdate the invoice. Backdating an invoice is done for reasons such as booking revenue for a previous date or when the subscription is effective as of a past date. Moreover, if `create_pending_invoices` is set to `true` , and if the site is configured to set invoice dates to date of closing, then upon invoice closure, this date is changed to the invoice closing date. taxes and line\_item\_taxes are computed based on the tax configuration as of `invoice_date`. When passing this parameter, the following prerequisites must be met:
  
  -   `invoice_date` must be in the past.
  -   `invoice_date` is not more than one calendar month into the past. For example, if today is 13th January, then you cannot pass a value that is earlier than 13th December.
  -   It is not earlier than `changes_scheduled_at`, `reactivate_from`, or `trial_end`.
  -   `invoice_immediately` is `true`. .

- `billing_cycles` (optional, integer, min=0)
  Billing cycles set for plan-item price is used by default.

- `terms_to_charge` (optional, integer, min=1)
  The number of subscription billing cycles to [invoice in advance](https://www.chargebee.com/docs/advance-invoices.html). If a new term is started for the subscription due to this API call, then `terms_to_charge` is inclusive of this new term. See description for the `force_term_reset` parameter to learn more about when a subscription term is reset.

- `reactivate_from` (optional, timestamp(UTC) in seconds)
  If the subscription `status` is `cancelled` and it is being reactivated via this operation, this is the date/time at which the subscription should be reactivated. **Note:** It is recommended not to pass this parameter along with `changed_scheduled_at`. `reactivate_from` can be backdated (set to a value in the past). Use backdating when the subscription has been reactivated already but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
  
  -   Backdating must be enabled for subscription reactivation operations.
  -   The current day of the month does not exceed the limit set in Chargebee for backdating subscription change. This limit is the day of the month by which the accounting for the previous month must be closed.
  -   The date is on or after the last date/time any of the product catalog items of the subscription were changed.
  -   The date is not more than duration X into the past where X is the billing period of the plan. For example, if the period of the plan in the subscription is 2 months and today is 14th April, `changes_scheduled_at` cannot be earlier than 14th February. .

- `billing_alignment_mode` (optional, enumerated string)
  Override the [billing alignment mode](https://www.chargebee.com/docs/calendar-billing.html#alignment-of-billing-date) chosen for the site for calendar billing. Only applicable when using calendar billing.
  Possible enum values:
    - `immediate`
      Subscription period will be aligned with the configured billing date immediately, with credits or charges raised accordingly..
    - `delayed`
      Subscription period will be aligned with the configured billing date at the next renewal.

- `coupon_ids` (optional, string, max chars=100)
  List of coupons to be applied to this subscription. You can provide coupon ids or [coupon codes](/docs/api/coupon_codes) .

- `replace_coupon_list` (optional, boolean, default=false)
  If `true` then the existing `coupon_ids` list for the subscription is replaced by the one provided. If `false` then the provided `coupon_ids` list gets added to the existing list.

- `reactivate` (optional, boolean)
  This parameter is only relevant for `cancelled` subscriptions. When set to `true` , it activates the canceled subscription; otherwise, subscription changes are applied without altering its `status`. Additionally, if not explicitly set and the `subscription_items` provided in the API differ from the existing items, the subscription will still be reactivated.

- `force_term_reset` (optional, boolean, default=false)
  **Note**: This parameter is relevant only for subscriptions with `status` of `active`, `non_renewing`, or `cancelled`.
  
  When you set this parameter to `true`, the subscription term resets to the date of the subscription change. By default, if you change the plan-item price to another with the same billing period, the subscription term remains unchanged. For example, if the subscription renews on the 28th of every month, it will continue to renew on the 28th after the change.
  
  **Note**: If the new plan-item price has a different billing period from the current plan-item price, the subscription term resets automatically, regardless of the value of `force_term_reset`.
  
  **Constraints** If you pass `force_term_reset`, you must also pass `invoice_usages` with the same value when **all** of the following site configuration settings are enabled:
  
  -   [Usage-based billing](https://www.chargebee.com/docs/billing/2.0/usage-based-billing/setting-up-usage-based-billing)
  -   Mid-term changes for usage-based items
  -   [Invoice and charge for usage-based items when a subscription is changing](https://www.chargebee.com/docs/billing/2.0/subscriptions/metered_billing#configuring-metered-billing)

- `change_option` (optional, enumerated string)
  Specifies when the subscription change takes effect.
  
  **See also**
  
  -   [Impacts on existing scheduled changes](/docs/api/subscriptions/update-subscription-for-items#impact-scheduled-changes).
  Possible enum values:
    - `immediately`
      The subscription change takes effect immediately.
    - `end_of_term`
      **Deprecated**  
      This option is deprecated; use the [Create a ramp API](/docs/api/ramps/create-a-ramp) instead.
      
      The change is carried out at the end of the current billing cycle of the subscription.
    - `specific_date`
      **Deprecated for scheduling changes**  
      This option is deprecated for scheduling changes to occur at a future date-time, use the [Create a ramp API](/docs/api/ramps/create-a-ramp) instead.
      
      Executes the change on a specified date. The change occurs as of the date-time defined in `changes_scheduled_at`.

- `changes_scheduled_at` (optional, timestamp(UTC) in seconds)
  The date-time at which the subscription change is to happen or has happened.
  
  **Required if**
  
  -   `change_option` is set to `specific_date`.
  
  **Deprecated for scheduling changes**
  
  -   Setting this parameter to a future date-time for scheduling changes is deprecated. Use the [Create a ramp API](/docs/api/ramps/create-a-ramp) instead.
  
  **Constraints**
  
  -   Do not pass this parameter along with `reactivate_from`.
  
  **Backdated changes**  
  `changes_scheduled_at`can be set to a value in the past. This is called backdating the subscription change and is performed when the subscription change has already been provisioned but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
  
  -   Backdating must be [enabled](https://www.chargebee.com/docs/billing/2.0/subscriptions/backdating#configuring-backdated-subscription-actions-and-invoicing) for subscription change operations.
  -   Only the following changes can be backdated:
      -   Changes in the recurring items or their prices.
      -   Addition of non-recurring items.
  -   Subscription `status` is `active`, `cancelled`, or `non_renewing`.
  -   The current day of the month does not exceed the limit set in Chargebee for backdating subscription change. This limit is typically the day of the month by which the accounting for the previous month must be closed.
  -   The date is on or after `current_term_start`.
  -   The date is on or after the last date/time any of the following changes were made:
      -   Changes in the recurring items or their prices.
      -   Addition of non-recurring items.

- `invoice_usages` (optional, boolean, default=false)
  Setting this attribute to `true` will invoice the overages for the metered items during the subscription change.
  
  **Constraints** If you pass `invoice_usages`, you must also pass `force_term_reset` with the same value when **all** of the following site configuration settings are enabled:
  
  -   [Usage-based billing](https://www.chargebee.com/docs/billing/2.0/usage-based-billing/setting-up-usage-based-billing)
  -   Mid-term changes for usage-based items
  -   [Invoice and charge for usage-based items when a subscription is changing](https://www.chargebee.com/docs/billing/2.0/subscriptions/metered_billing#configuring-metered-billing)

- `redirect_url` (optional, string, max chars=250)
  The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL.
  
  **Note** :
  
  -   Although the customer will be redirected to the `redirect_url` after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons such as user closing the tab, or exiting the browser, and so on. If there is any synchronization that you are doing after the redirection, you will have to have a backup. Chargebee recommends listening to appropriate webhooks such as [`subscription_created`](/docs/api/events) or [`invoice_generated`](/docs/api/events) to verify a successful checkout.
  -   Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
  -   _Eg :_ _http://yoursite.com?id=\*\*&state=succeeded_
  -   This parameter is not applicable for iframe messaging.

- `cancel_url` (optional, string, max chars=250)
  The customers will be redirected to this URL upon canceling checkout. The hosted page id and state will be passed as parameters to this URL.
  
  **Note** : - Cancel URL configured in Settings > Hosted Pages Settings would be overriden by this cancel URL.  
  _Eg : http://yoursite.com?id=&state=cancelled_
  
  -   This parameter is not applicable for iframe messaging and [in-app](https://www.chargebee.com/docs/2.0/checkout.html) checkout.

- `pass_thru_content` (optional, string, max chars=2048)
  This attribute allows you to store custom information with the `hosted_page` object. You can use it to associate specific data with a hosted page session. For example, you can store the ID of the marketing campaign that initiated the user session. After a successful checkout, when the customer is redirected, you can retrieve the hosted page ID from the [redirect URL](/docs/api/hosted_pages/create-checkout-to-update-a-subscription#redirect_url)'s query parameters. Using this ID, you can fetch the hosted page and perform actions related to the success of the marketing campaign.

- `allow_offline_payment_methods` (optional, boolean)
  Allow the customer to select an offline payment method during checkout. The choice of payment methods can be configured via the Chargebee UI.

- `subscription` (optional, string)
  Parameters for subscription
  - `id` (required, string, max chars=50)
    A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
  - `start_date` (optional, timestamp(UTC) in seconds)
    The new start date of a `future` subscription. Applicable only for `future` subscriptions.
  - `trial_end` (optional, timestamp(UTC) in seconds)
    The time at which the trial has ended or will end for the subscription. This is only allowed when the subscription `status` is `future` , `in_trial` , or `cancelled`. Also, the value must not be earlier than `changes_scheduled_at` or `start_date`. **Note**: This parameter can be backdated (set to a value in the past) only when the subscription is in `cancelled` or `in_trial` `status`. Do this to keep a record of when the trial ended in case it ended at some point in the past. When `trial_end` is backdated, the subscription immediately goes into `active` or `non_renewing` status. This parameter overrides the [`item_price_trial_period`](/docs/api/item_prices/item_price-object#trial_period) directly.
  - `auto_collection` (optional, enumerated string)
    Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
    Possible enum values:
      - `on`
        Whenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.
      - `off`
        Automatic collection of charges will not be made for this subscription. Use this for offline payments.
  - `offline_payment_method` (optional, enumerated string)
    The preferred offline payment method for the subscription.
    Possible enum values:
      - `no_preference`
        No Preference
      - `cash`
        Cash
      - `check`
        Check
      - `bank_transfer`
        Bank Transfer
      - `ach_credit`
        ACH Credit
      - `sepa_credit`
        SEPA Credit
      - `boleto`
        Boleto
      - `us_automated_bank_transfer`
        US Automated Bank Transfer
      - `eu_automated_bank_transfer`
        EU Automated Bank Transfer
      - `uk_automated_bank_transfer`
        UK Automated Bank Transfer
      - `jp_automated_bank_transfer`
        JP Automated Bank Transfer
      - `mx_automated_bank_transfer`
        MX Automated Bank Transfer
      - `custom`
        Custom
  - `invoice_notes` (optional, string, max chars=2000)
    A customer-facing note added to all invoices associated with this subscription. This note is one among [all the notes](/docs/api/invoices/invoice-object#notes) displayed on the invoice PDF.
  - `contract_term_billing_cycle_on_renewal` (optional, integer, min=1, max=100)
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is the same as `billing_cycles` or a custom value depending on the [site configuration](https://www.chargebee.com/docs/contract-terms.html#configuring-contract-terms) .

- `customer` (optional, string)
  Parameters for customer
  - `vat_number` (optional, string, max chars=20)
    The VAT/tax registration number for the customer. For customers with `[billing_address](/docs/api/customers/customer-object#billing_address)`
    
    `country` as `XI` (which is **United Kingdom - Northern Ireland** ), the first two characters of the [full VAT number](https://en.wikipedia.org/wiki/VAT_identification_number) can be overridden by setting `[vat_number_prefix](/docs/api/customers/customer-object#vat_number_prefix)` .
  - `vat_number_prefix` (optional, string, max chars=10)
    An overridden value for the first two characters of the [full VAT number](https://en.wikipedia.org/wiki/VAT_identification_number). Only applicable specifically for customers with `[billing_address](/docs/api/customers/customer-object#billing_address)`
    
    `country` as `XI` (which is **United Kingdom - Northern Ireland** ).
    
    When you have enabled [EU VAT](https://www.chargebee.com/docs/eu-vat.html) in 2021 or have [manually enabled](https://www.chargebee.com/docs/brexit.html#what-needs-to-be-done-in-chargebee) the Brexit configuration, you have the option of setting `[billing_address](/docs/api/customers/customer-object#billing_address)`
    
    `country` as `XI`. That's the code for **United Kingdom - Northern Ireland**. The first two characters of the VAT number in such a case is `XI` by default. However, if the VAT number was registered in UK, the value should be `GB`. Set `vat_number_prefix` to `GB` for such cases.
  - `is_einvoice_enabled` (optional, boolean)
    Determines whether the customer is e-invoiced. When set to `true` or not set to any value, the customer is e-invoiced so long as e-invoicing is enabled for their country (`billing_address.country` ). When set to `false` , the customer is not e-invoiced even if e-invoicing is enabled for their country.
    
    **Tip:**
    
    It is possible to set a value for this flag even when E-Invoicing is disabled. However, it comes into effect only when E-Invoicing is enabled.
  - `entity_identifier_scheme` (optional, string, max chars=50)
    The Peppol BIS scheme associated with the `[vat_number](/docs/api/customers/customer-object#vat_number)` of the customer. This helps identify the specific type of customer entity. For example, `DE:VAT` is used for a German business entity while `DE:LWID45` is used for a German government entity. The value must be from the list of possible values and must correspond to the country provided under `billing_address.country`. See [list of possible values](https://www.chargebee.com/docs/e-invoicing.html#supported-countries) .
    
    **Tip:**
    
    If there are additional entity identifiers for the customer not associated with the `vat_number`, they can be provided as the `entity_identifiers[]` array.
  - `entity_identifier_standard` (optional, string, default=iso6523-actorid-upis, max chars=50)
    The standard used for specifying the `entity_identifier_scheme`. Currently only `iso6523-actorid-upis` is supported and is used by default when not provided.
    
    **Tip:**
    
    If there are additional entity identifiers for the customer not associated with the `vat_number`, they can be provided as the `entity_identifiers[]` array.

- `card` (optional, string)
  Parameters for card
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.

- `contract_term` (optional, enumerated string)
  Parameters for contract\_term
  - `action_at_term_end` (optional, enumerated string)
    Action to be taken when the contract term completes.
    Possible enum values:
      - `renew`
        -   Contract term completes and a new contract term is started for the number of billing cycles specified in [`contract_billing_cycle_on_renewal`](/docs/api/v2/pcv-1/subscriptions/create-subscription-for-customer#contract_term_billing_cycle_on_renewal).
        -   The `action_at_term_end` for the new contract term is set to `renew`.
      - `evergreen`
        Contract term completes and the subscription renews.
      - `cancel`
        Contract term completes and subscription is canceled.
  - `cancellation_cutoff_period` (optional, integer, default=0)
    The number of days before [`contract_end`](/docs/api/contract_terms/contract_term-object#contract_end) , during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.

- `subscription_items` (optional, array)
  Parameters for subscription\_items
  - `item_price_id` (required, string, max chars=100)
    The unique identifier of the item price. The first item price in the list (`subscription_items[item_price_id][0]` ) must be an `item_price` of [item\_type](/docs/api/item_prices/item_price-object#item_type) `plan` .
  - `quantity` (optional, integer)
    The quantity of the item purchased
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the item purchased. Can be provided for quantity-based item prices and only when [multi-decimal pricing](/docs/api/getting-started) is enabled.
  - `unit_price` (optional, in cents)
    The price/per unit price of the item. When not provided, [the value set](/docs/api/item_prices/item-price-object) for the item price is used. This is only applicable when the `pricing_model` of the item price is `flat_fee` or `per_unit`. Also, it is only allowed when [price overriding](https://www.chargebee.com/docs/price-override.html) is enabled for the site. The value depends on the type of currency. If `changes_scheduled_at` is in the past and a `unit_price` is not passed, then the item price's current unit price is considered even if the item price did not exist on the date as of when the change is scheduled.
  - `unit_price_in_decimal` (optional, string, max chars=39)
    When [price overriding](https://www.chargebee.com/docs/price-override.html) is enabled for the site, the price or per-unit price of the item can be set here. The [value set for the item price](/docs/api/item_prices/item_price-object#price) is used by default. Provide the value as a decimal string in major units of the currency. Can be provided only when [multi-decimal pricing](/docs/api/getting-started) is enabled. If `changes_scheduled_at` is in the past and a `unit_price_in_decimal` is not passed, then the item price's current unit price is considered even if the item price did not exist on the date as of when the change is scheduled.
  - `billing_cycles` (optional, integer)
    For the plan-item price: the value determines the number of billing cycles the subscription runs before canceling automatically. If not provided, then [the value set](/docs/api/item_prices/item-price-object) for the plan-item price is used.
    
    For addon-item prices: If [addon billing cycles](https://www.chargebee.com/docs/2.0/addons-billingcycle.html) are enabled then this is the number of subscription billing cycles for which the addon is included. If not provided, then [the value set under attached addons](/docs/api/attached_items/attached-item-object) is used. Further, if that value is not provided, then [the value set for the addon-item price](/docs/api/item_prices/item-price-object) is used.
  - `trial_end` (optional, timestamp(UTC) in seconds)
    The date/time when the trial period of the item ends. This applies to plan-items.
  - `service_period_days` (optional, integer)
    **Not supported**: This parameter is not supported in the API. If included in a request, it will be ignored.
  - `charge_on_event` (optional, enumerated string)
    When `charge_on_option` option is set to `on_event` , this parameter specifies the event at which the charge-item is applied to the subscription. This parameter only applies to charge-items.
    Possible enum values:
      - `subscription_creation`
        the time of creation of the subscription.
      - `subscription_trial_start`
        the time when the trial period of the subscription begins.
      - `plan_activation`
        same as subscription activation, but also includes the case when the plan-item of the subscription is changed.
      - `subscription_activation`
        the moment a subscription enters an `active` or `non-renewing` state. Also includes reactivations of canceled subscriptions.
      - `contract_termination`
        when a contract term is [terminated](/docs/api/subscriptions/cancel-subscription-for-items#contract_term_cancel_option) .
  - `charge_once` (optional, boolean)
    Indicates if the charge-item is to be charged only once or each time the `charge_on_event` occurs. This parameter only applies to charge-items.
  - `charge_on_option` (optional, enumerated string)
    Indicates when the charge-item is to be charged. This parameter only applies to charge-items.
    Possible enum values:
      - `immediately`
        The item is charged immediately on being added to the subscription.
      - `on_event`
        The item is charged at the occurrence of the event specified as `charge_on_event` .

- `discounts` (optional, array)
  Parameters for discounts
  - `apply_on` (optional, enumerated string)
    The amount on the invoice to which the discount is applied.
    Possible enum values:
      - `invoice_amount`
        The discount is applied to the invoice `sub_total` .
      - `specific_item_price`
        The discount is applied to the `invoice.line_item.amount` that corresponds to the item price specified by `item_price_id` .
  - `duration_type` (required, enumerated string)
    Specifies the time duration for which this discount is attached to the subscription.
    Possible enum values:
      - `one_time`
        The discount stays attached to the subscription till it is applied on an invoice **once**. It is removed after that from the subscription.
      - `forever`
        The discount is attached to the subscription and applied on the invoices till it is [explicitly removed](/docs/api/subscriptions/update-subscription-for-items#discounts_operation_type) .
      - `limited_period`
        The discount is attached to the subscription and applied on the invoices for a limited duration. This duration starts from the point it is applied to an invoice for the first time and expires after a period specified by `period` and `period_unit` .
  - `percentage` (optional, double)
    The percentage of the original amount that should be deducted from it.
  - `amount` (optional, in cents)
    The value of the discount. [The format of this value](/docs/api/currencies) depends on the kind of currency.
  - `period` (optional, integer)
    The duration of time for which the discount is attached to the subscription, in `period_units`. Applicable only when `duration_type` is `limited_period`.
  - `period_unit` (optional, enumerated string)
    The unit of time for `period`. Applicable only when `duration_type` is `limited_period`.
    Possible enum values:
      - `day`
        A period of 24 hours.
      - `week`
        A period of 7 days.
      - `month`
        A period of 1 calendar month.
      - `year`
        A period of 1 calendar year.
  - `included_in_mrr` (optional, boolean)
    The discount is included in MRR calculations for your site. This attribute is only applicable when `duration_type` is `one_time` and when the [feature is enabled](https://www.chargebee.com/docs/reporting.html#dashboards_flexible-mrr-calculation) in Chargebee. Also, If the [site-level setting](https://www.chargebee.com/docs/reporting.html#chart_flexible-mrr-calculation) is to exclude one-time discounts from MRR calculations, this value is always returned `false`.
  - `item_price_id` (optional, string, max chars=100)
    The [id of the item price](/docs/api/subscriptions/subscription-object#subscription_items_item_price_id) in the subscription to which the discount is to be applied. Relevant only when `apply_on` = `specific_item_price`.
  - `quantity` (optional, integer)
    Specifies the number of free units provided for the item, without affecting the total quantity sold
  - `operation_type` (required, enumerated string)
    The operation to be carried out for the discount.
    Possible enum values:
      - `add`
        The discount is attached to the subscription.
      - `remove`
        The discount (given by `discounts[id]` ) is removed from the subscription. Subsequent invoices will no longer have the discount applied. **Tip:** If you want to replace a discount, `remove` it and `add` another in the same API call.
  - `id` (optional, string, max chars=50)
    An immutable unique id for the discount. It is always auto-generated.

- `item_tiers` (optional, array)
  Parameters for item\_tiers
  - `item_price_id` (optional, string, max chars=100)
    The id of the item price for which the tier price is being overridden.
  - `starting_unit` (optional, integer)
    The lowest value in the quantity tier.
  - `ending_unit` (optional, integer)
    The highest value in the quantity tier.
  - `price` (optional, in cents)
    The overridden price of the tier. The value depends on the [type of currency](/docs/api/hosted_pages) .
  - `starting_unit_in_decimal` (optional, string, max chars=33)
    The decimal representation of the lowest value of quantity in this tier. This is zero for the lowest tier. For all other tiers, it is the same as `ending_unit_in_decimal` of the next lower tier. Returned only when the pricing\_model is `tiered` , `volume` or `stairstep` and [multi-decimal pricing](/docs/api/getting-started) is enabled.
  - `ending_unit_in_decimal` (optional, string, max chars=33)
    The decimal representation of the highest value of quantity in this tier. This attribute is not applicable for the highest tier. For all other tiers, it must be equal to the `starting_unit_in_decimal` of the next higher tier. Returned only when the pricing\_model is `tiered` , `volume` or `stairstep` and [multi-decimal pricing](/docs/api/getting-started) is enabled.
  - `price_in_decimal` (optional, string, max chars=39)
    The decimal representation of the per-unit price for the tier when the `pricing_model` is `tiered` or `volume`. When the `pricing_model` is `stairstep` , it is the decimal representation of the total price for the item. The value is in major units of the currency. Returned when the plan is quantity-based and [multi-decimal pricing](/docs/api/getting-started) is enabled.
  - `pricing_type` (optional, enumerated string)
    Pricing type for the tier.
    Possible enum values:
      - `per_unit`
        Indicates that the tier pricing is based on individual units. Customers are charged a fixed price per unit. For example, if the price per unit is $2 and the customer consumes 150 units, they will be charged $300 (150 × $2).
      - `flat_fee`
        Indicates that the tier pricing is a flat fee, applied to the entire tier regardless of the number of units consumed. For the **stairstep** pricing model, `pricing_type` will be set to `flat_fee` by default. For example, if the flat fee for a tier is $100, the customer pays $100 whether they consume 1 unit or the maximum number of units within that tier.
      - `package`
        Indicates that the tier pricing is based on a package of units. Customers are charged for each block or package of units. For example, if the package size is 100 units and the cost per block is $20 consuming 400 units will result in a charge of $80 (4 × $20).
  - `package_size` (optional, integer)
    Package size for the tier when pricing type is `package`. Specify the number of units that make up one package. For example, if 1000 API hits are grouped into a single package, set the package size to 1000.

- `entity_identifiers` (optional, array)
  Parameters for entity\_identifiers
  - `id` (optional, string, max chars=40)
    The unique id for the `entity_identifier[i]` in Chargebee. This is required when `entity_identifier[operation][i]` is `update` or `delete` .
  - `scheme` (optional, string, max chars=50)
    The Peppol BIS scheme associated with the `[vat_number](/docs/api/customers/customer-object#vat_number)` of the customer. This helps identify the specific type of customer entity. For example, `DE:VAT` is used for a German business entity while `DE:LWID45` is used for a German government entity. The value must be from the list of possible values and must correspond to the country provided under `billing_address.country`. See [list of possible values](https://www.chargebee.com/docs/e-invoicing.html#supported-countries) .
    
    **Tip:**
    
    If there is only one entity identifier for the customer and the value is the same as `vat_number`, then there is no need to provide the `entity_identifiers[]` array. See [description for `entity_identifiers[]`](/docs/api/customers/customer-object#entity_identifiers).
  - `value` (optional, string, max chars=50)
    The value of the `entity_identifier`. This identifies the customer entity on the Peppol network. For example: `10101010-STO-10` .
    
    **Tip:**
    
    If there is only one entity identifier for the customer and the value is the same as `vat_number`, then there is no need to provide the `entity_identifiers[]` array. See [description for `entity_identifiers[]`](/docs/api/customers/customer-object#entity_identifiers).
  - `operation` (optional, enumerated string)
    The operation to be performed for the `entity_identifier` .
    Possible enum values:
      - `create`
        Creates a new `entity_identifier` for the customer.
      - `update`
        Updates an existing `entity_identifier` for the customer. `entity_identifier[id]` must be provided in this case.
      - `delete`
        Deletes an existing `entity_identifier` for the customer. `entity_identifier[id]` must be provided in this case.
  - `standard` (optional, string, max chars=50)
    The standard used for specifying the `entity_identifier` `scheme`. Currently, only `iso6523-actorid-upis` is supported and is used by default when not provided.
    
    **Tip:**
    
    If there is only one entity identifier for the customer and the value is the same as `vat_number`, then there is no need to provide the `entity_identifiers[]` array. See [description for `entity_identifiers[]`](/docs/api/customers/customer-object#entity_identifiers).

## Returns

- `hosted_page` (Hosted page object)
  Resource object representing hosted\_page
