# Checkout new 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)

Hosted page to accept card details from the subscriber and create a new subscription. This is similar to our server to server API [Create a Subscription](/docs/api/v2/pcv-1/subscriptions/create-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 Tutorials[](#related-tutorials)

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

As mentioned before this behavior is very similar to the create subscription API call. All the web hook events will be fired only after the submission of payment details by the customer and successful creation 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

### checkout a new subscription with customer details.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_new \
     -u {site_api_key}:\
     -d "customer[email]"="john@user.com" \
     -d "customer[first_name]"="John" \
     -d "customer[last_name]"="Doe" \
     -d "customer[locale]"="fr-CA" \
     -d "customer[phone]"="+1-949-999-9999" \
     -d "subscription[plan_id]"="no_trial" \
     -d "billing_address[first_name]"="John" \
     -d "billing_address[last_name]"="Doe" \
     -d "billing_address[line1]"="PO Box 9999" \
     -d "billing_address[city]"="Walnut" \
     -d "billing_address[state]"="California" \
     -d "billing_address[zip]"="91789" \
     -d "billing_address[country]"="US"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.CheckoutNew()
		.CustomerEmail("john@user.com")
		.CustomerFirstName("John")
		.CustomerLastName("Doe")
		.CustomerLocale("fr-CA")
		.CustomerPhone("+1-949-999-9999")
		.SubscriptionPlanId("no_trial")
		.BillingAddressFirstName("John")
		.BillingAddressLastName("Doe")
		.BillingAddressLine1("PO Box 9999")
		.BillingAddressCity("Walnut")
		.BillingAddressState("California")
		.BillingAddressZip("91789")
		.BillingAddressCountry("US")
		.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.CheckoutNew(&hostedpage.CheckoutNewRequestParams{
        Customer : &hostedpage.CheckoutNewCustomerParams{
            Email : "john@user.com",
            FirstName : "John",
            LastName : "Doe",
            Locale : "fr-CA",
            Phone : "+1-949-999-9999",
        },
        Subscription : &hostedpage.CheckoutNewSubscriptionParams{
            PlanId : "no_trial",
        },
        BillingAddress : &hostedpage.CheckoutNewBillingAddressParams{
            FirstName : "John",
            LastName : "Doe",
            Line1 : "PO Box 9999",
            City : "Walnut",
            State : "California",
            Zip : "91789",
            Country : "US",
        },
    }).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.HostedPageCheckoutNewRequest{
    Customer : &chargebee.HostedPageCheckoutNewCustomer{
        Email : "john@user.com",
        FirstName : "John",
        LastName : "Doe",
        Locale : "fr-CA",
        Phone : "+1-949-999-9999",
    },
    Subscription : &chargebee.HostedPageCheckoutNewSubscription{
        PlanId : "no_trial",
    },
    BillingAddress : &chargebee.HostedPageCheckoutNewBillingAddress{
        FirstName : "John",
        LastName : "Doe",
        Line1 : "PO Box 9999",
        City : "Walnut",
        State : "California",
        Zip : "91789",
        Country : "US",
    },
}
  res, err := client.HostedPage.CheckoutNew(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.checkoutNew()
            .customerEmail("john@user.com")
            .customerFirstName("John")
            .customerLastName("Doe")
            .customerLocale("fr-CA")
            .customerPhone("+1-949-999-9999")
            .subscriptionPlanId("no_trial")
            .billingAddressFirstName("John")
            .billingAddressLastName("Doe")
            .billingAddressLine1("PO Box 9999")
            .billingAddressCity("Walnut")
            .billingAddressState("California")
            .billingAddressZip("91789")
            .billingAddressCountry("US")
            .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.HostedPageCheckoutNewParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageCheckoutNewResponse;

public class HostedPageCheckoutNew {

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

        HostedPageCheckoutNewParams.CustomerParams customerParams =
            HostedPageCheckoutNewParams.CustomerParams.builder()
                .email("john@user.com")
                .firstName("John")
                .lastName("Doe")
                .locale("fr-CA")
                .phone("+1-949-999-9999")
                .build();

        HostedPageCheckoutNewParams.SubscriptionParams subscriptionParams =
            HostedPageCheckoutNewParams.SubscriptionParams.builder()
                .planId("no_trial")
                .build();

        HostedPageCheckoutNewParams.BillingAddressParams billingAddressParams =
            HostedPageCheckoutNewParams.BillingAddressParams.builder()
                .firstName("John")
                .lastName("Doe")
                .line1("PO Box 9999")
                .city("Walnut")
                .state("California")
                .zip("91789")
                .country("US")
                .build();

        HostedPageCheckoutNewParams params = HostedPageCheckoutNewParams.builder()
            .customer(customerParams)
            .subscription(subscriptionParams)
            .billingAddress(billingAddressParams)
            .build();

        HostedPageCheckoutNewResponse response = client.hostedPages().checkoutNew(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.checkoutNew({
        customer: {
            email: "john@user.com",
            first_name: "John",
            last_name: "Doe",
            locale: "fr-CA",
            phone: "+1-949-999-9999"
        },
        subscription: {
            plan_id: "no_trial"
        },
        billing_address: {
            first_name: "John",
            last_name: "Doe",
            line1: "PO Box 9999",
            city: "Walnut",
            state: "California",
            zip: 91789,
            country: "US"
        }
    });

    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()->checkoutNew([
    "customer" => [
        "email" => "john@user.com",
        "first_name" => "John",
        "last_name" => "Doe",
        "locale" => "fr-CA",
        "phone" => "+1-949-999-9999"
    ],
    "subscription" => [
        "plan_id" => "no_trial"
    ],
    "billing_address" => [
        "first_name" => "John",
        "last_name" => "Doe",
        "line1" => "PO Box 9999",
        "city" => "Walnut",
        "state" => "California",
        "zip" => "91789",
        "country" => "US"
    ]
]);
$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_new(
    cb_client.HostedPage.CheckoutNewParams(
        customer=cb_client.HostedPage.CheckoutNewCustomerParams(
            email="john@user.com",
            first_name="John",
            last_name="Doe",
            locale="fr-CA",
            phone="+1-949-999-9999"
        ),
        subscription=cb_client.HostedPage.CheckoutNewSubscriptionParams(
            plan_id="no_trial"
        ),
        billing_address=cb_client.HostedPage.CheckoutNewBillingAddressParams(
            first_name="John",
            last_name="Doe",
            line1="PO Box 9999",
            city="Walnut",
            state="California",
            zip="91789",
            country="US"
        )
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::HostedPage.checkout_new({
  :customer => {
    :email => "john@user.com",
    :first_name => "John",
    :last_name => "Doe",
    :locale => "fr-CA",
    :phone => "+1-949-999-9999"
  },
  :subscription => {
    :plan_id => "no_trial"
  },
  :billing_address => {
    :first_name => "John",
    :last_name => "Doe",
    :line1 => "PO Box 9999",
    :city => "Walnut",
    :state => "California",
    :zip => "91789",
    :country => "US"
  }
})

hosted_page = result.hosted_page
```

### checkout a new subscription with addons.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_new \
     -u {site_api_key}:\
     -d "customer[email]"="john@user.com" \
     -d "customer[first_name]"="John" \
     -d "customer[last_name]"="Doe" \
     -d "customer[locale]"="fr-CA" \
     -d "customer[phone]"="+1-949-999-9999" \
     -d "subscription[plan_id]"="no_trial" \
     -d "addons[id][0]"="sub_monitor" \
     -d "addons[unit_price][0]"=100 \
     -d "addons[quantity][0]"=2
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.CheckoutNew()
		.CustomerEmail("john@user.com")
		.CustomerFirstName("John")
		.CustomerLastName("Doe")
		.CustomerLocale("fr-CA")
		.CustomerPhone("+1-949-999-9999")
		.SubscriptionPlanId("no_trial")
		.AddonId(0, "sub_monitor")
		.AddonUnitPrice(0, 100)
		.AddonQuantity(0, 2)
		.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.CheckoutNew(&hostedpage.CheckoutNewRequestParams{
        Addons : []*hostedpage.CheckoutNewAddonParams{
            {
                Id : "sub_monitor",
                UnitPrice : chargebee.Int64(100),
                Quantity : chargebee.Int32(2),
            },
        },
        Customer : &hostedpage.CheckoutNewCustomerParams{
            Email : "john@user.com",
            FirstName : "John",
            LastName : "Doe",
            Locale : "fr-CA",
            Phone : "+1-949-999-9999",
        },
        Subscription : &hostedpage.CheckoutNewSubscriptionParams{
            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.HostedPageCheckoutNewRequest{
    Addons : []*chargebee.HostedPageCheckoutNewAddon{
        {
            Id : "sub_monitor",
            UnitPrice : chargebee.Int64(100),
            Quantity : chargebee.Int32(2),
        },
    },
    Customer : &chargebee.HostedPageCheckoutNewCustomer{
        Email : "john@user.com",
        FirstName : "John",
        LastName : "Doe",
        Locale : "fr-CA",
        Phone : "+1-949-999-9999",
    },
    Subscription : &chargebee.HostedPageCheckoutNewSubscription{
        PlanId : "no_trial",
    },
}
  res, err := client.HostedPage.CheckoutNew(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.checkoutNew()
            .customerEmail("john@user.com")
            .customerFirstName("John")
            .customerLastName("Doe")
            .customerLocale("fr-CA")
            .customerPhone("+1-949-999-9999")
            .subscriptionPlanId("no_trial")
            .addonId(0, "sub_monitor")
            .addonUnitPrice(0, 100L)
            .addonQuantity(0, 2)
            .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.HostedPageCheckoutNewParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageCheckoutNewResponse;
import java.util.List;

public class HostedPageCheckoutNew {

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

        HostedPageCheckoutNewParams.CustomerParams customerParams =
            HostedPageCheckoutNewParams.CustomerParams.builder()
                .email("john@user.com")
                .firstName("John")
                .lastName("Doe")
                .locale("fr-CA")
                .phone("+1-949-999-9999")
                .build();

        HostedPageCheckoutNewParams.SubscriptionParams subscriptionParams =
            HostedPageCheckoutNewParams.SubscriptionParams.builder()
                .planId("no_trial")
                .build();

        HostedPageCheckoutNewParams.AddonsParams addon0 =
            HostedPageCheckoutNewParams.AddonsParams.builder()
                .id("sub_monitor")
                .unitPrice(100L)
                .quantity(2)
                .build();

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

        HostedPageCheckoutNewParams params = HostedPageCheckoutNewParams.builder()
            .customer(customerParams)
            .subscription(subscriptionParams)
            .addons(addonsList)
            .build();

        HostedPageCheckoutNewResponse response = client.hostedPages().checkoutNew(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.checkoutNew({
        addons: [
            {
                id: "sub_monitor",
                unit_price: 100,
                quantity: 2
            }
        ],
        customer: {
            email: "john@user.com",
            first_name: "John",
            last_name: "Doe",
            locale: "fr-CA",
            phone: "+1-949-999-9999"
        },
        subscription: {
            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()->checkoutNew([
    "addons" => [
        [
            "id" => "sub_monitor",
            "unit_price" => 100,
            "quantity" => 2
        ]
    ],
    "customer" => [
        "email" => "john@user.com",
        "first_name" => "John",
        "last_name" => "Doe",
        "locale" => "fr-CA",
        "phone" => "+1-949-999-9999"
    ],
    "subscription" => [
        "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_new(
    cb_client.HostedPage.CheckoutNewParams(
        addons=[
            cb_client.HostedPage.CheckoutNewAddonParams(
              id="sub_monitor",
              unit_price=100,
              quantity=2
            )
        ],
        customer=cb_client.HostedPage.CheckoutNewCustomerParams(
            email="john@user.com",
            first_name="John",
            last_name="Doe",
            locale="fr-CA",
            phone="+1-949-999-9999"
        ),
        subscription=cb_client.HostedPage.CheckoutNewSubscriptionParams(
            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_new({
  :customer => {
    :email => "john@user.com",
    :first_name => "John",
    :last_name => "Doe",
    :locale => "fr-CA",
    :phone => "+1-949-999-9999"
  },
  :subscription => {
    :plan_id => "no_trial"
  },
  :addons => [
    {
      :id => "sub_monitor",
      :unit_price => 100,
      :quantity => 2
    }
  ]
})

hosted_page = result.hosted_page
```

### checkout a new subscription with customer card details.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_new \
     -u {site_api_key}:\
     -d "customer[email]"="john@user.com" \
     -d "customer[first_name]"="John" \
     -d "customer[last_name]"="Doe" \
     -d "customer[locale]"="fr-CA" \
     -d "customer[phone]"="+1-949-999-9999" \
     -d "subscription[plan_id]"="no_trial" \
     -d "card[gateway_account_id]"="gw___test__KyVnGlSBWmAIk2Ph"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = HostedPage.CheckoutNew()
		.CustomerEmail("john@user.com")
		.CustomerFirstName("John")
		.CustomerLastName("Doe")
		.CustomerLocale("fr-CA")
		.CustomerPhone("+1-949-999-9999")
		.SubscriptionPlanId("no_trial")
		.CardGatewayAccountId("gw___test__KyVnGlSBWmAIk2Ph")
		.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.CheckoutNew(&hostedpage.CheckoutNewRequestParams{
        Customer : &hostedpage.CheckoutNewCustomerParams{
            Email : "john@user.com",
            FirstName : "John",
            LastName : "Doe",
            Locale : "fr-CA",
            Phone : "+1-949-999-9999",
        },
        Subscription : &hostedpage.CheckoutNewSubscriptionParams{
            PlanId : "no_trial",
        },
        Card : &hostedpage.CheckoutNewCardParams{
            GatewayAccountId : "gw___test__KyVnGlSBWmAIk2Ph",
        },
    }).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.HostedPageCheckoutNewRequest{
    Customer : &chargebee.HostedPageCheckoutNewCustomer{
        Email : "john@user.com",
        FirstName : "John",
        LastName : "Doe",
        Locale : "fr-CA",
        Phone : "+1-949-999-9999",
    },
    Subscription : &chargebee.HostedPageCheckoutNewSubscription{
        PlanId : "no_trial",
    },
    Card : &chargebee.HostedPageCheckoutNewCard{
        GatewayAccountId : "gw___test__KyVnGlSBWmAIk2Ph",
    },
}
  res, err := client.HostedPage.CheckoutNew(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.checkoutNew()
            .customerEmail("john@user.com")
            .customerFirstName("John")
            .customerLastName("Doe")
            .customerLocale("fr-CA")
            .customerPhone("+1-949-999-9999")
            .subscriptionPlanId("no_trial")
            .cardGatewayAccountId("gw___test__KyVnGlSBWmAIk2Ph")
            .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.HostedPageCheckoutNewParams;
import com.chargebee.v4.models.hostedPage.responses.HostedPageCheckoutNewResponse;

public class HostedPageCheckoutNew {

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

        HostedPageCheckoutNewParams.CustomerParams customerParams =
            HostedPageCheckoutNewParams.CustomerParams.builder()
                .email("john@user.com")
                .firstName("John")
                .lastName("Doe")
                .locale("fr-CA")
                .phone("+1-949-999-9999")
                .build();

        HostedPageCheckoutNewParams.SubscriptionParams subscriptionParams =
            HostedPageCheckoutNewParams.SubscriptionParams.builder()
                .planId("no_trial")
                .build();

        HostedPageCheckoutNewParams.CardParams cardParams =
            HostedPageCheckoutNewParams.CardParams.builder()
                .gatewayAccountId("gw___test__KyVnGlSBWmAIk2Ph")
                .build();

        HostedPageCheckoutNewParams params = HostedPageCheckoutNewParams.builder()
            .customer(customerParams)
            .subscription(subscriptionParams)
            .card(cardParams)
            .build();

        HostedPageCheckoutNewResponse response = client.hostedPages().checkoutNew(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.checkoutNew({
        customer: {
            email: "john@user.com",
            first_name: "John",
            last_name: "Doe",
            locale: "fr-CA",
            phone: "+1-949-999-9999"
        },
        subscription: {
            plan_id: "no_trial"
        },
        card: {
            gateway_account_id: "gw___test__KyVnGlSBWmAIk2Ph"
        }
    });

    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()->checkoutNew([
    "customer" => [
        "email" => "john@user.com",
        "first_name" => "John",
        "last_name" => "Doe",
        "locale" => "fr-CA",
        "phone" => "+1-949-999-9999"
    ],
    "subscription" => [
        "plan_id" => "no_trial"
    ],
    "card" => [
        "gateway_account_id" => "gw___test__KyVnGlSBWmAIk2Ph"
    ]
]);
$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_new(
    cb_client.HostedPage.CheckoutNewParams(
        customer=cb_client.HostedPage.CheckoutNewCustomerParams(
            email="john@user.com",
            first_name="John",
            last_name="Doe",
            locale="fr-CA",
            phone="+1-949-999-9999"
        ),
        subscription=cb_client.HostedPage.CheckoutNewSubscriptionParams(
            plan_id="no_trial"
        ),
        card=cb_client.HostedPage.CheckoutNewCardParams(
            gateway_account_id="gw___test__KyVnGlSBWmAIk2Ph"
        )
    )
)
hosted_page = response.hosted_page
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::HostedPage.checkout_new({
  :customer => {
    :email => "john@user.com",
    :first_name => "John",
    :last_name => "Doe",
    :locale => "fr-CA",
    :phone => "+1-949-999-9999"
  },
  :subscription => {
    :plan_id => "no_trial"
  },
  :card => {
    :gateway_account_id => "gw___test__KyVnGlSBWmAIk2Ph"
  }
})

hosted_page = result.hosted_page
```

## Sample Response

```json
{
  "hosted_page": {
    "created_at": 1517505996,
    "embed": true,
    "expires_at": 1517509596,
    "id": "__test__znukwBn17fojRqcSm5uZtxxn99WgF5gcu",
    "layout": "in_app",
    "object": "hosted_page",
    "resource_version": 1517505996000,
    "state": "created",
    "type": "checkout_new",
    "updated_at": 1517505996,
    "url": "https://yourapp.chargebee.com/pages/v4/__test__znukwBn17fojRqcSm5uZtxxn99WgF5gcu/"
  }
}
```

## URL Format

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

## Input Parameters

- `billing_cycles` (optional, integer, min=0)
  Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.

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

- `terms_to_charge` (optional, integer, min=1)
  The number of subscription billing cycles (including the first one) to [invoice in advance](https://www.chargebee.com/docs/advance-invoices.html) .

- `billing_alignment_mode` (optional, enumerated string)
  Override the [billing alignment mode](https://www.chargebee.com/docs/calendar-billing.html#alignment-of-billing-date) for Calendar Billing. Only applicable when using Calendar Billing. The default value is that which has been configured for the site.
  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.

- `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-new-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` (optional, string, max chars=50)
    A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
  - `plan_id` (required, string, max chars=100)
    Identifier of the plan for this subscription
  - `plan_quantity` (optional, integer, default=1, min=1)
    Plan quantity for this subscription
  - `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` (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) .
  - `plan_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 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.
  - `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) .
  - `trial_end` (optional, timestamp(UTC) in seconds)
    The time at which the trial ends for this subscription. Can be specified to override the default trial period.If **'0'** is passed, the subscription will be activated immediately. This parameter overrides the Plan's [`trial_period`](/docs/api/v2/pcv-1/plans) directly.
  - `start_date` (optional, timestamp(UTC) in seconds)
    The date/time at which the subscription is to start. If not provided, the subscription starts immediately. You can provide a value in the past as well. This is called backdating the subscription creation and is done when the subscription has already been provisioned but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
    
    -   Backdating is enabled for subscription creation operations.
    -   The current day of the month does not exceed the limit set in Chargebee for backdating such operations. This day is typically the day of the month by which the accounting for the previous month must be closed.
    -   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, `start_date` cannot be earlier than 14th February.
  - `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.
  - `affiliate_token` (optional, string, max chars=250)
    A unique tracking token
  - `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
  - `id` (optional, string, max chars=50)
    The unique ID of the customer for which this `hosted_page` should be created.
    
    -   When not provided, a new customer is created with the ID set to the value provided for `subscription[id]`. If `subscription[id]` is unavailable, then the customer ID is autogenerated.
    -   To prevent duplicate subscriptions, pass `customer[id]` while generating the checkout URL. This enables Chargebee to validate against existing subscriptions for the customer. Without it, the validation is skipped.
  - `email` (optional, string, max chars=70)
    Email of the customer. Configured email notifications will be sent to this email.
  - `first_name` (optional, string, max chars=150)
    First name of the customer. If not provided it will be got from contact information entered in the hosted page
  - `last_name` (optional, string, max chars=150)
    Last name of the customer. If not provided it will be got from contact information entered in the hosted page
  - `company` (optional, string, max chars=250)
    Company name of the customer.
  - `phone` (optional, string, max chars=50)
    Phone number of the customer
  - `locale` (optional, string, max chars=50)
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
  - `taxability` (optional, enumerated string, default=taxable)
    Specifies if the customer is liable for tax
    Possible enum values:
      - `taxable`
        Computes tax for the customer based on the [site configuration](https://www.chargebee.com/docs/tax.html). In some cases, depending on the region, shipping\_address is needed. If not provided, then billing\_address is used to compute tax. If that's not available either, the tax is taken as zero.
      - `exempt`
        -   Customer is exempted from tax. When using Chargebee's native [Taxes](https://www.chargebee.com/docs/tax.html) feature or when using the [TaxJar integration](https://www.chargebee.com/docs/taxjar.html), no other action is needed.
        -   However, when using our [Avalara integration](https://www.chargebee.com/docs/avalara.html), optionally, specify `entity_code` or `exempt_number` attributes if you use Chargebee's [AvaTax for Sales](https://www.chargebee.com/docs/avalara.html#configuring-tax-exemption) or specify `exemption_details` attribute if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration. Tax may still be applied by Avalara for certain values of `entity_code`/`exempt_number`/`exemption_details` based on the state/region/province of the taxable address.
  - `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.
  - `consolidated_invoicing` (optional, boolean)
    Indicates whether invoices raised on the same day for the `customer` are consolidated. When provided, this overrides the default configuration at the [site-level](https://www.chargebee.com/docs/consolidated-invoicing.html#configuring-consolidated-invoicing). This parameter can be provided only when [Consolidated Invoicing](https://www.chargebee.com/docs/consolidated-invoicing.html) is enabled.
    
    **Note:**
    
    Any invoices raised when a subscription activates from `in_trial` or `future` `status`, are not consolidated by default. [Contact Support](https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team?utm_source=docs_api&utm_medium=content&utm_campaign=support) to enable consolidation for such invoices.

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

- `billing_address` (optional, string)
  Parameters for billing\_address
  - `first_name` (optional, string, max chars=150)
    The first name of the billing contact.
  - `last_name` (optional, string, max chars=150)
    The last name of the billing contact.
  - `email` (optional, string, max chars=70)
    The email address.
  - `company` (optional, string, max chars=250)
    The company name.
  - `phone` (optional, string, max chars=50)
    The phone number.
  - `line1` (optional, string, max chars=150)
    Address line 1
  - `line2` (optional, string, max chars=150)
    Address line 2
  - `line3` (optional, string, max chars=150)
    Address line 3
  - `city` (optional, string, max chars=50)
    The name of the city.
  - `state_code` (optional, string, max chars=50)
    The [ISO 3166-2 state/province code](https://www.iso.org/obp/ui/#search/code) without the country prefix. Currently supported for USA, Canada, India and UAE. For instance, for Arizona (USA), set `state_code` as `AZ` (not `US-AZ` ). For Tamil Nadu (India), set as `TN` (not `IN-TN` ). For British Columbia (Canada), set as `BC` (not `CA-BC` ). For Dubai (UAE), set as `DU` (not `AE-DU` ).
  - `state` (optional, string, max chars=50)
    The state/province name. Is set by Chargebee automatically for US, Canada, India and UAE, if `state_code` is provided.
  - `zip` (optional, string, max chars=20)
    Zip or postal code. The number of characters is validated according to the rules [specified here](https://chromium-i18n.appspot.com/ssl-address) .
  - `country` (optional, string, max chars=50)
    The billing address country of the customer. Must be one of [ISO 3166 alpha-2 country code](https://www.iso.org/iso-3166-country-codes.html) .
    
    **Note**: If you enter an invalid country code, the system will return an error.
    
    **Brexit**
    
    If you have enabled [EU VAT](https://www.chargebee.com/docs/eu-vat.html) in 2021 or later, or have [manually enable](https://www.chargebee.com/docs/brexit.html#what-needs-to-be-done-in-chargebee) the Brexit configuration, then `XI` (the code for **United Kingdom - Northern Ireland**) is available as an option.
  - `validation_status` (optional, enumerated string, default=not_validated)
    The address verification status.
    Possible enum values:
      - `not_validated`
        Address is not yet validated.
      - `valid`
        Address was validated successfully.
      - `partially_valid`
        The address is valid for taxability but has not been validated for shipping.
      - `invalid`
        Address is invalid.

- `shipping_address` (optional, string)
  Parameters for shipping\_address
  - `first_name` (optional, string, max chars=150)
    The first name of the contact.
  - `last_name` (optional, string, max chars=150)
    The last name of the contact.
  - `email` (optional, string, max chars=70)
    The email address.
  - `company` (optional, string, max chars=250)
    The company name.
  - `phone` (optional, string, max chars=50)
    The phone number.
  - `line1` (optional, string, max chars=150)
    Address line 1
  - `line2` (optional, string, max chars=150)
    Address line 2
  - `line3` (optional, string, max chars=150)
    Address line 3
  - `city` (optional, string, max chars=50)
    The name of the city.
  - `state_code` (optional, string, max chars=50)
    The [ISO 3166-2 state/province code](https://www.iso.org/obp/ui/#search/code) without the country prefix. Currently supported for USA, Canada, India and UAE. For instance, for Arizona (USA), set `state_code` as `AZ` (not `US-AZ` ). For Tamil Nadu (India), set as `TN` (not `IN-TN` ). For British Columbia (Canada), set as `BC` (not `CA-BC` ). For Dubai (UAE), set as `DU` (not `AE-DU` ).
  - `state` (optional, string, max chars=50)
    The state/province name. Is set by Chargebee automatically for US, Canada, India and UAE, if `state_code` is provided.
  - `zip` (optional, string, max chars=20)
    Zip or postal code. The number of characters is validated according to the rules [specified here](https://chromium-i18n.appspot.com/ssl-address) .
  - `country` (optional, string, max chars=50)
    The billing address country of the customer. Must be one of [ISO 3166 alpha-2 country code](https://www.iso.org/iso-3166-country-codes.html) .
    
    **Note**: If you enter an invalid country code, the system will return an error.
    
    **Brexit**
    
    If you have enabled [EU VAT](https://www.chargebee.com/docs/eu-vat.html) in 2021 or later, or have [manually enable](https://www.chargebee.com/docs/brexit.html#what-needs-to-be-done-in-chargebee) the Brexit configuration, then `XI` (the code for **United Kingdom - Northern Ireland**) is available as an option.
  - `validation_status` (optional, enumerated string, default=not_validated)
    The address verification status.
    Possible enum values:
      - `not_validated`
        Address is not yet validated.
      - `valid`
        Address was validated successfully.
      - `partially_valid`
        The address is valid for taxability but has not been validated for shipping.
      - `invalid`
        Address is invalid.

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

- `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) .
  - `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.
  - `service_period_in_days` (optional, integer)
    Defines service period of the addon in days from the day of charge.
  - `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.
  - `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.

## Returns

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