# Checkout existing subscription

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


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

You can checkout an existing subscription(typically in the trial state) by passing in the plan, quantity and addon details(like [Update a Subscription](/docs/api/v2/pcv-1/subscriptions/update-a-subscription))

When the redirect URL is notified of the result, we would advise you to [retrieve the subscription](/docs/api/subscriptions/retrieve-a-subscription) and verify the details.

#### Related Tutorial[](#related-tutorial)

-   [Upgrade existing subscription using Chargebee's hosted page](https://www.chargebee.com/tutorials/chargebee-js-checkout-existing-subscription/)

As mentioned before this behavior is very similar to the update subscription API call. All the web hook events will be fired only after the submission of payment details by the customer and successful checkout of subscription. Any errors related to the payment form that is submitted is handled as a response within the form so that the user is kept informed about the reason for failure to take corrective action.

## Sample Request

### Default

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_existing \
     -u {site_api_key}:\
     -d "subscription[id]"="__test__KyVnHhSBWmCOu2tC" \
     -d "subscription[plan_id]"="sub_plan1"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.CheckoutExisting()
		.SubscriptionId("__test__KyVnHhSBWmCOu2tC")
		.SubscriptionPlanId("sub_plan1")
		.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.CheckoutExisting(&hostedpage.CheckoutExistingRequestParams{
        Subscription : &hostedpage.CheckoutExistingSubscriptionParams{
            Id : "__test__KyVnHhSBWmCOu2tC",
            PlanId : "sub_plan1",
        },
    }).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.HostedPageCheckoutExistingRequest{
    Subscription : &chargebee.HostedPageCheckoutExistingSubscription{
        Id : "__test__KyVnHhSBWmCOu2tC",
        PlanId : "sub_plan1",
    },
}
  res, err := client.HostedPage.CheckoutExisting(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.checkoutExisting()
            .subscriptionId("__test__KyVnHhSBWmCOu2tC")
            .subscriptionPlanId("sub_plan1")
            .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.HostedPageCheckoutExistingParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageCheckoutExistingResponse;

public class HostedPageCheckoutExisting {

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

        HostedPageCheckoutExistingParams.SubscriptionParams subscriptionParams =
            HostedPageCheckoutExistingParams.SubscriptionParams.builder()
                .id("__test__KyVnHhSBWmCOu2tC")
                .planId("sub_plan1")
                .build();

        HostedPageCheckoutExistingParams params = HostedPageCheckoutExistingParams.builder()
            .subscription(subscriptionParams)
            .build();

        HostedPageCheckoutExistingResponse response = client.hostedPages().checkoutExisting(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.checkoutExisting({
        subscription: {
            id: "__test__KyVnHhSBWmCOu2tC",
            plan_id: "sub_plan1"
        }
    });

    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()->checkoutExisting([
    "subscription" => [
        "id" => "__test__KyVnHhSBWmCOu2tC",
        "plan_id" => "sub_plan1"
    ]
]);
$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(
    cb_client.HostedPage.CheckoutExistingParams(
        subscription=cb_client.HostedPage.CheckoutExistingSubscriptionParams(
            id="__test__KyVnHhSBWmCOu2tC",
            plan_id="sub_plan1"
        )
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::HostedPage.checkout_existing({
  :subscription => {
    :id => "__test__KyVnHhSBWmCOu2tC",
    :plan_id => "sub_plan1"
  }
})

hosted_page = result.hosted_page
```

### checkout an existing subscription with addons.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_existing \
     -u {site_api_key}:\
     -d "subscription[id]"="__test__KyVnHhSBWmCoF2tJ" \
     -d "subscription[plan_id]"="no_trial" \
     -d "addons[id][0]"="sub_ssl" \
     -d "addons[unit_price][0]"=200
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.CheckoutExisting()
		.SubscriptionId("__test__KyVnHhSBWmCoF2tJ")
		.SubscriptionPlanId("no_trial")
		.AddonId(0, "sub_ssl")
		.AddonUnitPrice(0, 200)
		.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.CheckoutExisting(&hostedpage.CheckoutExistingRequestParams{
        Addons : []*hostedpage.CheckoutExistingAddonParams{
            {
                Id : "sub_ssl",
                UnitPrice : chargebee.Int64(200),
            },
        },
        Subscription : &hostedpage.CheckoutExistingSubscriptionParams{
            Id : "__test__KyVnHhSBWmCoF2tJ",
            PlanId : "no_trial",
        },
    }).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.HostedPageCheckoutExistingRequest{
    Addons : []*chargebee.HostedPageCheckoutExistingAddon{
        {
            Id : "sub_ssl",
            UnitPrice : chargebee.Int64(200),
        },
    },
    Subscription : &chargebee.HostedPageCheckoutExistingSubscription{
        Id : "__test__KyVnHhSBWmCoF2tJ",
        PlanId : "no_trial",
    },
}
  res, err := client.HostedPage.CheckoutExisting(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.checkoutExisting()
            .subscriptionId("__test__KyVnHhSBWmCoF2tJ")
            .subscriptionPlanId("no_trial")
            .addonId(0, "sub_ssl")
            .addonUnitPrice(0, 200L)
            .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.HostedPageCheckoutExistingParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageCheckoutExistingResponse;
import java.util.List;

public class HostedPageCheckoutExisting {

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

        HostedPageCheckoutExistingParams.SubscriptionParams subscriptionParams =
            HostedPageCheckoutExistingParams.SubscriptionParams.builder()
                .id("__test__KyVnHhSBWmCoF2tJ")
                .planId("no_trial")
                .build();

        HostedPageCheckoutExistingParams.AddonsParams addon0 =
            HostedPageCheckoutExistingParams.AddonsParams.builder()
                .id("sub_ssl")
                .unitPrice(200L)
                .build();

        List<HostedPageCheckoutExistingParams.AddonsParams> addonsList =
            List.of(addon0);

        HostedPageCheckoutExistingParams params = HostedPageCheckoutExistingParams.builder()
            .subscription(subscriptionParams)
            .addons(addonsList)
            .build();

        HostedPageCheckoutExistingResponse response = client.hostedPages().checkoutExisting(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.checkoutExisting({
        addons: [
            {
                id: "sub_ssl",
                unit_price: 200
            }
        ],
        subscription: {
            id: "__test__KyVnHhSBWmCoF2tJ",
            plan_id: "no_trial"
        }
    });

    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()->checkoutExisting([
    "addons" => [
        [
            "id" => "sub_ssl",
            "unit_price" => 200
        ]
    ],
    "subscription" => [
        "id" => "__test__KyVnHhSBWmCoF2tJ",
        "plan_id" => "no_trial"
    ]
]);
$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(
    cb_client.HostedPage.CheckoutExistingParams(
        addons=[
            cb_client.HostedPage.CheckoutExistingAddonParams(
              id="sub_ssl",
              unit_price=200
            )
        ],
        subscription=cb_client.HostedPage.CheckoutExistingSubscriptionParams(
            id="__test__KyVnHhSBWmCoF2tJ",
            plan_id="no_trial"
        )
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::HostedPage.checkout_existing({
  :subscription => {
    :id => "__test__KyVnHhSBWmCoF2tJ",
    :plan_id => "no_trial"
  },
  :addons => [
    {
      :id => "sub_ssl",
      :unit_price => 200
    }
  ]
})

hosted_page = result.hosted_page
```

## Sample Response

```json
{
  "hosted_page": {
    "created_at": 1517505988,
    "embed": true,
    "expires_at": 1517509588,
    "id": "__test__yY8QV6GaiRmIYi3JV6ZBHulNfEVj6LjG",
    "layout": "in_app",
    "object": "hosted_page",
    "resource_version": 1517505988000,
    "state": "created",
    "type": "checkout_existing",
    "updated_at": 1517505988,
    "url": "https://yourapp.chargebee.com/pages/v4/__test__yY8QV6GaiRmIYi3JV6ZBHulNfEVj6LjG/"
  }
}
```

## URL Format

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

## Input Parameters

- `replace_addon_list` (optional, boolean, default=false)
  Should be true if the existing addons should be replaced with the ones that are being passed.

- `mandatory_addons_to_remove` (optional, string, max chars=100)
  List of addons IDs that are mandatory to the plan and has to be removed from the subscription.

- `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)
  The number of billing cycles the subscription runs before canceling. If not provided, then the billing cycles set for the plan is used.

- `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.

- `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)
  Applicable only for cancelled subscriptions. Once this is passed as true, cancelled subscription will become active; otherwise subscription changes will be made but the subscription state will remain cancelled. If not passed, subscription will be activated only if there is any change in subscription data.

- `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 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 has a different billing period from the current plan, the subscription term resets automatically, regardless of the value of `force_term_reset`.

- `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/v2/pcv-1/hosted_pages/checkout-existing-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.

- `embed` (optional, boolean, default=true)
  If true then hosted page formatted to be shown in iframe. If false, it is formatted to be shown as a separate page.
  
  **Note** : For [in-app](https://www.chargebee.com/docs/checkout-v3.html) checkout, default is false.

- `iframe_messaging` (optional, boolean, default=false)
  If true then iframe will communicate with the parent window. Applicable only for embedded(iframe) hosted pages. If you're using iframe\_messaging you need to implement onSuccess & onCancel callbacks.
  
  **Note** : This parameter is not applicable for [in-app](https://www.chargebee.com/docs/checkout-v3.html) checkout.

- `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.
  - `plan_id` (optional, string, max chars=100)
    Identifier of the plan for this subscription
  - `plan_quantity` (optional, integer, default=1, min=1)
    Represents the plan quantity for this subscription.
  - `plan_unit_price` (optional, in cents, min=0)
    Amount that will override the Plan's default price. The unit depends on the [type of currency](/docs/api/getting-started) .
  - `setup_fee` (optional, in cents, min=0)
    Amount that will override the default setup fee. The unit depends on the [type of currency](/docs/api/getting-started) .
  - `plan_quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the plan purchased. Can be provided for quantity-based plans and only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `plan_unit_price_in_decimal` (optional, string, max chars=39)
    When price overriding is enabled for the site, the price or per-unit price of the plan can be set here. The value [set for the plan](/docs/api/v2/pcv-1/plans/plan-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/v2/pcv-1/currencies) is enabled.
  - `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 Plan's [`trial_period`](/docs/api/v2/pcv-1/plans) 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.

- `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.

- `addons` (optional, array)
  Parameters for addons
  - `id` (optional, string, max chars=100)
    Identifier of the addon. Multiple addons can be passed.
  - `quantity` (optional, integer)
    Quantity of the addon. Applicable for addons with `pricing_model` other than `flat_fee` .
  - `unit_price` (optional, in cents)
    The price or per-unit-price of the addon. The value depends on the [type of currency](/docs/api/getting-started).
    
    **Note:**
    
    For recurring addons, this is the final price or per-unit price for each billing period of the subscription, regardless of the [addon period](/docs/api/v2/pcv-1/addons/addon-object#period). For example, consider the following details:
    
    -   The `unit_price` provided is $10
    -   The addon billing period is 1 month.
    -   The plan billing period is 3 months.
    -   The addon is only billed for $10 on each subscription renewal.
  - `billing_cycles` (optional, integer)
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `unit_price_in_decimal` (optional, string, 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 addon can be set here. The value [set for the addon](/docs/api/v2/pcv-1/addons/addon-object#price) is used by default. However, the price provided here is considered as the price of the addon for an entire billing cycle of the subscription regardless of the value of the addon `period`. Provide the value as a decimal string in major units of the currency. Can be provided only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.

- `event_based_addons` (optional, array)
  Parameters for event\_based\_addons
  - `id` (optional, string, max chars=100)
    A unique 'id' used to identify the addon.
  - `quantity` (optional, integer)
    Quantity of the addon. Applicable for addons with `pricing_model` other than `flat_fee` .
  - `unit_price` (optional, in cents)
    Amount that will override the Addon's default price. The unit depends on the [type of currency](/docs/api/getting-started) .
  - `service_period_in_days` (optional, integer)
    Defines service period of the addon in days from the day of charge.
  - `charge_on` (optional, enumerated string)
    Indicates when the non-recurring addon will be charged.
    Possible enum values:
      - `immediately`
        Charges for the addon will be applied immediately.
      - `on_event`
        Charge for the addon will be applied on the occurrence of a specified event.
  - `on_event` (optional, enumerated string)
    Event on which this addon will be charged.
    Possible enum values:
      - `subscription_creation`
        Addon will be charged on subscription creation.
      - `subscription_trial_start`
        Addon will be charged when the trial period starts.
      - `plan_activation`
        Addon will be charged on plan activation.
      - `subscription_activation`
        Addon will be charged on subscription activation.
      - `contract_termination`
        Addon will be charged on contract termination.
  - `charge_once` (optional, boolean)
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
  - `quantity_in_decimal` (optional, string, max chars=33)
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.
  - `unit_price_in_decimal` (optional, string, 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 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. Can be provided only when [multi-decimal pricing](/docs/api/v2/pcv-1/currencies) is enabled.

## Returns

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