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

# Get payment

> Get the current status of an Express payment attempt using either the paymentId or related transactionId returned by POST /v1/express.

**Permissions**: `transactions.read`



## OpenAPI

````yaml https://api.moflay.com/openapi get /v1/payments/{id}
openapi: 3.1.0
info:
  title: Moflay API
  description: The fastest way to add M-Pesa payments.
  version: 1.0.0
  contact:
    name: Moflay Support
    email: support@moflay.com
    url: https://moflay.com
  termsOfService: https://moflay.com/legal/terms-of-service
servers:
  - url: https://api.moflay.com
    description: Production server
security:
  - token: []
tags:
  - name: Customers
    description: Create and manage customers in the organization
  - name: Transactions
    description: Everything about transactions in the organization
  - name: Express
    description: >-
      Create M-Pesa Express payments. Use the returned paymentId with the
      Payments API to read status.
  - name: Payments
    description: >-
      Track payment lifecycle and status for paymentIds returned by Express
      payment creation.
externalDocs:
  url: https://moflay.com/docs
  description: Moflay Documentation
paths:
  /v1/payments/{id}:
    get:
      tags:
        - Payments
      summary: Get payment
      description: >-
        Get the current status of an Express payment attempt using either the
        paymentId or related transactionId returned by POST /v1/express.


        **Permissions**: `transactions.read`
      operationId: getPayment
      parameters:
        - schema:
            $ref: '#/components/schemas/PaymentLookupId'
          required: true
          description: >-
            Payment lookup identifier. Use a paymentId prefixed with 'pay_' or
            the related transactionId prefixed with 'trxn_'.
          name: id
          in: path
      responses:
        '200':
          description: Payment Status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentStatus'
        '401':
          description: Missing API Key Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MissingApiKeyError'
        '403':
          description: Invalid API Key Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidApiKeyError'
        '404':
          description: Payment Not Found
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/NotFoundError'
                  - description: Payment Not Found
        '405':
          description: Method Not Allowed Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MethodNotAllowedError'
        '422':
          description: The validation error(s) or invalid access error
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ValidationError'
                  - $ref: '#/components/schemas/InvalidAccessError'
                description: The validation error(s) or invalid access error
        '429':
          description: Rate Limit Exceeded Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitExceededError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
      security:
        - token: []
components:
  schemas:
    PaymentLookupId:
      type: string
      example: pay_ABC123DEF456GHI
      description: >-
        Payment lookup identifier. Use a paymentId prefixed with 'pay_' or the
        related transactionId prefixed with 'trxn_'.
    PaymentStatus:
      type: object
      properties:
        id:
          type: string
          example: pay_ABC123DEF456GHI
          description: Unique identifier for the payment, prefixed with 'pay_'
        transactionId:
          type: string
          example: trxn_ABC123DEF456GHI
          description: Unique identifier for the related transaction, prefixed with 'trxn_'
        customerId:
          type:
            - string
            - 'null'
          example: cus_GqfKXLmg61LURZhB
          description: >-
            Unique identifier for the customer attached to the payment, prefixed
            with 'cus_'
        merchantRequestId:
          type:
            - string
            - 'null'
          example: 29115-34620561-1
          description: M-Pesa MerchantRequestID returned by Safaricom
        checkoutRequestId:
          type:
            - string
            - 'null'
          example: ws_CO_191220241030123456789
          description: M-Pesa CheckoutRequestID used to reconcile the STK push
        status:
          $ref: '#/components/schemas/TransactionStatus'
        statusDetail:
          type:
            - string
            - 'null'
          example: The service request is processed successfully.
          description: >-
            Provider detail explaining the current payment status, when
            available
        failureReason:
          type:
            - string
            - 'null'
          example: The customer cancelled the STK prompt.
          description: >-
            Developer-readable explanation when the payment failed, was
            canceled, or moved to an unknown state. Null for successful or
            in-progress payments.
        amount:
          type: number
          example: 1000
          description: Payment amount in the smallest currency unit
        currency:
          type: string
          example: KES
          description: Three-letter ISO currency code for the payment
        description:
          type: string
          example: Premium plan
          description: Short customer-facing payment description
        accountReference:
          type: string
          example: ORDER123
          description: >-
            Short alphanumeric reference that was sent to M-Pesa and stored with
            this payment, such as an order or invoice number.
        receiptNumber:
          type:
            - string
            - 'null'
          example: QMF7MBB5ED
          description: M-Pesa receipt number for a completed payment
        environment:
          type: string
          enum:
            - sandbox
            - production
          example: sandbox
          description: >-
            Environment where the payment was created. Either 'sandbox' or
            'production'
        createdAt:
          type: string
          format: date-time
          example: '2024-12-19T10:25:00.000Z'
          description: Timestamp when the payment was created (ISO 8601 format)
        updatedAt:
          type: string
          format: date-time
          example: '2024-12-19T10:32:00.000Z'
          description: Timestamp when the payment was last updated (ISO 8601 format)
        processedAt:
          type:
            - string
            - 'null'
          format: date-time
          example: '2024-12-19T10:32:00.000Z'
          description: >-
            Timestamp when the payment reached a terminal completed, failed,
            canceled, or unknown state (ISO 8601 format)
        completedAt:
          type:
            - string
            - 'null'
          format: date-time
          example: '2024-12-19T10:32:00.000Z'
          description: Timestamp when the payment completed successfully (ISO 8601 format)
        failedAt:
          type:
            - string
            - 'null'
          format: date-time
          example: null
          description: Timestamp when the payment failed (ISO 8601 format)
        unknownAt:
          type:
            - string
            - 'null'
          format: date-time
          example: null
          description: >-
            Timestamp when the payment moved to an unknown state (ISO 8601
            format)
      required:
        - id
        - transactionId
        - customerId
        - merchantRequestId
        - checkoutRequestId
        - status
        - statusDetail
        - failureReason
        - amount
        - currency
        - description
        - accountReference
        - receiptNumber
        - environment
        - createdAt
        - updatedAt
        - processedAt
        - completedAt
        - failedAt
        - unknownAt
      example:
        id: pay_ABC123DEF456GHI
        transactionId: trxn_ABC123DEF456GHI
        customerId: cus_GqfKXLmg61LURZhB
        merchantRequestId: 29115-34620561-1
        checkoutRequestId: ws_CO_191220241030123456789
        status: completed
        statusDetail: The service request is processed successfully.
        failureReason: null
        amount: 1000
        currency: KES
        description: Premium plan
        accountReference: ORDER123
        receiptNumber: QMF7MBB5ED
        environment: sandbox
        createdAt: '2024-12-19T10:25:00.000Z'
        updatedAt: '2024-12-19T10:32:00.000Z'
        processedAt: '2024-12-19T10:32:00.000Z'
        completedAt: '2024-12-19T10:32:00.000Z'
        failedAt: null
        unknownAt: null
      description: Payment Status
    MissingApiKeyError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 401
            code:
              type: string
              description: Machine-readable error name
              example: missing_api_key
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: Missing API key in the authorization header.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Missing API Key Error
    InvalidApiKeyError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 403
            code:
              type: string
              description: Machine-readable error name
              example: invalid_api_key
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: API key is invalid.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Invalid API Key Error
    NotFoundError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 404
            code:
              type: string
              description: Machine-readable error name
              example: not_found
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: The requested endpoint does not exist.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Customer Not Found
    MethodNotAllowedError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 405
            code:
              type: string
              description: Machine-readable error name
              example: method_not_allowed
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: Method is not allowed for the requested path.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Method Not Allowed Error
    ValidationError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 422
            code:
              type: string
              description: Machine-readable error name
              example: validation_error
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: We found an error with one or more fields in the request.
            validation:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                    description: The name of the field that failed validation
                    example: email
                  message:
                    type: string
                    description: The validation error message for the field
                    example: Invalid email format
                required:
                  - field
                  - message
              description: List of field-specific validation issues
              example:
                - field: email
                  message: Invalid email format
                - field: age
                  message: Expected number, received string
          required:
            - status
            - code
            - message
            - validation
      required:
        - error
    InvalidAccessError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 422
          required:
            - status
        code:
          type: string
          description: Machine-readable error name
          example: invalid_access
        message:
          type: string
          x-speakeasy-error-message: true
          description: Human-readable error message
          example: >-
            The API key does not have the necessary permissions to access this
            resource.
      required:
        - error
        - code
        - message
    RateLimitExceededError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 429
            code:
              type: string
              description: Machine-readable error name
              example: rate_limit_exceeded
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: You have exceeded your request limit. Please try again later.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Rate Limit Exceeded Error
    InternalServerError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 500
            code:
              type: string
              description: Machine-readable error name
              example: internal_server_error
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: An unexpected error occurred.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Internal Server Error
    TransactionStatus:
      type: string
      enum:
        - initiating
        - pending
        - completed
        - failed
        - canceled
        - unknown
      example: completed
      description: >-
        Current status. Possible values: initiating, pending, completed, failed,
        canceled, unknown
  securitySchemes:
    token:
      type: http
      scheme: bearer
      description: The API key to use for authentication
      x-speakeasy-example: MOFLAY_API_KEY

````