# Create a collections payment promise

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


Creates a collections payment promise for a customer, with the promised amount and the date payment was promised. Include `invoice_id` when the promise applies to a specific invoice.

## Sample Request

#### Chargebee CLI

```bash
chargebee collections-payment-promise create-collections-payment-promise \
    -d customer_id=__test__8aspTSOcUcz72s \
    -d invoice_id=__demo_inv__4 \
    -d amount=1000 \
    -d promised_on=1738512000
```

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/collections_payment_promises \
     -u {site_api_key}:\
     -d customer_id="__test__8aspTSOcUcz72s" \
     -d invoice_id="__demo_inv__4" \
     -d amount=1000 \
     -d promised_on=1738512000
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = CollectionsPaymentPromise.CreateCollectionsPaymentPromise()
		.CustomerId("__test__8aspTSOcUcz72s")
		.InvoiceId("__demo_inv__4")
		.Amount(1000)
		.PromisedOn(1738512000)
		.Request();

CollectionsPaymentPromise collectionsPaymentPromise = result.CollectionsPaymentPromise;
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    collectionspaymentpromiseAction "github.com/chargebee/chargebee-go/v3/actions/collectionspaymentpromise"
    "github.com/chargebee/chargebee-go/v3/models/collectionspaymentpromise"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := collectionspaymentpromiseAction.CreateCollectionsPaymentPromise(&collectionspaymentpromise.CreateCollectionsPaymentPromiseRequestParams{
        CustomerId : "__test__8aspTSOcUcz72s",
        InvoiceId : "__demo_inv__4",
        Amount : chargebee.Int64(1000),
        PromisedOn : chargebee.Int64(1738512000),
    }).Request()
    if err != nil {
        fmt.Println(err)
    } else {
        CollectionsPaymentPromise := res.CollectionsPaymentPromise
    }
}
```

#### 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.CollectionsPaymentPromiseCreateCollectionsPaymentPromiseRequest{
    CustomerId : "__test__8aspTSOcUcz72s",
    InvoiceId : "__demo_inv__4",
    Amount : chargebee.Int64(1000),
    PromisedOn : chargebee.Int64(1738512000),
}
  res, err := client.CollectionsPaymentPromise.CreateCollectionsPaymentPromise(req)
      if err != nil {
        fmt.Println(err)
    } else {
        CollectionsPaymentPromise := res.CollectionsPaymentPromise
    }
}
```

#### Java

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

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = CollectionsPaymentPromise.createCollectionsPaymentPromise()
            .customerId("__test__8aspTSOcUcz72s")
            .invoiceId("__demo_inv__4")
            .amount(1000L)
            .promisedOn(new Timestamp(1738512000L * 1000))
            .request();

        CollectionsPaymentPromise collectionsPaymentPromise = result.collectionsPaymentPromise();
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.collectionsPaymentPromise.CollectionsPaymentPromise;
import com.chargebee.v4.models.collectionsPaymentPromise.params.CreateCollectionsPaymentPromiseParams;
import com.chargebee.v4.models.collectionsPaymentPromise.responses.CreateCollectionsPaymentPromiseResponse;
import java.sql.Timestamp;

public class CreateCollectionsPaymentPromise {

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

        CreateCollectionsPaymentPromiseParams params = CreateCollectionsPaymentPromiseParams.builder()
            .customerId("__test__8aspTSOcUcz72s")
            .invoiceId("__demo_inv__4")
            .amount(1000L)
            .promisedOn(new Timestamp(1738512000L * 1000))
            .build();

        CreateCollectionsPaymentPromiseResponse response = client.collectionsPaymentPromises().createCollectionsPaymentPromise(params);

        CollectionsPaymentPromise collectionsPaymentPromise = response.getCollectionsPaymentPromise();
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.collectionsPaymentPromise.createCollectionsPaymentPromise({
        customer_id: "__test__8aspTSOcUcz72s",
        invoice_id: "__demo_inv__4",
        amount: 1000,
        promised_on: 1738512000
    });

    console.log(result);
    const collectionsPaymentPromise = result.collections_payment_promise;
} 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->collectionsPaymentPromise()->createCollectionsPaymentPromise([
    "customer_id" => "__test__8aspTSOcUcz72s",
    "invoice_id" => "__demo_inv__4",
    "amount" => 1000,
    "promised_on" => 1738512000
]);
$collectionsPaymentPromise = $result->collections_payment_promise;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.CollectionsPaymentPromise.create_collections_payment_promise(
    cb_client.CollectionsPaymentPromise.CreateCollectionsPaymentPromiseParams(
        customer_id="__test__8aspTSOcUcz72s",
        invoice_id="__demo_inv__4",
        amount=1000,
        promised_on=1738512000
    )
)
collections_payment_promise = response.collections_payment_promise
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::CollectionsPaymentPromise.create_collections_payment_promise({
  :customer_id => "__test__8aspTSOcUcz72s",
  :invoice_id => "__demo_inv__4",
  :amount => 1000,
  :promised_on => 1738512000
})

collections_payment_promise = result.collections_payment_promise
```

## Sample Response

```json
{
  "collections_payment_promise": {
    "id": "pp_8aspTSOcUcz72s",
    "customer_id": "__test__8aspTSOcUcz72s",
    "invoice_id": "__demo_inv__4",
    "currency_code": "USD",
    "amount": 1000,
    "promised_by": "ops.user@chargebee.com",
    "promised_on": 1738512000,
    "status": "active",
    "created_at": 1738508400,
    "updated_at": 1738512100,
    "resource_version": 1738512100000,
    "object": "collections_payment_promise"
  }
}
```

## URL Format

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

## Input Parameters

- `customer_id` (required, string, max chars=100)
  Identifier of the customer for whom the payment promise is being created. This field is required.

- `invoice_id` (optional, string, max chars=100)
  Identifier of the invoice associated with this promise. This field is optional.

- `amount` (required, long)
  Amount promised by the customer, in the smallest currency unit (for example, cents for USD). This field is required.

- `currency_code` (optional, string, max chars=3)
  Currency code for `amount` in ISO 4217 format. If omitted, the site's base currency is used.

- `promised_on` (required, timestamp(UTC) in seconds)
  Timestamp in UTC seconds for the date on which the customer promised payment. This field is required.

- `reason` (optional, string, max chars=500)
  Optional context about why or how this promise was recorded.

- `promised_by` (optional, string, max chars=254)
  Name or identifier of the person who captured this promise.

## Returns

- `collections_payment_promise` (Collections payment promise object)
  The newly created `collections_payment_promise` resource.
