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

# Get Transaction Status

> Check the status of a payment transaction by reference

# Get Transaction Status

This endpoint allows you to check the current status of a payment transaction using its reference identifier.

**Endpoint:** `GET /v1/payment/{reference}/status`

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url https://api.staging.kairosafrika.cloud/paygw/v1/payment/20416369453214532143/status \
    --header 'Authorization: Basic $(echo -n "username:password" | base64)'
  ```

  ```javascript JavaScript theme={null}
  const username = 'your_username';
  const password = 'your_password';
  const credentials = btoa(`${username}:${password}`);

  const response = await fetch('https://api.staging.kairosafrika.cloud/paygw/v1/payment/20416369453214532143/status', {
    method: 'GET',
    headers: {
      'Authorization': `Basic ${credentials}`
    }
  });

  const result = await response.json();
  console.log(result);
  ```

  ```python Python theme={null}
  import requests
  import base64

  username = 'your_username'
  password = 'your_password'
  credentials = base64.b64encode(f'{username}:{password}'.encode()).decode()

  response = requests.get(
      'https://api.staging.kairosafrika.cloud/paygw/v1/payment/20416369453214532143/status',
      headers={
          'Authorization': f'Basic {credentials}'
      }
  )

  result = response.json()
  print(result)
  ```

  ```php PHP theme={null}
  <?php
  $username = 'your_username';
  $password = 'your_password';
  $credentials = base64_encode($username . ':' . $password);

  $curl = curl_init();

  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.staging.kairosafrika.cloud/paygw/v1/payment/20416369453214532143/status',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
      'Authorization: Basic ' . $credentials
    ),
  ));

  $response = curl_exec($curl);
  curl_close($curl);
  echo $response;
  ?>
  ```
</RequestExample>

## Path Parameter

* **reference** (string, required): The reference identifier of the payment transaction to check.
  * Example: `20416369453214532143`

## Responses

### 200 OK - Transaction Status Retrieved Successfully

```json theme={null}
{
    "statusCode": "0000",
    "statusMessage": "Successful",
    "transactionId": "20416369453214532143",
    "data": {
        "reference": "20416369453214532143",
        "status": "COMPLETED",
        "amount": 45,
        "charge": 0.68,
        "totalAmount": 45.68,
        "payee": "Kairos",
        "payer": "testOne",
        "narration": "PIZZAMAN/CHICKMAN",
        "msisdn": "233559400612",
        "completedAt": "2024-07-17T14:30:00Z"
    },
    "links": [
        {
            "rel": "payment",
            "href": "/v1/payment"
        }
    ]
}
```

### 404 Not Found - Transaction Not Found

```json theme={null}
{
    "statusCode": "0404",
    "statusMessage": "Transaction not found",
    "transactionId": null,
    "data": null,
    "links": []
}
```

### 401 Unauthorized - Invalid Credentials

```json theme={null}
{
    "statusCode": "0401",
    "statusMessage": "Unauthorized",
    "transactionId": null,
    "data": null,
    "links": []
}
```

## Response Fields

* **statusCode** (string): Status code indicating the result of the request
  * `"0000"`: Successful
  * `"0404"`: Transaction not found
  * `"0401"`: Unauthorized
* **statusMessage** (string): Human-readable status message
* **transactionId** (string): Unique transaction identifier for tracking
* **data** (object): Transaction details when successful
  * **reference** (string): Reference identifier for the payment
  * **status** (string): Current transaction status - `PENDING`, `COMPLETED`, `FAILED`, `CANCELLED`
  * **amount** (number): Base payment amount
  * **charge** (number): Processing charge amount
  * **totalAmount** (number): Total amount including charges
  * **payee** (string): Name of the payee receiving the payment
  * **payer** (string): Name or identifier of the payer
  * **narration** (string): Payment description or narration
  * **msisdn** (string): Mobile subscriber identifier
  * **completedAt** (string): ISO 8601 timestamp when transaction was completed (null if not completed)
* **links** (array): HATEOAS links for related actions

## Transaction Status Values

* **PENDING**: Transaction is being processed
* **COMPLETED**: Transaction has been successfully completed
* **FAILED**: Transaction failed to process
* **CANCELLED**: Transaction was cancelled

## Usage Example

Use this endpoint to check the current status of a payment transaction. This is particularly useful for:

* Polling transaction status after initiating a payment
* Verifying payment completion before fulfilling orders
* Troubleshooting failed transactions


## OpenAPI

````yaml GET /v1/payment/{reference}/status
openapi: 3.0.3
info:
  title: Kairos Afrika Payment API
  description: >-
    Process payments and manage transactions through the Kairos Afrika platform.
    Switch between staging and production environments using the server
    dropdown.
  version: 1.0.0
  contact:
    name: Kairos Afrika Support
    email: support@kairosafrika.com
servers:
  - url: /
    description: API Base
security:
  - basicAuth: []
paths:
  /v1/payment/{reference}/status:
    get:
      tags:
        - Payments
      summary: Get Transaction Status
      description: Check the status of a payment transaction by reference
      operationId: getTransactionStatus
      parameters:
        - name: reference
          in: path
          required: true
          description: The reference identifier of the payment transaction
          schema:
            type: string
          example: '20416369453214532143'
      responses:
        '200':
          description: Transaction status retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionStatusResponse'
        '401':
          description: Unauthorized - Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Transaction not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TransactionStatusResponse:
      type: object
      properties:
        statusCode:
          type: string
          description: Status code indicating the result of the request
          example: '0000'
        statusMessage:
          type: string
          description: Human-readable status message
          example: Successful
        transactionId:
          type: string
          description: Unique transaction identifier for tracking
          example: '20416369453214532143'
        data:
          type: object
          nullable: true
          description: Transaction details when successful
          properties:
            reference:
              type: string
              description: Reference identifier for the payment
              example: '20416369453214532143'
            status:
              type: string
              description: Current transaction status
              enum:
                - PENDING
                - COMPLETED
                - FAILED
                - CANCELLED
              example: COMPLETED
            amount:
              type: number
              description: Base payment amount
              example: 45
            charge:
              type: number
              description: Processing charge amount
              example: 0.68
            totalAmount:
              type: number
              description: Total amount including charges
              example: 45.68
            payee:
              type: string
              description: Name of the payee receiving the payment
              example: Kairos
            payer:
              type: string
              description: Name or identifier of the payer
              example: testOne
            narration:
              type: string
              description: Payment description or narration
              example: PIZZAMAN/CHICKMAN
            msisdn:
              type: string
              description: Mobile subscriber identifier
              example: '233559400612'
            completedAt:
              type: string
              format: date-time
              nullable: true
              description: ISO 8601 timestamp when transaction was completed
              example: '2024-07-17T14:30:00Z'
        links:
          type: array
          description: HATEOAS links for related actions
          items:
            type: object
            properties:
              rel:
                type: string
                description: Relationship type
                example: payment
              href:
                type: string
                description: Link URL
                example: /v1/payment
    Error:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          description: Error code
          example: INSUFFICIENT_FUNDS
        message:
          type: string
          description: Human-readable error message
          example: The customer has insufficient funds for this transaction
        details:
          type: object
          description: Additional error details
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Basic authentication using base64 encoded username:password

````