# Payment schedules

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


Payment schedules for an invoice refer to a payment structure where the `amount_due` on an invoice is divided into smaller, more manageable parts, each of which is paid over a specified period.

`reference_transactions[]` lists the payment attempts referenced against those installments.

## Sample Payment schedule

```json
{
  "payment_schedule": {
    "id": "16BdWdUNYtQf97w",
    "scheme_id": "16Bk0DUNYt3kk3n",
    "entity_type": "invoice",
    "entity_id": "a0920247004",
    "amount": 40000,
    "currency_code": "USD",
    "created_at": 1725593728,
    "updated_at": 1725593800,
    "resource_version": 1725593800000,
    "object": "payment_schedule",
    "schedule_entries": [
      {
        "id": "16BdWdUNYtQfC7x",
        "date": 1725593728,
        "amount": 0,
        "scheduled_amount": 13333,
        "status": "paid",
        "object": "schedule_entry"
      },
      {..}
    ],
    "reference_transactions": [
      {
        "schedule_entry_id": "16BdWdUNYtQfC7x",
        "applied_amount": 13333,
        "txn_id": "txn_16BdWdUNYtQgPay",
        "txn_status": "success",
        "txn_date": 1725593800,
        "txn_amount": 13333
      },
      {..}
    ]
  }
}
```

## Payment schedules attributes

## Input Parameters

- `id` (required, string, max chars=40)
  An auto-generated unique identifier for the payment schedule.

- `scheme_id` (required, string, max chars=40)
  The identifier of the `payment_schedule_scheme` , used to create the payment schedules.

- `entity_type` (required, enumerated string)
  Specifies the types of entity this payment schedule is based on.
  Possible enum values:
    - `invoice`
      Indicates the invoice entity type

- `entity_id` (required, string, max chars=50)
  The identifier of the entity this payment schedule is based on.

- `amount` (optional, in cents, min=0)
  The part of the `invoice.amount_due` to be distributed across the payment schedules. If not specified, the entire `invoice.amount_due` is considered by default.

- `created_at` (required, timestamp(UTC) in seconds)
  The timestamp at which the `payment_schedule` was created.

- `resource_version` (optional, long)
  Version number of this resource. The `resource_version` is updated with a new timestamp in milliseconds for every change made to the resource. This attribute will be present only if the resource has been updated after 2016-09-28.

- `updated_at` (optional, timestamp(UTC) in seconds)
  Specifies when these payment schedules are updated recently.

- `currency_code` (optional, string, max chars=3)
  The currency code (ISO 4217 format) of the transaction amount.

- `schedule_entries` (optional, list of schedule_entry)
  List of schedule entries
  - `id` (required, string, max chars=40)
    An auto-generated unique identifier for the payment schedules.
  - `date` (required, timestamp(UTC) in seconds)
    Date at which this payment schedule is scheduled.
  - `amount` (required, in cents, min=0)
    The remaining amount due on this schedule entry. Decreases as payments are applied. When this value reaches `0`, `status` is `paid`.
  - `scheduled_amount` (required, in cents, min=0)
    The original installment amount for this schedule entry. This value does not change when payments are applied.
  - `status` (required, enumerated string)
    Defines the status for each payment schedule.
    Possible enum values:
      - `posted`
        The installment is unpaid or partially paid and the due date (`date`) has not passed.
      - `payment_due`
        The installment is unpaid or partially paid and the due date (`date`) has passed.
      - `paid`
        The installment has been paid.

- `reference_transactions` (optional, list of schedule_entry_transaction)
  The list of transactions referenced against the schedule entries of this payment schedule, most recent first. A transaction referenced against more than one schedule entry appears once per entry.
  - `schedule_entry_id` (required, string, max chars=40)
    The identifier of the [`schedule_entries[]`](/docs/api/payment_schedules/payment_schedule-object#schedule_entries) item this transaction is linked to.
  - `applied_amount` (optional, in cents, min=0)
    The amount of this transaction applied to this schedule entry. `0` for failed and in-progress transactions until the payment settles.
  - `txn_id` (required, string, max chars=40)
    Uniquely identifies the transaction.
  - `txn_status` (optional, enumerated string)
    The status of this transaction.
    Possible enum values:
      - `in_progress`
        Transaction is being processed by the gateway. This typically happens for [direct debit transactions](https://www.chargebee.com/docs/direct-debit-payments.html) or, in case of cards, refund transactions. Such transactions can take 2-7 days to complete, depending on the gateway and payment method.
      - `success`
        The transaction is successful.
      - `voided`
        The transaction got voided or authorization expired at gateway.
      - `failure`
        Transaction failed. Refer the 'error\_code' and 'error\_text' fields to know the reason for failure
      - `timeout`
        Transaction failed because of Gateway not accepting the connection.
      - `needs_attention`
        When connection with the Gateway gets terminated abruptly. For `needs_attention` status Chargebee automatically reconcile the transaction for few gateways, for rest of the gateways you have to use the [Reconcile transaction API](/docs/api/transactions/reconcile-transaction). You can use this API to update the `id_at_gateway` (Gateway Transaction ID) and `status` for a [`needs_attention`](/docs/api/transactions/transaction-object#status) transaction to be reconciled at par with the gateway.
        
        [Learn more](https://www.chargebee.com/docs/payments/2.0/needs-attention-transactions.html) about `needs_attention` transaction status
      - `late_failure`
        Indicates that a successful payment transaction has failed now due to a late failure notification from the payment gateway, typically caused by issues like insufficient funds or a closed bank account.
  - `txn_date` (optional, timestamp(UTC) in seconds)
    Indicates when this transaction occurred.
  - `txn_amount` (optional, in cents, min=0)
    Total amount of the transaction.

