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

# client.getTransaction()

> Fetch a single transaction by ID.

Use this method to fetch a single transaction by its ID, including its stage breakdown. Call it after a payment flow completes (for example, when [`client.setupApplePay()`](/platform/sdk-reference/react-native/setup-apple-pay), [`client.setupGooglePay()`](/platform/sdk-reference/react-native/setup-google-pay), or [`client.setupBuy()`](/platform/sdk-reference/react-native/setup-buy) emits `complete`) to poll for the final transaction status.

For request and response details, see the [Get a transaction API](/api-reference/platform/endpoints/transactions/get).

```tsx Get a transaction focus={5-15} theme={null}
import { useMoonPay } from "@moonpay/platform-sdk-react-native";

export function TransactionDetails({
  transactionId,
}: {
  transactionId: string;
}) {
  const { client } = useMoonPay();

  const load = async () => {
    const result = await client.getTransaction(transactionId);

    if (!result.ok) {
      // Handle error
      console.error(result.error.code, result.error.message);
      return;
    }

    console.log(result.value.data);
  };

  // ...
}
```

***

## Parameters

`client.getTransaction()` takes a single positional argument.

| Argument | Type     | Required | Description                        |
| -------- | -------- | -------- | ---------------------------------- |
| `id`     | `string` | ✅        | The MoonPay ID of the transaction. |

This method does not require a separate auth token. The client uses stored credentials from an active connection.

## Result

`client.getTransaction()` returns a `Result<{ data: TransactionWithStages }, GetTransactionsError>`.

### Result envelope

`Result<{ data: TransactionWithStages }, GetTransactionsError>`

| Field   | Type                                                            | Required | Description                      |
| ------- | --------------------------------------------------------------- | -------- | -------------------------------- |
| `ok`    | `boolean`                                                       | ✅        | Whether the operation succeeded. |
| `value` | `{ data:` [`TransactionWithStages`](#transactionwithstages) `}` |          | Present when `ok` is `true`.     |
| `error` | [`GetTransactionsError`](#gettransactionserror)                 |          | Present when `ok` is `false`.    |

### `TransactionWithStages`

A transaction with its stage breakdown. See the [Transaction object](/api-reference/platform/objects-and-types/transaction) for every field, and the [Get a transaction API](/api-reference/platform/endpoints/transactions/get) for the response shape.

| Field         | Type                | Required | Description                                                                                                                                        |
| ------------- | ------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`          | `string`            | ✅        | The MoonPay ID of the transaction.                                                                                                                 |
| `status`      | `TransactionStatus` | ✅        | The current transaction status. See the [Transaction object](/api-reference/platform/objects-and-types/transaction) for the full list of statuses. |
| `source`      | `object`            | ✅        | The source amount and asset (fiat currency).                                                                                                       |
| `destination` | `object`            | ✅        | The destination amount and asset (cryptocurrency).                                                                                                 |
| `createdAt`   | `string`            | ✅        | An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp of when the transaction was created.                                               |
| `stages`      | `Stage[]`           | ✅        | The transaction's pipeline stages, each with a `kind` and `status`.                                                                                |

### `GetTransactionsError`

`GetTransactionsError` is the standard MoonPay Platform API error shape, `DevPlatformApiError`.

| Field     | Type                          | Required | Description                                                                                                                                                                     |
| --------- | ----------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `code`    | `DevPlatformApiErrorCode`     | ✅        | A machine-readable error code (for example, `"not_found"`, `"unauthorized"`). See the [error reference](/api-reference/platform/documentation/using-the-api) for the full list. |
| `message` | `string`                      | ✅        | A developer-friendly message.                                                                                                                                                   |
| `errors`  | `DevPlatformApiErrorDetail[]` |          | Optional list of field-level errors.                                                                                                                                            |

## Example: poll until terminal status

After a payment flow emits `complete`, poll `client.getTransaction()` until the transaction reaches a terminal status. The set of terminal statuses depends on the flow — check the [Transaction object](/api-reference/platform/objects-and-types/transaction) reference for the values that apply.

```ts Poll for final status theme={null}
const TERMINAL_STATUSES = new Set(["completed", "failed"]);

async function pollTransaction(transactionId: string) {
  while (true) {
    const result = await client.getTransaction(transactionId);

    if (!result.ok) {
      throw new Error(result.error.message);
    }

    const transaction = result.value.data;

    if (TERMINAL_STATUSES.has(transaction.status)) {
      return transaction;
    }

    await new Promise((resolve) => setTimeout(resolve, 3000));
  }
}
```

<Callout icon="circle-info" iconType="regular">
  Webhook support is coming soon. Until then, use polling to track transaction
  status.
</Callout>
