> ## Documentation Index
> Fetch the complete documentation index at: https://paystack-sdk.efobi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Transaction

> Complete API reference for the Transaction module in the Paystack TypeScript SDK

## Overview

The Transaction class provides methods for interacting with Paystack's Transaction API. This module allows you to initialize transactions, verify payments, list transactions, charge saved authorizations, and more.

## Methods

### initialize

Initializes a transaction from your backend.

```typescript theme={null}
async initialize(transaction: TxnInitializeInput): Promise<TxnInitializeSuccess | GenericError>
```

<ParamField path="transaction" type="TxnInitializeInput" required>
  The transaction details to initialize.

  <Expandable title="properties">
    <ParamField path="amount" type="string" required>
      Amount to charge (in kobo for NGN, pesewas for GHS, cents for ZAR and USD)
    </ParamField>

    <ParamField path="email" type="string" required>
      Customer's email address
    </ParamField>

    <ParamField path="currency" type="'NGN' | 'USD' | 'GHS' | 'ZAR' | 'KES' | 'XOF'">
      Currency in which amount should be charged (defaults to NGN)
    </ParamField>

    <ParamField path="reference" type="string">
      Unique transaction reference. Only alphanumeric characters allowed
    </ParamField>

    <ParamField path="callback_url" type="string">
      Fully qualified URL to redirect to when transaction is completed
    </ParamField>

    <ParamField path="plan" type="string">
      If transaction is to create a subscription, provide plan code here
    </ParamField>

    <ParamField path="invoice_limit" type="number">
      Number of invoices to raise during subscription
    </ParamField>

    <ParamField path="metadata" type="any">
      Stringified JSON object of custom data
    </ParamField>

    <ParamField path="channels" type="array">
      An array of payment channels to control what channels you want to make available to the user. Available channels: card, bank, ussd, qr, mobile\_money, bank\_transfer, eft, apple\_pay
    </ParamField>

    <ParamField path="split_code" type="string">
      The split code of the transaction split
    </ParamField>

    <ParamField path="subaccount" type="string">
      The code for the subaccount that owns the payment
    </ParamField>

    <ParamField path="transaction_charge" type="string">
      A flat fee to charge the subaccount for this transaction
    </ParamField>

    <ParamField path="bearer" type="'account' | 'subaccount'">
      Who bears Paystack charges
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="authorization_url" type="string">
      URL to redirect user to for payment
    </ResponseField>

    <ResponseField name="access_code" type="string">
      Access code for the transaction
    </ResponseField>

    <ResponseField name="reference" type="string">
      Unique reference for this transaction
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.initialize({
  amount: "20000",
  email: "customer@email.com",
  currency: "NGN",
  reference: "unique-reference-123",
});

if (error) {
  console.error("Transaction initialization failed:", error);
} else {
  console.log("Redirect user to:", data.authorization_url);
}
```

***

### verify

Confirms the status of a transaction.

```typescript theme={null}
async verify(reference: string): Promise<TxnVerifySuccess | GenericError>
```

<ParamField path="reference" type="string" required>
  The transaction reference to verify
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="id" type="number">
      Transaction ID
    </ResponseField>

    <ResponseField name="domain" type="string">
      Domain type
    </ResponseField>

    <ResponseField name="status" type="string">
      Transaction status (success, failed, abandoned, etc.)
    </ResponseField>

    <ResponseField name="reference" type="string">
      Transaction reference
    </ResponseField>

    <ResponseField name="amount" type="number">
      Amount charged in kobo/cents
    </ResponseField>

    <ResponseField name="currency" type="string">
      Currency code
    </ResponseField>

    <ResponseField name="channel" type="string">
      Payment channel used
    </ResponseField>

    <ResponseField name="gateway_response" type="string">
      Gateway response message
    </ResponseField>

    <ResponseField name="customer" type="object">
      Customer information object
    </ResponseField>

    <ResponseField name="authorization" type="object">
      Authorization details (for card payments)
    </ResponseField>

    <ResponseField name="metadata" type="any">
      Custom metadata passed during initialization
    </ResponseField>

    <ResponseField name="fees" type="number">
      Fees charged
    </ResponseField>

    <ResponseField name="paidAt" type="string">
      ISO datetime when payment was made
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      ISO datetime when transaction was created
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.verify("reference-123");

if (error) {
  console.error("Verification failed:", error);
} else if (data.status === "success") {
  console.log("Payment successful:", data);
}
```

***

### list

Lists transactions carried out on your integration.

```typescript theme={null}
async list(input: TxnListInput): Promise<TxnListSuccess | GenericError>
```

<ParamField path="input" type="TxnListInput" required>
  Query parameters for listing transactions.

  <Expandable title="properties">
    <ParamField path="perPage" type="number">
      Number of records to fetch per page (defaults to 50)
    </ParamField>

    <ParamField path="page" type="number">
      Page number to retrieve (defaults to 1)
    </ParamField>

    <ParamField path="customer" type="string">
      Filter by customer ID
    </ParamField>

    <ParamField path="terminalId" type="string">
      Filter by terminal ID
    </ParamField>

    <ParamField path="status" type="'success' | 'failed' | 'abandoned'">
      Filter by transaction status
    </ParamField>

    <ParamField path="from" type="Date">
      Start date for date range filter
    </ParamField>

    <ParamField path="to" type="string">
      End date for date range filter (ISO datetime)
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="data" type="array">
  Array of transaction objects
</ResponseField>

<ResponseField name="meta" type="object">
  <Expandable title="properties">
    <ResponseField name="next" type="string | null">
      Next page URL
    </ResponseField>

    <ResponseField name="previous" type="string | null">
      Previous page URL
    </ResponseField>

    <ResponseField name="perPage" type="number">
      Records per page
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.list({
  perPage: 100,
  page: 1,
  status: "success",
});

if (error) {
  console.error("Failed to list transactions:", error);
} else {
  console.log(`Found ${data.length} transactions`);
}
```

***

### getTransactionById

Retrieves details of a transaction carried out on your integration.

```typescript theme={null}
async getTransactionById(id: number): Promise<TxnSingleSuccess | GenericError>
```

<ParamField path="id" type="number" required>
  The ID of the transaction
</ParamField>

<ResponseField name="data" type="object">
  Complete transaction object with all details (same structure as verify response)
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.getTransactionById(12345);

if (error) {
  console.error("Failed to fetch transaction:", error);
} else {
  console.log("Transaction details:", data);
}
```

***

### chargeAuthorization

Charges an authorization marked as reusable.

```typescript theme={null}
async chargeAuthorization(input: TxnChargeInput): Promise<TxnChargeSuccess | GenericError>
```

<ParamField path="input" type="TxnChargeInput" required>
  The charge details.

  <Expandable title="properties">
    <ParamField path="amount" type="number" required>
      Amount to charge in kobo/cents
    </ParamField>

    <ParamField path="email" type="string" required>
      Customer's email address
    </ParamField>

    <ParamField path="authorization_code" type="string" required>
      Valid authorization code to charge
    </ParamField>

    <ParamField path="reference" type="string">
      Unique transaction reference
    </ParamField>

    <ParamField path="currency" type="'NGN' | 'USD' | 'GHS' | 'ZAR' | 'KES' | 'XOF'">
      Currency in which amount should be charged
    </ParamField>

    <ParamField path="metadata" type="any">
      Custom data object
    </ParamField>

    <ParamField path="channels" type="array">
      Payment channels to use (card or bank)
    </ParamField>

    <ParamField path="subaccount" type="string">
      Subaccount code
    </ParamField>

    <ParamField path="transaction_charge" type="number">
      Flat fee to charge the subaccount
    </ParamField>

    <ParamField path="bearer" type="'account' | 'subaccount'">
      Who bears Paystack charges (defaults to account)
    </ParamField>

    <ParamField path="queue" type="boolean">
      Queue transaction (defaults to false)
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="amount" type="number">
      Amount charged
    </ResponseField>

    <ResponseField name="currency" type="string">
      Currency code
    </ResponseField>

    <ResponseField name="transaction_date" type="string">
      ISO datetime of transaction
    </ResponseField>

    <ResponseField name="status" type="string">
      Transaction status
    </ResponseField>

    <ResponseField name="reference" type="string">
      Transaction reference
    </ResponseField>

    <ResponseField name="authorization" type="object">
      Authorization details
    </ResponseField>

    <ResponseField name="customer" type="object">
      Customer information
    </ResponseField>

    <ResponseField name="id" type="number">
      Transaction ID
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.chargeAuthorization({
  amount: 10000,
  email: "customer@email.com",
  authorization_code: "AUTH_code123",
});

if (error) {
  console.error("Charge failed:", error);
} else {
  console.log("Charge successful:", data.status);
}
```

***

### viewTxnTimeline

Views the timeline of a transaction.

```typescript theme={null}
async viewTxnTimeline(id_or_reference: string): Promise<TxnTimelineSuccess | GenericError>
```

<ParamField path="id_or_reference" type="string" required>
  The ID or reference of the transaction
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="start_time" type="string">
      ISO time when transaction started
    </ResponseField>

    <ResponseField name="time_spent" type="number">
      Time spent in milliseconds
    </ResponseField>

    <ResponseField name="attempts" type="number">
      Number of attempts
    </ResponseField>

    <ResponseField name="errors" type="number">
      Number of errors
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Whether transaction succeeded
    </ResponseField>

    <ResponseField name="mobile" type="boolean">
      Whether transaction was from mobile
    </ResponseField>

    <ResponseField name="history" type="array">
      Array of timeline events
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.viewTxnTimeline("reference-123");

if (error) {
  console.error("Failed to fetch timeline:", error);
} else {
  console.log("Transaction timeline:", data.history);
}
```

***

### getTxnTotals

Retrieves the total volume of transactions received on your integration.

```typescript theme={null}
async getTxnTotals(input: GenericInput): Promise<TxnTotalsSuccess | GenericError>
```

<ParamField path="input" type="GenericInput" required>
  Query parameters for transaction totals.

  <Expandable title="properties">
    <ParamField path="perPage" type="number">
      Records per page
    </ParamField>

    <ParamField path="page" type="number">
      Page number
    </ParamField>

    <ParamField path="from" type="string">
      Start date (ISO datetime)
    </ParamField>

    <ParamField path="to" type="string">
      End date (ISO datetime)
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="total_transactions" type="number">
      Total number of transactions
    </ResponseField>

    <ResponseField name="total_volume" type="number">
      Total transaction volume
    </ResponseField>

    <ResponseField name="total_volume_by_currency" type="array">
      Volume breakdown by currency
    </ResponseField>

    <ResponseField name="pending_transfers" type="number">
      Pending transfers count
    </ResponseField>

    <ResponseField name="pending_transfers_by_currency" type="array">
      Pending transfers by currency
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.getTxnTotals({
  perPage: 50,
  page: 1,
});

if (error) {
  console.error("Failed to fetch totals:", error);
} else {
  console.log(`Total transactions: ${data.total_transactions}`);
}
```

***

### exportTxns

Exports a list of transactions carried out on your integration.

```typescript theme={null}
async exportTxns(input: TxnExportInput): Promise<TxnExportSuccess | GenericError>
```

<ParamField path="input" type="TxnExportInput" required>
  Query parameters for exporting transactions.

  <Expandable title="properties">
    <ParamField path="perPage" type="number">
      Records per page
    </ParamField>

    <ParamField path="page" type="number">
      Page number
    </ParamField>

    <ParamField path="from" type="string">
      Start date (ISO datetime)
    </ParamField>

    <ParamField path="to" type="string">
      End date (ISO datetime)
    </ParamField>

    <ParamField path="customer" type="string">
      Customer ID filter
    </ParamField>

    <ParamField path="status" type="'success' | 'failed' | 'abandoned'">
      Transaction status filter
    </ParamField>

    <ParamField path="currency" type="string">
      Currency filter
    </ParamField>

    <ParamField path="amount" type="number">
      Amount filter
    </ParamField>

    <ParamField path="settled" type="boolean">
      Settlement status filter
    </ParamField>

    <ParamField path="settlement" type="number">
      Settlement ID filter
    </ParamField>

    <ParamField path="payment_page" type="number">
      Payment page ID filter
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="path" type="string">
      URL to download the export file
    </ResponseField>

    <ResponseField name="expiresAt" type="string">
      ISO datetime when the export expires
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.exportTxns({
  from: "2024-01-01T00:00:00Z",
  to: "2024-12-31T23:59:59Z",
  status: "success",
});

if (error) {
  console.error("Export failed:", error);
} else {
  console.log("Download export from:", data.path);
}
```

***

### partialDebit

Retrieves part of a payment from a customer.

```typescript theme={null}
async partialDebit(input: TxnPartialDebitInput): Promise<TxnPartialDebitSuccess | GenericError>
```

<ParamField path="input" type="TxnPartialDebitInput" required>
  The partial debit details.

  <Expandable title="properties">
    <ParamField path="authorization_code" type="string" required>
      Authorization code for the transaction
    </ParamField>

    <ParamField path="currency" type="'NGN' | 'GHS'" required>
      Currency (defaults to NGN)
    </ParamField>

    <ParamField path="amount" type="number" required>
      Amount to debit
    </ParamField>

    <ParamField path="email" type="string" required>
      Customer's email address
    </ParamField>

    <ParamField path="reference" type="string">
      Unique transaction reference
    </ParamField>

    <ParamField path="at_least" type="number">
      Minimum amount to charge
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="amount" type="number">
      Amount charged
    </ResponseField>

    <ResponseField name="currency" type="string">
      Currency code
    </ResponseField>

    <ResponseField name="status" type="string">
      Transaction status
    </ResponseField>

    <ResponseField name="reference" type="string">
      Transaction reference
    </ResponseField>

    <ResponseField name="requested_amount" type="number">
      Originally requested amount
    </ResponseField>
  </Expandable>
</ResponseField>

**Example Usage:**

```typescript theme={null}
const { data, error } = await paystack.transaction.partialDebit({
  authorization_code: "AUTH_code123",
  currency: "NGN",
  amount: 50000,
  email: "customer@email.com",
  at_least: 30000,
});

if (error) {
  console.error("Partial debit failed:", error);
} else {
  console.log(`Charged ${data.amount} of ${data.requested_amount}`);
}
```

***

## Related Guides

* [Getting Started](/quickstart)
* [Transactions Guide](/guides/transactions)
* [Webhooks Guide](/guides/webhooks)
