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

# Query Refund Payment

> **The payment gateway requests a query refund payment status**

Check the status of a refund previously requested via [Refund Payment](/api-reference/refund-payment). Use this to confirm whether a refund has completed, is still processing, or failed.

## Errors

In addition to standard signature errors, this endpoint can return:

| Code | Name                           | Meaning                                                                                                               |
| ---- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| 2010 | `TransactionNotFound`          | `transactionNumber` does not match a transaction, or (for a refund-only lookup) the refund hasn't been processed yet. |
| 2043 | `FailedToRefundQuery`          | The transaction's channel/provider does not support querying refund status.                                           |
| 2130 | `ChannelNotSupportRefund`      | The transaction's channel is configured to not support refunds.                                                       |
| 2160 | `InvalidPaymentGatewaySetting` | The channel's provider settings are missing or misconfigured for this tenant.                                         |


## OpenAPI

````yaml /openapi.json get /api/services/app/PaymentGateway/QueryRefund
openapi: 3.0.1
info:
  title: CommercePay API
  version: v1
  description: >
    ---

    **Credentials Accounts**


    Every account is provided with separate keys for testing and for running
    live transactions. Once the merchant application has been approved,
    developers can begin the process of integrating the CommercePay API. The
    following details will be provided to get started with the integration. 


    <a href="https://docs.commercepay.asia/docs/api/d19b0f3289ae0-get-started"
    target="_blank">Get Started</a>
  contact: {}
servers:
  - description: Staging
    url: https://staging-payments.commerce.asia
  - url: https://payments.commerce.asia
    description: Production
security: []
paths:
  /api/services/app/PaymentGateway/QueryRefund:
    get:
      tags:
        - PaymentGateway
      summary: Query Refund Payment
      description: >-
        **The payment gateway requests a query refund payment status**


        Check the status of a refund previously requested via [Refund
        Payment](/api-reference/refund-payment). Use this to confirm whether a
        refund has completed, is still processing, or failed.
      operationId: ApiServicesAppPaymentgatewayQueryrefundGet
      parameters:
        - name: TransactionNumber
          in: query
          schema:
            type: string
            maxLength: 24
          description: Unique CAP Transaction Number
          required: true
        - name: Timestamp
          in: query
          schema:
            type: integer
            format: int64
            example: 1621851652617
          description: new Date().getTime()
          required: true
        - $ref: '#/components/parameters/AbpTenantId'
        - $ref: '#/components/parameters/Authorization'
        - $ref: '#/components/parameters/CapSignature'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RequestRefundOutputDto'
              examples:
                Example 1:
                  value:
                    tenantId: 0
                    transactionNumber: string
                    refundTransactionNumber: string
                    referenceCode: string
                    amount: 0
                    currencyCode: string
                    refundStatus: 11
                    responseMessage: string
                    paymentSessionNumber: string
                    refundPaymentList:
                      transactionNumber: string
                      amount: 0
                      currencyCode: string
                      refundReason: string
                      refundStatus: 11
            text/json:
              schema:
                $ref: '#/components/schemas/RequestRefundOutputDto'
            text/plain:
              schema:
                $ref: '#/components/schemas/RequestRefundOutputDto'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorOutputDto'
              examples:
                TransactionNotFound:
                  value:
                    code: 2010
                    message: >-
                      transactionNumber does not match a transaction, or the
                      refund hasn't been processed yet.
components:
  parameters:
    AbpTenantId:
      schema:
        type: string
      in: header
      name: Abp-TenantId
      required: true
      description: Your unique Merchant ID assigned by CommercePay.
    Authorization:
      schema:
        type: string
      in: header
      name: Authorization
      required: true
      description: Your API credentials used for authentication (typically a Bearer token).
    CapSignature:
      schema:
        type: string
      in: header
      name: cap-signature
      required: true
      description: >-
        A unique security hash used to verify the integrity of the request body.
        See [Generate Signature](/docs/generate-signature) for how to generate
        this.
  schemas:
    RequestRefundOutputDto:
      type: object
      additionalProperties: false
      x-internal: false
      properties:
        tenantId:
          type: integer
          format: int64
          description: Merchant ID.
        transactionNumber:
          type: string
          description: >-
            Unique CAP Transaction Number of the original payment being
            refunded.
          maxLength: 24
          nullable: true
        refundTransactionNumber:
          type: string
          description: >-
            Unique CAP Transaction Number for the refund transaction itself,
            distinct from the original payment's transactionNumber.
          nullable: true
        referenceCode:
          type: string
          description: Merchant Reference Code
          nullable: true
        amount:
          type: number
          format: double
          description: "Please take note: The Amount parameter only accepts integer units. For example, 1000 is equivalent to 10.00 for the backend.\r\n\r\nInvalid Format: 1,000.00"
          example: 100
        currencyCode:
          type: string
          description: Currency code with a 3-letter ISO 4217 standard code
          example: MYR
          maxLength: 3
          nullable: true
        refundStatus:
          $ref: '#/components/schemas/RefundStatus'
        responseMessage:
          type: string
          description: Human-readable status message for the refund request.
          nullable: true
        paymentSessionNumber:
          type: string
          description: Unique CAP Session Number
          maxLength: 24
          nullable: true
        refundPaymentList:
          $ref: '#/components/schemas/RefundPaymentListDto'
      x-examples:
        Example 1:
          tenantId: 0
          transactionNumber: string
          paymentSessionNumber: string
          refundTransactionNumber: string
          referenceCode: string
          amount: 0
          currencyCode: string
          refundStatus: 0
          refundPaymentList:
            - transactionNumber: string
              amount: 0
              currencyCode: string
              refundReason: string
              refundStatus: 0
          responseMessage: string
    ErrorOutputDto:
      type: object
      additionalProperties: false
      properties:
        code:
          type: integer
          description: See the Errors table above.
        message:
          type: string
          nullable: true
    RefundStatus:
      enum:
        - 11
        - 12
        - 13
        - 16
        - 17
        - 18
      type: integer
      format: int32
      x-enumNames:
        - Refunded
        - ProcessingRefund
        - FailedRefund
        - RefundWithCharges
        - RefundReverse
        - Voided
      description: >-
        Status of the refund itself (not the original payment).


        | Value | Name | Meaning |

        | ----- | ---- | ------- |

        | 11 | `Refunded` | Refund completed successfully. |

        | 12 | `ProcessingRefund` | Refund request accepted, being processed by
        the provider. |

        | 13 | `FailedRefund` | Refund attempt failed. |

        | 16 | `RefundWithCharges` | Refund completed, but provider/processing
        charges were deducted from the refunded amount. |

        | 17 | `RefundReverse` | A previously completed refund was reversed by
        the provider. |

        | 18 | `Voided` | The original transaction was voided instead of
        refunded, e.g. same-day cancellation. |
    RefundPaymentListDto:
      title: RefundPaymentListDto
      type: object
      properties:
        transactionNumber:
          type: string
          description: Unique CAP Transaction Number
          maxLength: 24
          nullable: true
        amount:
          type: number
          format: double
          description: Refund Amount.
          example: 100
        currencyCode:
          type: string
          description: Currency code with a 3-letter ISO 4217 standard code
          example: MYR
          maxLength: 3
          nullable: true
        refundReason:
          type: string
          description: A description for refund.
          nullable: true
        refundStatus:
          $ref: '#/components/schemas/RefundStatus'

````