# Pause dunning for invoice

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


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

Pause [dunning](https://www.chargebee.com/docs/payments/2.0/dunning-v2.html) for the specified invoice until `expected_payment_date`. Chargebee cancels all configured payment collection [retry attempts](https://www.chargebee.com/docs/payments/2.0/dunning-v2.html) and dunning [email notifications](https://www.chargebee.com/docs/payments/2.0/dunning-v2.html#dunning-email-notifications) for the invoice until `expected_payment_date`.

#### Prerequisites[](#prerequisites)

This operation is only permitted for an invoice that meets _all_ the following conditions:

-   The [status](/docs/api/invoices/invoice-object#status) of the invoice is `payment_due`.
-   The invoice belongs to a [subscription](/docs/api/subscriptions) or [customer](/docs/api/customers) with [`auto_collection`](/docs/api/v2/pcv-1/subscriptions/subscription-object#auto_collection) set to `on`.
-   The invoice does not have dunning paused currently.

#### Automatic dunning resumption[](#automatic-dunning-resumption)

Unless you [resume dunning](/docs/api/invoices/resume-dunning-for-invoice) for the invoice, Chargebee attempts to collect payment on the `expected_payment_date`. If payment collection fails, the next action is taken as follows:

-   If the `expected_payment_date` is within the dunning period for the invoice, Chargebee resumes any dunning retries and email notifications that remain after the pause period, and not attempt the retries or notifications that were canceled during the pause period.
-   If the `expected_payment_date` is after the dunning period for the invoice, the [final action](https://www.chargebee.com/docs/payments/2.0/dunning-v2.html) configured in Billing is initiated for the invoice and, if applicable, for the subscription.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices/__demo_inv__4/pause_dunning \
     -u {site_api_key}:\
     -d expected_payment_date=1747548502
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Invoice.PauseDunning("__demo_inv__4")
		.ExpectedPaymentDate(1747548502)
		.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.PauseDunning("__demo_inv__4", &invoice.PauseDunningRequestParams{
        ExpectedPaymentDate : chargebee.Int64(1747548502),
    }).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.InvoicePauseDunningRequest{
    ExpectedPaymentDate : chargebee.Int64(1747548502),
}
  res, err := client.Invoice.PauseDunning("__demo_inv__4", 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;
import java.sql.Timestamp;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        Result result = Invoice.pauseDunning("__demo_inv__4")
            .expectedPaymentDate(new Timestamp(1747548502L * 1000))
            .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.InvoicePauseDunningParams;
import com.chargebee.v4.models.invoice.responses.InvoicePauseDunningResponse;
import java.sql.Timestamp;

public class InvoicePauseDunning {

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

        InvoicePauseDunningParams params = InvoicePauseDunningParams.builder()
            .expectedPaymentDate(new Timestamp(1747548502L * 1000))
            .build();

        InvoicePauseDunningResponse response = client
            .invoices()
            .pauseDunning("__demo_inv__4", 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.pauseDunning("__demo_inv__4", {
        expected_payment_date: 1747548502
    });

    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()->pauseDunning("__demo_inv__4", [
    "expected_payment_date" => 1747548502
]);
$invoice = $result->invoice;
```

#### Python

```python
from chargebee import Chargebee

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
response = cb_client.Invoice.pause_dunning("__demo_inv__4",
    cb_client.Invoice.PauseDunningParams(
        expected_payment_date=1747548502
    )
)
invoice = response.invoice
```

#### Ruby

```ruby
require 'chargebee'

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

result = ChargeBee::Invoice.pause_dunning("__demo_inv__4",{
  :expected_payment_date => 1747548502
})

invoice = result.invoice
```

## Sample Response

```json
{
  "invoice": {
    "adjustment_credit_notes": {},
    "amount_adjusted": 0,
    "amount_due": 1000,
    "amount_paid": 0,
    "amount_to_collect": 1000,
    "applied_credits": {},
    "base_currency_code": "USD",
    "billing_address": {
      "first_name": "Rachel",
      "last_name": "Green",
      "object": "billing_address",
      "validation_status": "not_validated"
    },
    "credits_applied": 0,
    "currency_code": "USD",
    "customer_id": "__test__8aspTSOcUcz72s",
    "date": 1612796988,
    "deleted": false,
    "due_date": 1612796988,
    "dunning_attempts": [
      {
        "attempt": 0,
        "created_at": 1612796989,
        "dunning_type": "auto_collect",
        "retry_engine": "chargebee",
        "transaction_id": "txn___test__8aspTSOcUezv3v",
        "txn_amount": 1000,
        "txn_status": "failure"
      },
      {..}
    ],
    "dunning_status": "stopped",
    "exchange_rate": 1,
    "first_invoice": false,
    "has_advance_charges": false,
    "id": "__demo_inv__4",
    "is_gifted": false,
    "issued_credit_notes": {},
    "line_items": [
      {
        "amount": 1000,
        "customer_id": "__test__8aspTSOcUcz72s",
        "date_from": 1612796988,
        "date_to": 1612883388,
        "description": "Basic USD 2",
        "discount_amount": 0,
        "entity_id": "basic-USD2",
        "entity_type": "plan_item_price",
        "id": "li___test__8aspTSOcUex03u",
        "is_taxed": false,
        "item_level_discount_amount": 0,
        "object": "line_item",
        "pricing_model": "per_unit",
        "quantity": 1,
        "subscription_id": "__test__8aspTSOcUcz72s",
        "tax_amount": 0,
        "tax_exempt_reason": "tax_not_configured",
        "unit_amount": 1000
      },
      {..}
    ],
    "linked_orders": {},
    "linked_payments": [
      {
        "applied_amount": 1000,
        "applied_at": 1612796989,
        "txn_amount": 1000,
        "txn_date": 1612796989,
        "txn_id": "txn___test__8aspTSOcUezv3v",
        "txn_status": "failure"
      },
      {..}
    ],
    "net_term_days": 0,
    "object": "invoice",
    "price_type": "tax_exclusive",
    "recurring": true,
    "resource_version": 1517490593188,
    "round_off_amount": 0,
    "status": "not_paid",
    "sub_total": 1000,
    "subscription_id": "__test__8aspTSOcUcz72s",
    "tax": 0,
    "term_finalized": true,
    "total": 1000,
    "updated_at": 1517490593,
    "write_off_amount": 0
  }
}
```

## URL Format

**POST** https://[site].chargebee.com/api/v2/invoices/{invoice-id}/pause_dunning

## Input Parameters

- `expected_payment_date` (required, timestamp(UTC) in seconds)
  The date and time at which dunning should resume. **See also**: [Dunning resumption process](/docs/api/invoices/resume-dunning-for-invoice).

- `comment` (optional, string, max chars=300)
  An internal [comment](/docs/api/comments) to add to the invoice for this operation. This comment is displayed on the Chargebee Billing UI. **Note**: This comment does not appear on any customer-facing [hosted pages](/docs/api/hosted_pages) or documents, such as the [invoice PDF](/docs/api/invoices/retrieve-invoice-as-pdf).

## Returns

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