# Create invoice for items and one-time charges

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


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

Creates an invoice for [charge-items](/docs/api/items) and [one-time charges](https://www.chargebee.com/docs/billing/2.0/product-catalog/charges#adding-quick-charges). The item prices must belong to items of `type` `charge`.

You can optionally override the line item name and description displayed on the invoice for charge-item prices and one-time charges. When `create_pending_invoice` is `true`, the invoice is created in `pending` status without collecting payment. You can review the invoice, add more charges if needed, and close it later via the [close a pending invoice](/docs/api/invoices/close-a-pending-invoice) operation.

One-time charges are represented in an invoice as `line_items` with `entity_type` `adhoc`.

## Sample Request

### Creates an invoice for charges and quick charges for a customer.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices/create_for_charge_items_and_charges \
     -u {site_api_key}:\
     -d customer_id="__test__KyVkkWS1xLskm8" \
     -d "item_prices[item_price_id][0]"="ssl-charge-USD" \
     -d "item_prices[unit_price][0]"=2000 \
     -d "shipping_address[first_name]"="John" \
     -d "shipping_address[last_name]"="Mathew" \
     -d "shipping_address[city]"="Walnut" \
     -d "shipping_address[state]"="California" \
     -d "shipping_address[zip]"="91789" \
     -d "shipping_address[country]"="US"
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Invoice.CreateForChargeItemsAndCharges()
		.CustomerId("__test__KyVkkWS1xLskm8")
		.ItemPriceItemPriceId(0, "ssl-charge-USD")
		.ItemPriceUnitPrice(0, 2000)
		.ShippingAddressFirstName("John")
		.ShippingAddressLastName("Mathew")
		.ShippingAddressCity("Walnut")
		.ShippingAddressState("California")
		.ShippingAddressZip("91789")
		.ShippingAddressCountry("US")
		.Request();

Invoice invoice = result.Invoice;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    invoiceAction "github.com/chargebee/chargebee-go/v3/actions/invoice"
    "github.com/chargebee/chargebee-go/v3/models/invoice"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceAction.CreateForChargeItemsAndCharges(&invoice.CreateForChargeItemsAndChargesRequestParams{
        ItemPrices : []*invoice.CreateForChargeItemsAndChargesItemPriceParams{
            {
                ItemPriceId : "ssl-charge-USD",
                UnitPrice : chargebee.Int64(2000),
            },
        },
        CustomerId : "__test__KyVkkWS1xLskm8",
        ShippingAddress : &invoice.CreateForChargeItemsAndChargesShippingAddressParams{
            FirstName : "John",
            LastName : "Mathew",
            City : "Walnut",
            State : "California",
            Zip : "91789",
            Country : "US",
        },
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
    }
}
```

#### 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.InvoiceCreateForChargeItemsAndChargesRequest{
    ItemPrices : []*chargebee.InvoiceCreateForChargeItemsAndChargesItemPrice{
        {
            ItemPriceId : "ssl-charge-USD",
            UnitPrice : chargebee.Int64(2000),
        },
    },
    CustomerId : "__test__KyVkkWS1xLskm8",
    ShippingAddress : &chargebee.InvoiceCreateForChargeItemsAndChargesShippingAddress{
        FirstName : "John",
        LastName : "Mathew",
        City : "Walnut",
        State : "California",
        Zip : "91789",
        Country : "US",
    },
}
  res, err := client.Invoice.CreateForChargeItemsAndCharges(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
    }
}
```

#### 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 = Invoice.createForChargeItemsAndCharges()
            .customerId("__test__KyVkkWS1xLskm8")
            .itemPriceItemPriceId(0, "ssl-charge-USD")
            .itemPriceUnitPrice(0, 2000L)
            .shippingAddressFirstName("John")
            .shippingAddressLastName("Mathew")
            .shippingAddressCity("Walnut")
            .shippingAddressState("California")
            .shippingAddressZip("91789")
            .shippingAddressCountry("US")
            .request();

        Invoice invoice = result.invoice();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.invoice.params.InvoiceCreateForChargeItemsAndChargesParams;
import com.chargebee.v4.models.invoice.responses.InvoiceCreateForChargeItemsAndChargesResponse;
import java.util.List;

public class InvoiceCreateForChargeItemsAndCharges {

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

        InvoiceCreateForChargeItemsAndChargesParams.ShippingAddressParams shippingAddressParams =
            InvoiceCreateForChargeItemsAndChargesParams.ShippingAddressParams.builder()
                .firstName("John")
                .lastName("Mathew")
                .city("Walnut")
                .state("California")
                .zip("91789")
                .country("US")
                .build();

        InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams itemPrice0 =
            InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams.builder()
                .itemPriceId("ssl-charge-USD")
                .unitPrice(2000L)
                .build();

        List<InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams> itemPricesList =
            List.of(itemPrice0);

        InvoiceCreateForChargeItemsAndChargesParams params = InvoiceCreateForChargeItemsAndChargesParams.builder()
            .customerId("__test__KyVkkWS1xLskm8")
            .itemPrices(itemPricesList)
            .shippingAddress(shippingAddressParams)
            .build();

        InvoiceCreateForChargeItemsAndChargesResponse response = client.invoices().createForChargeItemsAndCharges(params);

        Invoice invoice = response.getInvoice();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.invoice.createForChargeItemsAndCharges({
        item_prices: [
            {
                item_price_id: "ssl-charge-USD",
                unit_price: 2000
            }
        ],
        customer_id: "__test__KyVkkWS1xLskm8",
        shipping_address: {
            first_name: "John",
            last_name: "Mathew",
            city: "Walnut",
            state: "California",
            zip: 91789,
            country: "US"
        }
    });

    console.log(result);
    const invoice = result.invoice;
} 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->invoice()->createForChargeItemsAndCharges([
    "item_prices" => [
        [
            "item_price_id" => "ssl-charge-USD",
            "unit_price" => 2000
        ]
    ],
    "customer_id" => "__test__KyVkkWS1xLskm8",
    "shipping_address" => [
        "first_name" => "John",
        "last_name" => "Mathew",
        "city" => "Walnut",
        "state" => "California",
        "zip" => "91789",
        "country" => "US"
    ]
]);
$invoice = $result->invoice;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Invoice.create_for_charge_items_and_charges(
    cb_client.Invoice.CreateForChargeItemsAndChargesParams(
        item_prices=[
            cb_client.Invoice.CreateForChargeItemsAndChargesItemPriceParams(
              item_price_id="ssl-charge-USD",
              unit_price=2000
            )
        ],
        customer_id="__test__KyVkkWS1xLskm8",
        shipping_address=cb_client.Invoice.CreateForChargeItemsAndChargesShippingAddressParams(
            first_name="John",
            last_name="Mathew",
            city="Walnut",
            state="California",
            zip="91789",
            country="US"
        )
    )
)
invoice = response.invoice
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Invoice.create_for_charge_items_and_charges({
  :customer_id => "__test__KyVkkWS1xLskm8",
  :item_prices => [
    {
      :item_price_id => "ssl-charge-USD",
      :unit_price => 2000
    }
  ],
  :shipping_address => {
    :first_name => "John",
    :last_name => "Mathew",
    :city => "Walnut",
    :state => "California",
    :zip => "91789",
    :country => "US"
  }
})

invoice = result.invoice
```

### Creates a pending invoice for charge items on a subscription without collecting payment.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices/create_for_charge_items_and_charges \
     -u {site_api_key}:\
     -d subscription_id="__test__KyVnTS1xLskm8" \
     -d create_pending_invoice="true" \
     -d "item_prices[item_price_id][0]"="ssl-charge-USD" \
     -d "item_prices[unit_price][0]"=2000
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Invoice.CreateForChargeItemsAndCharges()
		.SubscriptionId("__test__KyVnTS1xLskm8")
		.CreatePendingInvoice(true)
		.ItemPriceItemPriceId(0, "ssl-charge-USD")
		.ItemPriceUnitPrice(0, 2000)
		.Request();

Invoice invoice = result.Invoice;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    invoiceAction "github.com/chargebee/chargebee-go/v3/actions/invoice"
    "github.com/chargebee/chargebee-go/v3/models/invoice"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceAction.CreateForChargeItemsAndCharges(&invoice.CreateForChargeItemsAndChargesRequestParams{
        ItemPrices : []*invoice.CreateForChargeItemsAndChargesItemPriceParams{
            {
                ItemPriceId : "ssl-charge-USD",
                UnitPrice : chargebee.Int64(2000),
            },
        },
        SubscriptionId : "__test__KyVnTS1xLskm8",
        CreatePendingInvoice : chargebee.Bool(true),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
    }
}
```

#### 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.InvoiceCreateForChargeItemsAndChargesRequest{
    ItemPrices : []*chargebee.InvoiceCreateForChargeItemsAndChargesItemPrice{
        {
            ItemPriceId : "ssl-charge-USD",
            UnitPrice : chargebee.Int64(2000),
        },
    },
    SubscriptionId : "__test__KyVnTS1xLskm8",
    CreatePendingInvoice : chargebee.Bool(true),
}
  res, err := client.Invoice.CreateForChargeItemsAndCharges(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
    }
}
```

#### 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 = Invoice.createForChargeItemsAndCharges()
            .subscriptionId("__test__KyVnTS1xLskm8")
            .createPendingInvoice(true)
            .itemPriceItemPriceId(0, "ssl-charge-USD")
            .itemPriceUnitPrice(0, 2000L)
            .request();

        Invoice invoice = result.invoice();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.invoice.params.InvoiceCreateForChargeItemsAndChargesParams;
import com.chargebee.v4.models.invoice.responses.InvoiceCreateForChargeItemsAndChargesResponse;
import java.util.List;

public class InvoiceCreateForChargeItemsAndCharges {

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

        InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams itemPrice0 =
            InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams.builder()
                .itemPriceId("ssl-charge-USD")
                .unitPrice(2000L)
                .build();

        List<InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams> itemPricesList =
            List.of(itemPrice0);

        InvoiceCreateForChargeItemsAndChargesParams params = InvoiceCreateForChargeItemsAndChargesParams.builder()
            .subscriptionId("__test__KyVnTS1xLskm8")
            .createPendingInvoice(true)
            .itemPrices(itemPricesList)
            .build();

        InvoiceCreateForChargeItemsAndChargesResponse response = client.invoices().createForChargeItemsAndCharges(params);

        Invoice invoice = response.getInvoice();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.invoice.createForChargeItemsAndCharges({
        item_prices: [
            {
                item_price_id: "ssl-charge-USD",
                unit_price: 2000
            }
        ],
        subscription_id: "__test__KyVnTS1xLskm8",
        create_pending_invoice: true
    });

    console.log(result);
    const invoice = result.invoice;
} 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->invoice()->createForChargeItemsAndCharges([
    "item_prices" => [
        [
            "item_price_id" => "ssl-charge-USD",
            "unit_price" => 2000
        ]
    ],
    "subscription_id" => "__test__KyVnTS1xLskm8",
    "create_pending_invoice" => true
]);
$invoice = $result->invoice;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Invoice.create_for_charge_items_and_charges(
    cb_client.Invoice.CreateForChargeItemsAndChargesParams(
        item_prices=[
            cb_client.Invoice.CreateForChargeItemsAndChargesItemPriceParams(
              item_price_id="ssl-charge-USD",
              unit_price=2000
            )
        ],
        subscription_id="__test__KyVnTS1xLskm8",
        create_pending_invoice=True
    )
)
invoice = response.invoice
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Invoice.create_for_charge_items_and_charges({
  :subscription_id => "__test__KyVnTS1xLskm8",
  :create_pending_invoice => "true",
  :item_prices => [
    {
      :item_price_id => "ssl-charge-USD",
      :unit_price => 2000
    }
  ]
})

invoice = result.invoice
```

### Creates an invoice with overridden line item name and description for charge items and one-time charges.

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices/create_for_charge_items_and_charges \
     -u {site_api_key}:\
     -d customer_id="__test__KyVkkWS1xLskm8" \
     -d "item_prices[item_price_id][0]"="ssl-charge-USD" \
     -d "item_prices[description][0]"="Custom SSL setup fee" \
     -d "item_prices[entity_description][0]"="One-time SSL certificate installation and configuration." \
     -d "charges[amount][0]"=500 \
     -d "charges[description][0]"="Priority support" \
     -d "charges[entity_description][0]"="24-hour priority support for the billing period."
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Invoice.CreateForChargeItemsAndCharges()
		.CustomerId("__test__KyVkkWS1xLskm8")
		.ItemPriceItemPriceId(0, "ssl-charge-USD")
		.ItemPriceDescription(0, "Custom SSL setup fee")
		.ItemPriceEntityDescription(0, "One-time SSL certificate installation and configuration.")
		.ChargeAmount(0, 500)
		.ChargeDescription(0, "Priority support")
		.ChargeEntityDescription(0, "24-hour priority support for the billing period.")
		.Request();

Invoice invoice = result.Invoice;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    invoiceAction "github.com/chargebee/chargebee-go/v3/actions/invoice"
    "github.com/chargebee/chargebee-go/v3/models/invoice"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := invoiceAction.CreateForChargeItemsAndCharges(&invoice.CreateForChargeItemsAndChargesRequestParams{
        ItemPrices : []*invoice.CreateForChargeItemsAndChargesItemPriceParams{
            {
                ItemPriceId : "ssl-charge-USD",
                Description : "Custom SSL setup fee",
                EntityDescription : "One-time SSL certificate installation and configuration.",
            },
        },
        Charges : []*invoice.CreateForChargeItemsAndChargesChargeParams{
            {
                Amount : chargebee.Int64(500),
                Description : "Priority support",
                EntityDescription : "24-hour priority support for the billing period.",
            },
        },
        CustomerId : "__test__KyVkkWS1xLskm8",
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
    }
}
```

#### 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.InvoiceCreateForChargeItemsAndChargesRequest{
    ItemPrices : []*chargebee.InvoiceCreateForChargeItemsAndChargesItemPrice{
        {
            ItemPriceId : "ssl-charge-USD",
            Description : "Custom SSL setup fee",
            EntityDescription : "One-time SSL certificate installation and configuration.",
        },
    },
    Charges : []*chargebee.InvoiceCreateForChargeItemsAndChargesCharge{
        {
            Amount : chargebee.Int64(500),
            Description : "Priority support",
            EntityDescription : "24-hour priority support for the billing period.",
        },
    },
    CustomerId : "__test__KyVkkWS1xLskm8",
}
  res, err := client.Invoice.CreateForChargeItemsAndCharges(req)
      if err != nil {
        fmt.Println(err)
    } else {
        Invoice := res.Invoice
    }
}
```

#### 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 = Invoice.createForChargeItemsAndCharges()
            .customerId("__test__KyVkkWS1xLskm8")
            .itemPriceItemPriceId(0, "ssl-charge-USD")
            .itemPriceDescription(0, "Custom SSL setup fee")
            .itemPriceEntityDescription(0, "One-time SSL certificate installation and configuration.")
            .chargeAmount(0, 500L)
            .chargeDescription(0, "Priority support")
            .chargeEntityDescription(0, "24-hour priority support for the billing period.")
            .request();

        Invoice invoice = result.invoice();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.invoice.Invoice;
import com.chargebee.v4.models.invoice.params.InvoiceCreateForChargeItemsAndChargesParams;
import com.chargebee.v4.models.invoice.responses.InvoiceCreateForChargeItemsAndChargesResponse;
import java.util.List;

public class InvoiceCreateForChargeItemsAndCharges {

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

        InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams itemPrice0 =
            InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams.builder()
                .itemPriceId("ssl-charge-USD")
                .description("Custom SSL setup fee")
                .entityDescription("One-time SSL certificate installation and configuration.")
                .build();

        List<InvoiceCreateForChargeItemsAndChargesParams.ItemPricesParams> itemPricesList =
            List.of(itemPrice0);

        InvoiceCreateForChargeItemsAndChargesParams.ChargesParams charge0 =
            InvoiceCreateForChargeItemsAndChargesParams.ChargesParams.builder()
                .amount(500L)
                .description("Priority support")
                .entityDescription("24-hour priority support for the billing period.")
                .build();

        List<InvoiceCreateForChargeItemsAndChargesParams.ChargesParams> chargesList =
            List.of(charge0);

        InvoiceCreateForChargeItemsAndChargesParams params = InvoiceCreateForChargeItemsAndChargesParams.builder()
            .customerId("__test__KyVkkWS1xLskm8")
            .itemPrices(itemPricesList)
            .charges(chargesList)
            .build();

        InvoiceCreateForChargeItemsAndChargesResponse response = client.invoices().createForChargeItemsAndCharges(params);

        Invoice invoice = response.getInvoice();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.invoice.createForChargeItemsAndCharges({
        item_prices: [
            {
                item_price_id: "ssl-charge-USD",
                description: "Custom SSL setup fee",
                entity_description: "One-time SSL certificate installation and configuration."
            }
        ],
        charges: [
            {
                amount: 500,
                description: "Priority support",
                entity_description: "24-hour priority support for the billing period."
            }
        ],
        customer_id: "__test__KyVkkWS1xLskm8"
    });

    console.log(result);
    const invoice = result.invoice;
} 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->invoice()->createForChargeItemsAndCharges([
    "item_prices" => [
        [
            "item_price_id" => "ssl-charge-USD",
            "description" => "Custom SSL setup fee",
            "entity_description" => "One-time SSL certificate installation and configuration."
        ]
    ],
    "charges" => [
        [
            "amount" => 500,
            "description" => "Priority support",
            "entity_description" => "24-hour priority support for the billing period."
        ]
    ],
    "customer_id" => "__test__KyVkkWS1xLskm8"
]);
$invoice = $result->invoice;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Invoice.create_for_charge_items_and_charges(
    cb_client.Invoice.CreateForChargeItemsAndChargesParams(
        item_prices=[
            cb_client.Invoice.CreateForChargeItemsAndChargesItemPriceParams(
              item_price_id="ssl-charge-USD",
              description="Custom SSL setup fee",
              entity_description="One-time SSL certificate installation and configuration."
            )
        ],
        charges=[
            cb_client.Invoice.CreateForChargeItemsAndChargesChargeParams(
              amount=500,
              description="Priority support",
              entity_description="24-hour priority support for the billing period."
            )
        ],
        customer_id="__test__KyVkkWS1xLskm8"
    )
)
invoice = response.invoice
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Invoice.create_for_charge_items_and_charges({
  :customer_id => "__test__KyVkkWS1xLskm8",
  :item_prices => [
    {
      :item_price_id => "ssl-charge-USD",
      :description => "Custom SSL setup fee",
      :entity_description => "One-time SSL certificate installation and configuration."
    }
  ],
  :charges => [
    {
      :amount => 500,
      :description => "Priority support",
      :entity_description => "24-hour priority support for the billing period."
    }
  ]
})

invoice = result.invoice
```

## Sample Response

```json
{
  "invoice": {
    "adjustment_credit_notes": {},
    "amount_adjusted": 0,
    "amount_due": 0,
    "amount_paid": 2000,
    "amount_to_collect": 0,
    "applied_credits": {},
    "base_currency_code": "USD",
    "billing_address": {
      "first_name": "John",
      "last_name": "Mathew",
      "object": "billing_address",
      "validation_status": "not_validated"
    },
    "credits_applied": 0,
    "currency_code": "USD",
    "customer_id": "__test__KyVkkWS1xLskm8",
    "date": 1517463749,
    "deleted": false,
    "due_date": 1517463749,
    "dunning_attempts": {},
    "exchange_rate": 1,
    "exchange_rates": [
      {
        "currency_code": "EUR",
        "rate": 1.154
      },
      {..}
    ],
    "first_invoice": true,
    "has_advance_charges": false,
    "id": "__demo_inv__1",
    "is_gifted": false,
    "issued_credit_notes": {},
    "line_items": [
      {
        "amount": 2000,
        "customer_id": "__test__KyVkkWS1xLskm8",
        "date_from": 1517463749,
        "date_to": 1517463749,
        "description": "SSL Charge USD Monthly",
        "discount_amount": 0,
        "entity_id": "ssl-charge-USD",
        "entity_type": "charge_item_price",
        "id": "li___test__KyVkkWS1xLt9LF",
        "is_taxed": false,
        "item_level_discount_amount": 0,
        "object": "line_item",
        "pricing_model": "flat_fee",
        "quantity": 1,
        "tax_amount": 0,
        "tax_exempt_reason": "tax_not_configured",
        "unit_amount": 2000
      },
      {..}
    ],
    "linked_orders": {},
    "linked_payments": [
      {
        "applied_amount": 2000,
        "applied_at": 1517463750,
        "txn_amount": 2000,
        "txn_date": 1517463750,
        "txn_id": "txn___test__KyVkkWS1xLtFiG",
        "txn_status": "success"
      },
      {..}
    ],
    "net_term_days": 0,
    "new_sales_amount": 2000,
    "object": "invoice",
    "paid_at": 1517463750,
    "price_type": "tax_exclusive",
    "recurring": false,
    "resource_version": 1517463750000,
    "round_off_amount": 0,
    "shipping_address": {
      "city": "Walnut",
      "country": "US",
      "first_name": "John",
      "last_name": "Mathew",
      "object": "shipping_address",
      "state": "California",
      "state_code": "CA",
      "validation_status": "not_validated",
      "zip": "91789"
    },
    "status": "paid",
    "sub_total": 2000,
    "tax": 0,
    "term_finalized": true,
    "total": 2000,
    "updated_at": 1517463750,
    "write_off_amount": 0
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/invoices/create_for_charge_items_and_charges

## Input Parameters

- `customer_id` (optional, string, max chars=50)
  Unique ID of the customer this invoice should be created for. Either this or `subscription_id` must be provided.
  
  **Note**
  
  The invoice is [linked](/docs/api/getting-started) to the same [business entity](/docs/api/getting-started) as this customer.

- `subscription_id` (optional, string, max chars=50)
  Unique ID of the subscription this invoice should be created for. Either this or `customer_id` must be provided.
  
  **Note**
  
  The invoice is [linked](/docs/api/getting-started) to the same [business entity](/docs/api/getting-started) as this subscription.

- `currency_code` (required if Multicurrency is enabled, string, max chars=3)
  The currency code (ISO 4217 format) of the invoice amount.

- `invoice_note` (optional, string, max chars=2000)
  A note for this particular invoice. This, and [all other notes](/docs/api/invoices/invoice-object#notes) for the invoice are displayed on the PDF invoice sent to the customer.

- `remove_general_note` (optional, boolean, default=false)
  Set as `true` to remove the [**general note**](https://www.chargebee.com/docs/invoice_notes.html#adding-general-notes) from this invoice.

- `po_number` (optional, string, max chars=100)
  Purchase Order Number for this invoice.

- `coupon_ids` (optional, string, max chars=100)
  List of Coupons to be added.

- `authorization_transaction_id` (optional, string, max chars=40)
  Authorization transaction to be captured.

- `payment_source_id` (optional, string, max chars=40)
  Payment source to be used for this payment.

- `auto_collection` (optional, enumerated string)
  If specified, the customer level auto collection will be overridden.
  
  **Note**
  
  -   When `create_pending_invoice` is `true`, `auto_collection` cannot be passed. When the pending invoice is closed, the [subscription](/docs/api/subscriptions/subscription-object#auto_collection) `auto_collection` setting is used when available; otherwise, the [customer](/docs/api/customers/customer-object#auto_collection) `auto_collection` setting applies.
  Possible enum values:
    - `on`
      Whenever an invoice is created, an automatic attempt will be made to charge.
    - `off`
      Whenever an invoice is created as payment due.

- `net_term_days` (optional, integer)
  The [Net D](https://www.chargebee.com/docs/billing/2.0/subscriptions/net_d) value explicitly set for this invoice. Net D is the number of days within which the invoice must be paid. When this value is provided, it overrides the payment terms defined at the subscription or customer level. **Note:** This value is used only for this invoice operation and does not update the customer or subscription records.

- `invoice_date` (optional, timestamp(UTC) in seconds)
  The document date displayed on the invoice PDF. By default, it is the date of creation of the invoice or, when Metered Billing is enabled, it can be the date of closing the invoice. Provide this value to backdate the invoice (set the invoice date to a value in the past). Backdating an invoice is done for reasons such as booking revenue for a previous date or when the non-recurring charge is effective as of a past date. `taxes` and `line_item_taxes` are computed based on the tax configuration as of this date. The date should not be 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.

- `create_pending_invoice` (optional, boolean)
  When set to `true`, the invoice is created with `status` as `pending` and payment is not collected. The invoice can be closed later via the [close a pending invoice](/docs/api/invoices/close-a-pending-invoice) operation.
  
  **Prerequisites**
  
  -   [Usage-based billing](https://www.chargebee.com/docs/billing/2.0/usage-based-billing/setting-up-usage-based-billing) must be enabled for the site.
  -   `subscription_id` must be provided.
  
  **Constraints**
  
  -   Payment collection parameters cannot be passed when this parameter is `true`. This includes `payment_source_id`, `authorization_transaction_id`, `auto_collection`, `payment_method` parameters, `card` parameters, `payment_intent` parameters, and `token_id`.
  -   `auto_collection` cannot be overridden on this request. When the pending invoice is closed, the [subscription](/docs/api/subscriptions/subscription-object#auto_collection) or [customer](/docs/api/customers/customer-object#auto_collection) `auto_collection` setting applies.

- `token_id` (optional, string, max chars=40)
  Token generated by Chargebee JS representing payment method details.

- `replace_primary_payment_source` (optional, boolean, default=false)
  Indicates whether the primary payment source should be replaced with this payment source. In case of Create Subscription for Customer endpoint, the default value is True. Otherwise, the default value is False.

- `retain_payment_source` (optional, boolean, default=true)
  Indicates whether the payment source should be retained for the customer.

- `payment_initiator` (optional, enumerated string)
  The type of initiator to be used for the payment request triggered by this operation.
  Possible enum values:
    - `customer`
      Pass this value to indicate that the request is initiated by the customer
    - `merchant`
      Pass this value to indicate that the request is initiated by the merchant

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

- `statement_descriptor` (optional, string)
  Parameters for statement\_descriptor
  - `descriptor` (optional, string, max chars=65k)
    Payment descriptor text

- `card` (optional, string)
  Parameters for card
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.
  - `first_name` (optional, string, max chars=50)
    Cardholder's first name
  - `last_name` (optional, string, max chars=50)
    Cardholder's last name
  - `number` (required if card provided, string, max chars=1500)
    The credit card number without any format. If you are using [Braintree.js](https://developer.paypal.com/braintree/docs/guides/client-sdk/setup/javascript/v2#getting-braintree.js) , you can specify the Braintree encrypted card number here.
  - `expiry_month` (required if card provided, integer, min=1, max=12)
    Card expiry month.
  - `expiry_year` (required if card provided, integer)
    Card expiry year.
  - `cvv` (optional, string, max chars=520)
    The card verification value (CVV). If you are using [Braintree.js](https://developer.paypal.com/braintree/docs/guides/client-sdk/setup/javascript/v2#getting-braintree.js) , you can specify the Braintree encrypted CVV here.
  - `preferred_scheme` (optional, enumerated string)
    The customer's preferred card scheme for co-branded cards.
    
    **Note**: Currently, this parameter is only supported for Stripe.
    Possible enum values:
      - `cartes_bancaires`
        A Cartes Bancaires card scheme.
      - `mastercard`
        A MasterCard scheme.
      - `visa`
        A Visa card scheme.
  - `billing_addr1` (optional, string, max chars=150)
    Address line 1, as available in card billing address.
  - `billing_addr2` (optional, string, max chars=150)
    Address line 2, as available in card billing address.
  - `billing_city` (optional, string, max chars=50)
    City, as available in card billing address.
  - `billing_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 `billing_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` ).
  - `billing_state` (optional, string, max chars=50)
    The state/province name. Is set by Chargebee automatically for US, Canada, India and UAE, if `billing_state_code` is provided.
  - `billing_zip` (optional, string, max chars=20)
    Postal or Zip code, as available in card billing address.
  - `billing_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.
  - `additional_information` (optional, jsonobject)
    -   `checkout_com`: While adding a new payment method using [permanent token](/docs/api/payment_sources/create-using-permanent-token) or passing raw card details to Checkout.com, `document` ID and `country_of_residence` are required to support payments through [dLocal](https://www.checkout.com/docs/previous/payments/payment-methods/cards/dlocal).
        
        -   `payer`: User related information.
            -   `country_of_residence`: This is required since the billing country associated with the user's payment method may not be the same as their country of residence. Hence the user's country of residence needs to be specified. The country code should be a [two-character ISO code](https://docs.checkout.com/resources/codes/country-codes).
            -   `document`: Document ID is the user's [identification number](https://docs.dlocal.com/api-documentation/payins-api-reference/country-reference#documents) based on their country.
    -   `bluesnap`: While passing raw card details to BlueSnap, if `fraud_session_id` is added, [additional validation](https://developers.bluesnap.com/docs/fraud-prevention) is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your [BlueSnap fraud session ID](https://developers.bluesnap.com/docs/fraud-prevention#section-implementing-device-data-collector) required to perform anti-fraud validation.
    -   `braintree`: While passing raw card details to Braintree, your `fraud_merchant_id` and the user's `device_session_id` can be added to perform [additional validation](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
            -   `fraud_merchant_id`: Your [merchant ID](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) for fraud detection.
    -   `chargebee_payments`: While passing raw card details to Chargebee Payments, if `fraud_session_id` is added, additional validation is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your Chargebee Payments fraud session ID required to perform anti-fraud validation.
    -   `bank_of_america`: While passing raw card details to Bank of America, your user's `device_session_id` can be added to perform additional validation and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
    -   `ecentric`: This parameter is used to verify and process payment method details in Ecentric. If the `merchant_id` parameter is included, Chargebee will vault it / perform a lookup and verification against this `merchant_id`, overriding the one configured in Chargebee. If tokens and processing occur in the same Merchant GUID, you can just skip this part.
        
        -   `merchant_id`: Merchant GUID where the card is vaulted or need to be vaulted.
    -   `ebanx`: While passing raw card details to EBANX, the user's `document` is required for some countries and `device_session_id` can be added to perform [additional validation](https://developer.ebanx.com/docs/payments/guides/features/device-fingerprint#device-fingerprint) and avoid fraudulent transactions.
        
        -   `payer`: User related information.
            -   `document`: Document is the user's identification number based on their country.
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device

- `bank_account` (optional, string)
  Parameters for bank\_account
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.
  - `iban` (optional, string, min chars=10, max chars=50)
    Account holder's International Bank Account Number. For the [GoCardless](https://www.chargebee.com/docs/gocardless.html) platform, this can be the [local bank details](https://developer.gocardless.com/api-reference/#appendix-local-bank-details)
  - `first_name` (optional, string, max chars=150)
    Account holder's first name as per bank account. If not passed, details from customer details will be considered.
  - `last_name` (optional, string, max chars=150)
    Account holder's last name as per bank account. If not passed, details from customer details will be considered.
  - `company` (optional, string, max chars=250)
    Account holder's company name as per bank account. If not passed, details from customer details will be considered.
  - `email` (optional, string, max chars=70)
    Account holder's email address. If not passed, details from customer details will be considered. All Direct Debit compliant emails will be sent to this email address.
  - `phone` (optional, string, max chars=50)
    Phone number of the account holder that is linked to the bank account.
  - `bank_name` (optional, string, max chars=100)
    Name of account holder's bank.
  - `account_number` (optional, string, min chars=4, max chars=17)
    Account holder's bank account number.
  - `routing_number` (optional, string, min chars=3, max chars=9)
    Bank account routing number.
  - `bank_code` (optional, string, max chars=20)
    Indicates the bank code.
  - `account_type` (optional, enumerated string)
    Represents the account type used to create a payment source. Available for [Authorize.net](https://www.authorize.net/) ACH and Razorpay NetBanking users only. If not passed, account type is taken as null.
    Possible enum values:
      - `checking`
        Checking Account
      - `savings`
        Savings Account
      - `business_checking`
        Business Checking Account
      - `current`
        Current Account
  - `account_holder_type` (optional, enumerated string)
    For Stripe ACH users only. Indicates the account holder type.
    Possible enum values:
      - `individual`
        Individual Account.
      - `company`
        Company Account.
  - `echeck_type` (optional, enumerated string)
    For Authorize.net ACH users only. Indicates the type of eCheck.
    Possible enum values:
      - `web`
        Payment Authorization obtained from the customer via the internet.
      - `ppd`
        Payment Authorization is prearranged between the customer and the merchant.
      - `ccd`
        Payment Authorization agreement from the corporate customer is required. Applicable for business\_checking account\_type.
  - `issuing_country` (optional, string, max chars=50)
    [two-letter(alpha2)](https://www.iso.org/iso-3166-country-codes.html) ISO country code. Required when local bank details are provided, and not IBAN.
  - `swedish_identity_number` (optional, string, min chars=10, max chars=12)
    For GoCardless Autogiro users only. The civic/company number (personnummer, samordningsnummer, or organisationsnummer) of the customer. Must be supplied if the customer's bank account is denominated in Swedish krona (SEK). This field cannot be changed once it has been set.
  - `billing_address` (optional, jsonobject)
    The billing address associated with the bank account. The value is a JSON object with the following keys and their values:- `first_name`:(string, max chars=150) The first name of the contact.
    
    -   `last_name`:(string, max chars=150) The last name of the contact.
    -   `company_name`:(string, max chars=250) The company name for the address.
    -   `line1`:(string, max chars=180) The first line of the address.
    -   `line2`:(string, max chars=180) The second line of the address.
    -   `country`:(string) The name of the country for the address.
    -   `country_code`:(string, max chars=50) The two-letter, [ISO 3166 alpha-2](https://www.iso.org/iso-3166-country-codes.html) country code for the address.
    -   `state`:(string, max chars=50) The name of the state or province for the address. When not provided, this is set automatically for US, Canada, India, and UAE.
    -   `state_code`:(string, max chars=50) The [ISO 3166-2 state/province code](https://www.iso.org/obp/ui/#search/code/) without the country prefix. This is 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`).
    -   `city`:(string, max chars=50) The city name for the address.
    -   `postal_code`:(string, max chars=20) The postal or ZIP code for the address.
    -   `phone`:(string, max chars=50) The contact phone number for the address.
    -   `email`:(string, max chars=70) The contact email address for the address.

- `payment_method` (optional, enumerated string)
  Parameters for payment\_method
  - `type` (optional, enumerated string)
    The type of payment method. For more details refer [Update payment method for a customer](/docs/api/customers/update-payment-method-for-a-customer) API under Customer resource.
    Possible enum values:
      - `card`
        Card based payment including credit cards and debit cards. Details about the card can be obtained from the card resource.
      - `paypal_express_checkout`
        Payments made via PayPal Express Checkout.
      - `amazon_payments`
        Payments made via Amazon Payments.
      - `direct_debit`
        Represents bank account for which the direct debit or ACH agreement/mandate is created.
      - `generic`
        Payments made via Generic Payment Method.
      - `alipay`
        Payments made via Alipay.
        
        This payment source is deprecated.
      - `unionpay`
        Payments made via UnionPay.
      - `apple_pay`
        Payments made via Apple Pay.
      - `wechat_pay`
        Payments made via WeChat Pay.
        
        This payment source is deprecated.
      - `ideal`
        Payments made via iDEAL.
      - `google_pay`
        Payments made via Google Pay.
      - `sofort`
        Payments made via Sofort.
      - `bancontact`
        Payments made via Bancontact Card.
      - `giropay`
        Payments made via giropay.
      - `dotpay`
        Payments made via Dotpay.
      - `upi`
        UPI Payments.
      - `netbanking_emandates`
        Netbanking (eMandates) Payments.
      - `venmo`
        Payments made via Venmo
      - `pay_to`
        Payments made via PayTo
      - `faster_payments`
        Payments made via Faster Payments
      - `sepa_instant_transfer`
        Payments made via Sepa Instant Transfer
      - `automated_bank_transfer`
        Represents virtual bank account using which the payment will be done.
      - `klarna_pay_now`
        Payments made via Klarna Pay Now
      - `online_banking_poland`
        Payments made via Online Banking Poland
      - `payconiq_by_bancontact`
        Payments made via Payconiq by Bancontact.
      - `electronic_payment_standard`
        Electronic Payment Standard
      - `kbc_payment_button`
        KBC Payment Button
      - `pay_by_bank`
        Pay By Bank
      - `trustly`
        Trustly
      - `stablecoin`
        Payments made via Stablecoin.
      - `kakao_pay`
        Payments made via Kakao Pay.
      - `naver_pay`
        Payments made via Naver Pay.
      - `revolut_pay`
        Payments made via Revolut Pay.
      - `cash_app_pay`
        Payments made via Cash App Pay.
      - `twint`
        Payments made via Twint
      - `go_pay`
        Payments made via GoPay
      - `grab_pay`
        Payments made via GrabPay
      - `pay_co`
        Payments made via PayCo
      - `after_pay`
        Payments made via Afterpay
      - `swish`
        Payments made via Swish
      - `payme`
        Payments made via PayMe
      - `pix`
        Payments made via Pix
      - `klarna`
        Payments made via Klarna.
      - `alipay_hk`
        Payments made via Alipay HK.
      - `paypay`
        Payments made via PayPay
      - `gcash`
        Payments made via GCash.
      - `south_korean_cards`
        Payments made via South Korean Cards
      - `paynow`
      - `bizum`
      - `promptpay`
      - `dana`
        Payments made via Dana.
      - `touch_n_go`
        Payments made via Touch 'n Go.
      - `tamara`
        Payments made via Tamara.
      - `qpay`
        Payments made via Qpay.
      - `ovo`
      - `momo`
      - `mercado_pago`
      - `nequi`
      - `nupay`
      - `picpay`
      - `thai_qr`
      - `blik`
      - `fpx`
      - `wero`
      - `p24`
      - `affirm_pay`
      - `rakuten_pay`
  - `gateway_account_id` (optional, string, max chars=50)
    The gateway account in which this payment source is stored.
  - `reference_id` (optional, string, max chars=200)
    The reference id. In the case of Amazon and PayPal this will be the _billing agreement id_. For GoCardless direct debit this will be 'mandate id'. In the case of card this will be the identifier provided by the gateway/card vault for the specific payment method resource. **Note:** This is not the one-time temporary token provided by gateways like Stripe.
    
    For more details refer [Update payment method for a customer](/docs/api/customers/update-payment-method-for-a-customer) API under Customer resource.
  - `tmp_token` (required if reference_id not provided, string, max chars=65k)
    Single-use tokens created by payment gateways. In Stripe, a single-use token is created for Apple Pay Wallet, card details or direct debit. In Braintree, a nonce is created for Apple Pay Wallet, PayPal, or card details. In Authorize.Net, a nonce is created for card details. In Adyen, an encrypted data is created from the card details.
  - `issuing_country` (optional, string, max chars=50)
    [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.
    
    If 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, then `XI` (the code for **United Kingdom - Northern Ireland** ) is available as an option.
  - `additional_information` (optional, jsonobject)
    -   `checkout_com`: While adding a new payment method using [permanent token](/docs/api/payment_sources/create-using-permanent-token) or passing raw card details to Checkout.com, `document` ID and `country_of_residence` are required to support payments through [dLocal](https://www.checkout.com/docs/previous/payments/payment-methods/cards/dlocal).
        
        -   `payer`: User related information.
            -   `country_of_residence`: This is required since the billing country associated with the user's payment method may not be the same as their country of residence. Hence the user's country of residence needs to be specified. The country code should be a [two-character ISO code](https://docs.checkout.com/resources/codes/country-codes).
            -   `document`: Document ID is the user's [identification number](https://docs.dlocal.com/api-documentation/payins-api-reference/country-reference#documents) based on their country.
    -   `bluesnap`: While passing raw card details to BlueSnap, if `fraud_session_id` is added, [additional validation](https://developers.bluesnap.com/docs/fraud-prevention) is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your [BlueSnap fraud session ID](https://developers.bluesnap.com/docs/fraud-prevention#section-implementing-device-data-collector) required to perform anti-fraud validation.
    -   `braintree`: While passing raw card details to Braintree, your `fraud_merchant_id` and the user's `device_session_id` can be added to perform [additional validation](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
            -   `fraud_merchant_id`: Your [merchant ID](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) for fraud detection.
    -   `chargebee_payments`: While passing raw card details to Chargebee Payments, if `fraud_session_id` is added, additional validation is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your Chargebee Payments fraud session ID required to perform anti-fraud validation.
    -   `bank_of_america`: While passing raw card details to Bank of America, your user's `device_session_id` can be added to perform additional validation and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
    -   `ecentric`: This parameter is used to verify and process payment method details in Ecentric. If the `merchant_id` parameter is included, Chargebee will vault it / perform a lookup and verification against this `merchant_id`, overriding the one configured in Chargebee. If tokens and processing occur in the same Merchant GUID, you can just skip this part.
        
        -   `merchant_id`: Merchant GUID where the card is vaulted or need to be vaulted.
    -   `ebanx`: While passing raw card details to EBANX, the user's `document` is required for some countries and `device_session_id` can be added to perform [additional validation](https://developer.ebanx.com/docs/payments/guides/features/device-fingerprint#device-fingerprint) and avoid fraudulent transactions.
        
        -   `payer`: User related information.
            -   `document`: Document is the user's identification number based on their country.
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device

- `payment_intent` (optional, string)
  Parameters for payment\_intent
  - `id` (optional, string, max chars=150)
    Identifier for PaymentIntent generated by Chargebee.js. Applicable only when you are using Chargebee.js for completing the 3DS flow. The PaymentIntent should be in 'authorized' state while passing it here. You need not pass other PaymentIntent parameters if this is passed.
  - `gateway_account_id` (required if payment intent token provided, string, max chars=50)
    The gateway account used for performing the 3DS flow.
  - `gw_token` (optional, string, max chars=65k)
    Identifier for 3DS transaction/verification object at the gateway. Can be passed only after successfully completing the 3DS flow. Refer [3DS implementation in Chargebee](/docs/api/3ds_card_payments) to find out the gateway-specific gw\_token format. Applicable when you are using gateway APIs directly for completing the 3DS flow.
  - `payment_method_type` (optional, enumerated string)
    The list of payment method types (For example, card, ideal, sofort, bancontact, etc.) this Payment Intent is allowed to use. If payment method type is empty, Card is taken as the default type for all gateways except Razorpay.
    Possible enum values:
      - `card`
        card
      - `ideal`
        ideal
      - `sofort`
        sofort
      - `bancontact`
        bancontact
      - `google_pay`
        google\_pay
      - `dotpay`
        dotpay
      - `giropay`
        giropay
      - `apple_pay`
        apple\_pay
      - `upi`
        upi
      - `netbanking_emandates`
        netbanking\_emandates
      - `paypal_express_checkout`
        paypal\_express\_checkout
      - `direct_debit`
        direct\_debit
      - `boleto`
        boleto
      - `venmo`
      - `amazon_payments`
        amazon\_payments
      - `pay_to`
      - `faster_payments`
      - `sepa_instant_transfer`
      - `klarna_pay_now`
        Klarna Pay Now
      - `online_banking_poland`
        Online Banking Poland
      - `payconiq_by_bancontact`
        Payments made via Payconiq by Bancontact.
      - `electronic_payment_standard`
        Electronic Payment Standard
      - `kbc_payment_button`
        KBC Payment Button
      - `pay_by_bank`
        Pay By Bank
      - `trustly`
        Trustly
      - `stablecoin`
        Payments made via Stablecoin.
      - `kakao_pay`
        Payments made via Kakao Pay.
      - `naver_pay`
        Payments made via Naver Pay.
      - `revolut_pay`
        Payments made via Revolut Pay.
      - `cash_app_pay`
        Payments made via Cash App Pay.
      - `wechat_pay`
        Payments made via WeChat Pay.
      - `alipay`
        Payments made via Alipay.
      - `twint`
        Payments made via Twint
      - `go_pay`
        Payments made via GoPay
      - `grab_pay`
        Payments made via GrabPay
      - `pay_co`
        Payments made via PayCo
      - `after_pay`
        Payments made via Afterpay
      - `swish`
        Payments made via Swish
      - `payme`
        Payments made via PayMe
      - `pix`
        Pix
      - `klarna`
        Payments made via Klarna.
      - `alipay_hk`
        Payments made via Alipay HK.
      - `paypay`
        PayPay
      - `gcash`
        Payments made via GCash.
      - `south_korean_cards`
        Payments made via South Korean Cards
      - `paynow`
      - `bizum`
      - `promptpay`
      - `dana`
        Payments made via Dana.
      - `touch_n_go`
        Payments made via Touch 'n Go.
      - `tamara`
        Payments made via Tamara.
      - `qpay`
        Payments made via Qpay.
      - `ovo`
      - `momo`
      - `mercado_pago`
      - `nequi`
      - `nupay`
      - `picpay`
      - `thai_qr`
      - `blik`
      - `fpx`
      - `wero`
      - `p24`
      - `affirm_pay`
      - `rakuten_pay`
  - `reference_id` (optional, string, max chars=65k)
    Identifier for Braintree permanent token. Applicable when you are using Braintree APIs for completing the 3DS flow.
  - `additional_information` (optional, jsonobject)
    -   `checkout_com`: While adding a new payment method using [permanent token](/docs/api/payment_sources/create-using-permanent-token) or passing raw card details to Checkout.com, `document` ID and `country_of_residence` are required to support payments through [dLocal](https://www.checkout.com/docs/previous/payments/payment-methods/cards/dlocal).
        
        -   `payer`: User related information.
            -   `country_of_residence`: This is required since the billing country associated with the user's payment method may not be the same as their country of residence. Hence the user's country of residence needs to be specified. The country code should be a [two-character ISO code](https://docs.checkout.com/resources/codes/country-codes).
            -   `document`: Document ID is the user's [identification number](https://docs.dlocal.com/api-documentation/payins-api-reference/country-reference#documents) based on their country.
    -   `bluesnap`: While passing raw card details to BlueSnap, if `fraud_session_id` is added, [additional validation](https://developers.bluesnap.com/docs/fraud-prevention) is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your [BlueSnap fraud session ID](https://developers.bluesnap.com/docs/fraud-prevention#section-implementing-device-data-collector) required to perform anti-fraud validation.
    -   `braintree`: While passing raw card details to Braintree, your `fraud_merchant_id` and the user's `device_session_id` can be added to perform [additional validation](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
            -   `fraud_merchant_id`: Your [merchant ID](https://developers.braintreepayments.com/guides/premium-fraud-management-tools/device-data-collection/javascript/v3#collecting-device-data) for fraud detection.
    -   `chargebee_payments`: While passing raw card details to Chargebee Payments, if `fraud_session_id` is added, additional validation is performed to avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `fraud_session_id`: Your Chargebee Payments fraud session ID required to perform anti-fraud validation.
    -   `bank_of_america`: While passing raw card details to Bank of America, your user's `device_session_id` can be added to perform additional validation and avoid fraudulent transactions.
        
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device.
    -   `ecentric`: This parameter is used to verify and process payment method details in Ecentric. If the `merchant_id` parameter is included, Chargebee will vault it / perform a lookup and verification against this `merchant_id`, overriding the one configured in Chargebee. If tokens and processing occur in the same Merchant GUID, you can just skip this part.
        
        -   `merchant_id`: Merchant GUID where the card is vaulted or need to be vaulted.
    -   `ebanx`: While passing raw card details to EBANX, the user's `document` is required for some countries and `device_session_id` can be added to perform [additional validation](https://developer.ebanx.com/docs/payments/guides/features/device-fingerprint#device-fingerprint) and avoid fraudulent transactions.
        
        -   `payer`: User related information.
            -   `document`: Document is the user's identification number based on their country.
        -   `fraud`: Fraud identification related information.
            -   `device_session_id`: Session ID associated with the user's device

- `item_prices` (optional, array)
  Parameters for item\_prices
  - `item_price_id` (optional, string, max chars=100)
    A unique ID for your system to identify the item price.
  - `quantity` (optional, integer)
    Item price quantity
  - `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 or per-unit-price of the item price. By default, it is the [value set](/docs/api/item_prices/item_price-object#price) for the `item_price`. This is only applicable when the `pricing_model` of the `item_price` is `flat_fee` or `per_unit`. The value depends on the [type of currency](/docs/api/getting-started) .
  - `unit_price_in_decimal` (optional, string, max chars=39)
    The decimal representation of the price or per-unit price of the plan. The value is in major units of the currency. Always returned when [multi-decimal pricing](/docs/api/getting-started) is enabled.
  - `date_from` (optional, timestamp(UTC) in seconds)
    The time when the service period for the item starts.
  - `date_to` (optional, timestamp(UTC) in seconds)
    The time when the service period for the item ends.
  - `description` (optional, string, max chars=250)
    The line item name to display on the invoice for this charge item.
    
    **Default value**
    
    -   The invoice name defined for the item in the product catalog.
  - `entity_description` (optional, string, max chars=500)
    Descriptive text displayed below the line item name on the invoice for this charge item.
    
    **Default value**
    
    -   The [item price description](/docs/api/item_prices/item_price-object#description) from the product catalog.

- `item_tiers` (optional, array)
  Parameters for item\_tiers
  - `item_price_id` (optional, string, max chars=100)
    The id of the item price to which this tier belongs.
  - `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 per-unit price for the tier when the `pricing_model` is `tiered` or `volume`. The total cost for the item price when the `pricing_model` is `stairstep`. The value is in the minor unit of the currency.
  - `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.

- `charges` (optional, array)
  Parameters for charges
  - `entity_description` (optional, string, max chars=500)
    Descriptive text for this one-time charge displayed on the invoice, shown below the line item name.
  - `amount` (optional, in cents)
    The amount to be charged. The unit depends on the [type of currency](/docs/api/getting-started) .
  - `amount_in_decimal` (optional, string, max chars=39)
    The decimal representation of the amount for the [one-time charge](https://www.chargebee.com/docs/charges.html#one-time-charges ). Provide the value in major units of the currency. Can be provided only when [multi-decimal pricing](/docs/api/currencies) is enabled.
  - `description` (optional, string, max chars=250)
    The name of this one-time charge as displayed on the invoice line item.
  - `taxable` (optional, boolean)
    The amount to be charged is taxable or not.
  - `tax_profile_id` (optional, string, max chars=50)
    Tax profile of the charge.
  - `avalara_tax_code` (optional, string, max chars=50)
    The Avalara tax codes to which items are mapped to should be provided here. Applicable only if you use Chargebee's [AvaTax for Sales integration](https://www.chargebee.com/docs/avalara.html) .
  - `hsn_code` (optional, string, max chars=50)
    The [HSN code](https://cbic-gst.gov.in/gst-goods-services-rates.html) to which the item is mapped for calculating the customer's tax in India. Applicable only when both of the following conditions are true:
    
    -   [**India**](https://www.chargebee.com/docs/indian-gst.html#configuring-indian-gst) has been enabled as a **Tax Region**. (An error is returned when this condition is not true.)
    -   The [**AvaTax for Sales** integration](https://www.chargebee.com/docs/avalara.html) has been enabled in Chargebee.
  - `taxjar_product_code` (optional, string, max chars=50)
    The TaxJar product codes to which items are mapped to should be provided here. Applicable only if you use Chargebee's [TaxJar integration](https://www.chargebee.com/docs/taxjar.html) .
  - `avalara_sale_type` (optional, enumerated string)
    Indicates the type of sale carried out. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
    Possible enum values:
      - `wholesale`
        Transaction is a sale to another company that will resell your product or service to another consumer
      - `retail`
        Transaction is a sale to an end user
      - `consumed`
        Transaction is for an item that is consumed directly
      - `vendor_use`
        Transaction is for an item that is subject to vendor use tax
  - `avalara_transaction_type` (optional, integer)
    Indicates the type of product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
  - `avalara_service_type` (optional, integer)
    Indicates the type of service for the product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
  - `date_from` (optional, timestamp(UTC) in seconds)
    The time when the service period for the charge starts.
  - `date_to` (optional, timestamp(UTC) in seconds)
    The time when the service period for the charge ends.

- `notes_to_remove` (optional, array)
  Parameters for notes\_to\_remove
  - `entity_type` (optional, enumerated string)
    Type of entity to which the [note](/docs/api/invoices/invoice-object#notes) belongs. To remove the general note, use the `remove_general_note` parameter.
    Possible enum values:
      - `customer`
        Entity that represents a customer.
      - `subscription`
        Entity that represents a subscription of customer.
      - `coupon`
        Entity that represents a coupon.
      - `plan_item_price`
        Indicates that this line item is based on plan Item Price
      - `addon_item_price`
        Indicates that this line item is based on addon Item Price
      - `charge_item_price`
        Indicates that this line item is based on charge Item Price
  - `entity_id` (optional, string, max chars=100)
    Unique identifier of the [note](/docs/api/invoices/invoice-object#notes) .

- `tax_providers_fields` (optional, array)
  Parameters for tax\_providers\_fields
  - `provider_name` (optional, string, max chars=50)
    Name of the tax provider currently supported.
  - `field_id` (optional, string, max chars=50)
    Field id of the attribute which tax vendor has provided while getting onboarded with us.
  - `field_value` (optional, string, max chars=50)
    The value of the corresponding tax field.

- `discounts` (optional, array)
  Parameters for discounts
  - `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.
  - `quantity` (optional, integer)
    Specifies the number of free units provided for the item, without affecting the total quantity sold
  - `apply_on` (required, 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` .
  - `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`.

## Returns

- `invoice` (Invoice object)
  Resource object representing invoice
