# Transactions

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


This resource represents the [transaction](https://www.chargebee.com/docs/transactions.html) event that has happened in your account.

## Sample Transaction

```json
{
  "transaction": {
    "amount": 1395,
    "amount_unused": 0,
    "currency_code": "USD",
    "customer_id": "__test__5SK0bLNFRFuCEDDLg",
    "date": 1517506742,
    "gateway": "chargebee",
    "id": "txn___test__5SK0bLNFRFuCEEELm",
    "id_at_gateway": "cb___test__5SK0bLNFRFuCEEJLn",
    "linked_invoices": [
      {
        "applied_amount": 1395,
        "applied_at": 1517506742,
        "invoice_amount": 1395,
        "invoice_date": 1517506742,
        "invoice_id": "__demo_inv__1"
      },
      {..}
    ],
    "linked_refunds": {},
    "masked_card_number": "************1111",
    "object": "transaction",
    "payment_method": "card",
    "status": "success",
    "subscription_id": "__test__5SK0bLNFRFuCEDDLg",
    "type": "payment"
  }
}
```

## Transactions attributes

## Input Parameters

- `id` (required, string, max chars=40)
  Uniquely identifies the transaction.

- `customer_id` (optional, string, max chars=50)
  Identifier of the customer for which this transaction is made

- `subscription_id` (optional, string, max chars=50)
  Identifier of the subscription for which this transaction is made.

- `payment_method` (required, enumerated string, default=card)
  The payment method of this transaction
  Possible enum values:
    - `card`
      Card
    - `cash`
      Cash
    - `check`
      Check
    - `chargeback`
      Only applicable for a transaction of `[type](/docs/api/transactions/transaction-object#type)` = `refund`. This value is set by Chargebee when an automated [chargeback](https://www.chargebee.com/docs/chargeback.html#chargeback-process) occurs. You can also set this explicitly when [recording a refund](/docs/api/transactions/record-an-offline-refund) .
    - `bank_transfer`
      Bank Transfer
    - `amazon_payments`
      Amazon Payments
    - `paypal_express_checkout`
      Paypal Express Checkout
    - `direct_debit`
      Direct Debit
    - `other`
      Payment Methods other than the above types

- `reference_number` (optional, string, max chars=100)
  The reference number for this transaction. For example, the check number when `[payment_method](/docs/api/transactions/transaction-object#payment_method)` = `check` .

- `gateway` (required, enumerated string)
  Gateway through which this transaction was done. Applicable only for 'Card' Payment Method
  Possible enum values:
    - `chargebee`
      Chargebee test gateway.
    - `stripe`
      Stripe is a payment gateway.
    - `braintree`
      Braintree is a payment gateway.
    - `authorize_net`
      Authorize.net is a payment gateway
    - `paypal_pro`
      PayPal Pro Account is a payment gateway.
    - `pin`
      Pin is a payment gateway
    - `eway`
      eWAY Account is a payment gateway.
    - `eway_rapid`
      eWAY Rapid is a payment gateway.
    - `worldpay`
      WorldPay is a payment gateway
    - `balanced_payments`
      Balanced is a payment gateway
    - `beanstream`
      Bambora(formerly known as Beanstream) is a payment gateway.
    - `bluepay`
      BluePay is a payment gateway.
    - `elavon`
      Elavon Virtual Merchant is a payment solution.
    - `first_data_global`
      First Data Global Gateway Virtual Terminal Account
    - `hdfc`
      HDFC Account is a payment gateway.
    - `migs`
      MasterCard Internet Gateway Service payment gateway.
    - `nmi`
      NMI is a payment gateway.
    - `ogone`
      Ingenico ePayments (formerly known as Ogone) is a payment gateway.
    - `paymill`
      PAYMILL is a payment gateway.
    - `paypal_payflow_pro`
      PayPal Payflow Pro is a payment gateway.
    - `sage_pay`
      Sage Pay is a payment gateway.
    - `tco`
      2Checkout is a payment gateway.
    - `wirecard`
      WireCard Account is a payment service provider.
    - `not_applicable`
      Indicates that payment gateway is not applicable for this resource.

- `type` (required, enumerated string)
  Type of the transaction.
  Possible enum values:
    - `authorization`
      The transaction represents an authorization for capturing the `[amount](/docs/api/transactions/transaction-object#amount)` from the customer's `[payment_source](/docs/api/payment_sources)` .
    - `payment`
      The transaction represents capture of `[amount](/docs/api/transactions/transaction-object#amount)` from the customer's `[payment_source](/docs/api/payment_sources)` .
    - `refund`
      The transaction represents a refund of `[amount](/docs/api/transactions/transaction-object#amount)` to the customer's `[payment_source](/docs/api/payment_sources)` .
    - `payment_reversal`
      Indicates a reversal transaction.

- `date` (optional, timestamp(UTC) in seconds)
  Indicates when this transaction occurred.

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

- `amount` (optional, in cents, min=0)
  Amount for this transaction.

- `id_at_gateway` (optional, string, max chars=100)
  The id with which this transaction is referred in gateway.

- `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`
      Connection with Gateway got terminated abruptly. So, status of this transaction needs to be resolved manually
    - `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.

- `initiator_type` (optional, enumerated string)
  Marker for on-session payments (3DS). null indicates 'merchant'.
  Possible enum values:
    - `customer`
      Customer initiated 3DS payment
    - `merchant`
      Payment initiated on stored payment method by the merchant

- `three_d_secure` (optional, boolean)
  Indicates whether this transaction has gone through 3DS. Applicable only for 'on-session' payments & verifications.If 3DS is not enforced by the gateway/bank or if the customers' card is not enrolled, this will be false.

- `error_code` (optional, string, max chars=100)
  Error code received from the payment gateway on failure.

- `error_text` (optional, string, max chars=65k)
  Error message received from the payment gateway on failure.

- `voided_at` (optional, timestamp(UTC) in seconds)
  Timestamp indicating when the payment was voided or authorization expired at gateway.

- `amount_unused` (optional, in cents, min=0)
  This is the part of the `amount` which has not been invoiced yet and is therefore added to `[excess_payments](/docs/api/customers/customer-object#excess_payments)` for the customer. Applicable only for a transaction of `type` = `payment` .

- `masked_card_number` (optional, string, max chars=20)
  The masked card number used for this transaction. Applicable only for 'Card' Payment Method

- `reference_transaction_id` (optional, string, max chars=40)
  This is the `id` of the offline transaction that is being refunded or reversed. Applicable only for transaction of `type` = `refund` or `payment_reversal` .

- `refunded_txn_id` (optional, string, max chars=40)
  This is the `id` of the transaction (always of `type` = `payment` ) being refunded. Applicable only for transaction of `type` = `refund` .

- `reversal_transaction_id` (optional, string, max chars=40)
  Reversal transaction id. Applicable only for payment transactions.

- `payment_method_details` (optional, string)
  Payment method details of the corresponding transaction

- `linked_invoices` (optional, list of invoice_transaction)
  Applicable only for 'Payment' transactions. The list of invoices this 'payment' transaction is applied to.
  - `invoice_id` (required, string, max chars=50)
    Identifier for the invoice.
  - `applied_amount` (required, in cents, min=0)
    The transaction amount applied to this invoice
  - `applied_at` (required, timestamp(UTC) in seconds)
    Timestamp at which the transaction is applied.
  - `invoice_date` (optional, timestamp(UTC) in seconds)
    The date this invoice is issued.
  - `invoice_amount` (optional, in cents, min=0)
    Total amount of the invoice

- `linked_refunds` (optional, list of txn_refunds_and_reversal)
  Applicable only for Payment transactions. It only returns values when the transaction is not associated with an invoice, and that there is a refund for the transaction.
  - `txn_id` (required, string, max chars=40)
    Uniquely identifies the transaction.
  - `txn_status` (required, 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`
        Connection with Gateway got terminated abruptly. So, status of this transaction needs to be resolved manually
      - `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` (required, timestamp(UTC) in seconds)
    Indicates when this refund occured.
  - `txn_amount` (required, in cents, min=0)
    Amount of this refund transaction.

