# Cancel a collections payment promise

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


Cancels an active collections payment promise that is no longer expected to be fulfilled.

## Sample Request

#### Chargebee CLI

```bash
chargebee collections-payment-promise cancel pp_8aspTSOcUcz72s
```

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/collections_payment_promises/pp_8aspTSOcUcz72s/cancel \
     -X POST  \
     -u {site_api_key}:
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = CollectionsPaymentPromise.Cancel("pp_8aspTSOcUcz72s").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"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := collectionspaymentpromiseAction.Cancel("pp_8aspTSOcUcz72s").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.CollectionsPaymentPromiseCancelRequest{
    Id : "pp_8aspTSOcUcz72s",
}
  res, err := client.CollectionsPaymentPromise.Cancel(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;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = CollectionsPaymentPromise.cancel("pp_8aspTSOcUcz72s").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.CollectionsPaymentPromiseCancelParams;
import com.chargebee.v4.models.collectionsPaymentPromise.responses.CollectionsPaymentPromiseCancelResponse;

public class CollectionsPaymentPromiseCancel {

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

        CollectionsPaymentPromiseCancelResponse response = client.collectionsPaymentPromises().cancel("pp_8aspTSOcUcz72s");

        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.cancel("pp_8aspTSOcUcz72s");

    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()->cancel("pp_8aspTSOcUcz72s");
$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.cancel("pp_8aspTSOcUcz72s")
collections_payment_promise = response.collections_payment_promise
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::CollectionsPaymentPromise.cancel("pp_8aspTSOcUcz72s")

collections_payment_promise = result.collections_payment_promise
```

## Sample Response

```json
{
  "collections_payment_promise": {
    "id": "pp_8aspTSOcUcz72s",
    "status": "cancelled",
    "object": "collections_payment_promise"
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/collections_payment_promises/{collections-payment-promise-id}/cancel

## Returns

- `collections_payment_promise` (Collections payment promise object)
  The updated `collections_payment_promise` resource after cancellation.
