# List payments for an invoice

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


[Eventually Consistent](/docs/api/read-consistency)

Retrieves the payments for an invoice with the recent ones on top. This returns all the payment attempts(manual & automatic) made for this invoice.

## Sample Request

#### cURL

```bash
curl  https://{site}.chargebee.com/api/v2/invoices/__demo_inv__4/payments \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=1
```

#### .NET

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

ApiConfig.Configure("{site}","{site_api_key}");
ListResult result = Transaction.PaymentsForInvoice("__demo_inv__4")
		.Limit(1)
		.Request();

foreach (var listItem in result.List){
  Transaction transaction = listItem.Transaction;
}
```

#### Go

```go
package main
import (
    "fmt"
    "github.com/chargebee/chargebee-go/v3"
    transactionAction "github.com/chargebee/chargebee-go/v3/actions/transaction"
    "github.com/chargebee/chargebee-go/v3/models/transaction"
)
func main() {
    chargebee.Configure("{site_api_key}","{site}");
    res,err := transactionAction.PaymentsForInvoice("__demo_inv__4", &transaction.PaymentsForInvoiceRequestParams{
        Limit : chargebee.Int32(1),
    }).ListRequest()
    if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Transaction := res.List[idx].Transaction
        }
    }
}
```

#### 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.TransactionPaymentsForInvoiceRequest{
    Limit : chargebee.Int32(1),
}
  res, err := client.Transaction.PaymentsForInvoice("__demo_inv__4", req)
      if err != nil {
        fmt.Println(err)
    } else {
        for idx := 0; idx < len(res.List); idx++ {
            Transaction := res.List[idx].Transaction
        }
    }
}
```

#### Java

```java
import com.chargebee.*;
import com.chargebee.ListResult;
import com.chargebee.models.*;
import com.chargebee.models.enums.*;
import java.io.IOException;
import java.util.List;

public class Sample {

    public static void main(String args[]) throws IOException, Exception {
        Environment.configure("{site}", "{site_api_key}");
        ListResult result = Transaction.paymentsForInvoice("__demo_inv__4")
            .limit(1)
            .request();

        for (ListResult.Entry entry : result) {
            Transaction transaction = entry.transaction();
        }
    }
}
```

#### Java

```java
import com.chargebee.v4.client.ChargebeeClient;
import com.chargebee.v4.models.transaction.Transaction;
import com.chargebee.v4.models.transaction.params.TransactionPaymentsForInvoiceParams;
import com.chargebee.v4.models.transaction.responses.TransactionPaymentsForInvoiceResponse;
import java.util.List;

public class TransactionPaymentsForInvoice {

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

        TransactionPaymentsForInvoiceParams params = TransactionPaymentsForInvoiceParams.builder()
            .limit(1)
            .build();

        TransactionPaymentsForInvoiceResponse response = client
            .transactions()
            .paymentsForInvoice("__demo_inv__4", params);
    }
}
```

#### Node.js

```node
import Chargebee from "chargebee";

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

try {
    const result = await chargebee.transaction.paymentsForInvoice("__demo_inv__4", {
        limit: 1
    });
    result.list.forEach((entry) => {
        console.log(entry);
        const transaction = entry.transaction;
    });
} 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->transaction()->paymentsForInvoice("__demo_inv__4", [
    "limit" => 1
]);
foreach($result->list as $entry) {
    $transaction = $entry->transaction;
}
```

#### Python

```python
from chargebee import Chargebee, Filters

cb_client = Chargebee(api_key="{site_api_key}", site="{site}")
entries = cb_client.Transaction.payments_for_invoice("__demo_inv__4",
    cb_client.Transaction.PaymentsForInvoiceParams(
        limit=1
    )
)
for entry in entries.list:
    transaction = entry.transaction
```

#### Ruby

```ruby
require 'chargebee'

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

list = ChargeBee::Transaction.payments_for_invoice("__demo_inv__4",{
  :limit => 1
})

list.each do |entry|
  transaction = entry.transaction
end
```

## Sample Response

```json
{
  "list": [
    {
      "transaction": {
        "amount": 100,
        "amount_unused": 0,
        "currency_code": "USD",
        "customer_id": "__test__KyVnHhSBWlvSM2pk",
        "date": 1600968323,
        "deleted": false,
        "exchange_rate": 1,
        "fraud_reason": "Payment complete.",
        "gateway": "stripe",
        "gateway_account_id": "gw___test__KyVnGlSBWltbL2AB",
        "id": "txn___test__KyVnHhSBWlvlh2pw",
        "id_at_gateway": "ch_1HUyC7Jv9j0DyntJJ6FrzqKp",
        "linked_invoices": [
          {
            "applied_amount": 100,
            "applied_at": 1517505924,
            "invoice_date": 1517505923,
            "invoice_id": "__demo_inv__4",
            "invoice_status": "payment_due",
            "invoice_total": 1095
          },
          {..}
        ],
        "linked_refunds": {},
        "masked_card_number": "************1111",
        "object": "transaction",
        "payment_method": "card",
        "payment_source_id": "pm___test__KyVnHhSBWlvgw2pl",
        "resource_version": 1517505924000,
        "status": "success",
        "subscription_id": "__test__KyVnHhSBWlvi12pp",
        "type": "payment",
        "updated_at": 1517505924
      }
    },
    {..}
  ]
}
```

## URL Format

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

## Input Parameters

- `limit` (optional, integer, default=10, min=1, max=100)
  The number of resources to be returned.

- `offset` (optional, string, max chars=1000)
  Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set `offset` to the value of `next_offset` obtained in the previous iteration of the API call.

## Returns

- `next_offset` (optional, string, max chars=1000)
  This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter `offset`.

- `transaction` (Transaction object)
  Resource object representing transaction
