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

# Find a payment by order

> Returns the newest payment for a `merchantOrderId`.



## OpenAPI

````yaml /api-reference/openapi.yaml get /v1/payments
openapi: 3.1.0
info:
  title: PrimePay API
  version: '1.0'
  description: >-
    Collect mobile money payments, send transfers and make payouts with the
    PrimePay API.
servers:
  - url: https://api.primepay.mw
    description: Live API (live keys, `sk_live_…`)
  - url: https://sandbox-api.primepay.mw
    description: Sandbox API (test keys, `sk_test_…`)
security:
  - bearerAuth: []
tags:
  - name: Operators
  - name: Payments
  - name: Refunds
  - name: Transfers
  - name: Payouts
  - name: Payment links
  - name: Checkout sessions
paths:
  /v1/payments:
    get:
      tags:
        - Payments
      summary: Find a payment by order
      description: Returns the newest payment for a `merchantOrderId`.
      operationId: getPaymentByOrder
      parameters:
        - name: merchantOrderId
          in: query
          required: true
          schema:
            type: string
            example: ORDER-5531
          description: Your order or invoice number.
      responses:
        '200':
          description: The newest payment for that order.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Payment'
        '404':
          $ref: '#/components/responses/Error'
components:
  schemas:
    Payment:
      type: object
      properties:
        reference:
          type: string
          example: TXN-WRYF6S2W3DQW
        status:
          type: string
          enum:
            - pending
            - processing
            - success
            - failed
            - expired
            - cancelled
            - reversed
        amount:
          type: number
        fee:
          type: number
        currency:
          type: string
          example: MWK
        merchantOrderId:
          type: string
        failureCode:
          type:
            - string
            - 'null'
        createdAt:
          type: string
          format: date-time
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
        subMerchantAccountCode:
          type:
            - string
            - 'null'
          description: Set when the payment was collected for a sub-merchant.
        subMerchantName:
          type:
            - string
            - 'null'
        aggregatorFee:
          type:
            - number
            - 'null'
          description: The fee you keep as the aggregator.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: insufficient_funds
            message:
              type: string
              example: Not enough available balance for MWK 25,000.00.
            field:
              type: string
              description: >-
                Payment links only. The field that is missing or wrong, for
                example `items[1].unitAmount`.
  responses:
    Error:
      description: An error. Use `code` in your code; show `message` to people.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >
        Your API key: `sk_live_…` / `sk_test_…` (secret), `pk_live_…` /
        `pk_test_…` (publishable, read-only reference data) or `rk_live_…` /
        `rk_test_…` (payments only).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.