> ## 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.

# Refund Payment

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

Initiate a full or partial refund for a successful payment transaction. See [Refund Integration](/docs/refund-integration) for full vs. partial refund behavior and bank support. The response's `refundStatus` reflects the outcome directly — if it comes back as `ProcessingRefund`, use [Query Refund Payment](/api-reference/query-refund-payment) to check when it completes.

## Errors

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

| Code | Name                           | Meaning                                                                                                                                                                                                                                                                               |
| ---- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 2010 | `TransactionNotFound`          | `transactionNumber` does not match a transaction, or the transaction is not in `Success` status.                                                                                                                                                                                      |
| 2042 | `FailedToRequestRefund`        | Generic refund failure. The message names the specific cause, e.g. a refund is already in progress for this transaction, the requested amount exceeds what's still available to refund, the channel doesn't support partial refunds, or the provider is unavailable for this channel. |
| 2044 | `MissingRequireField`          | `reason` was not supplied.                                                                                                                                                                                                                                                            |
| 2094 | `InvalidTenantProfile`         | Tenant could not be resolved (no session tenant and no `tenantId` in the request body).                                                                                                                                                                                               |
| 2124 | `RequestRefundTimeOut`         | The provider's refund API timed out while processing the request.                                                                                                                                                                                                                     |
| 2130 | `ChannelNotSupportRefund`      | The original transaction's channel is configured to not support refunds.                                                                                                                                                                                                              |
| 2160 | `InvalidPaymentGatewaySetting` | The channel's provider settings are missing or misconfigured for this tenant.                                                                                                                                                                                                         |

> A refund amount of `0` (or negative) is also rejected via `FailedToRequestRefund` (2042), with the message "Refund amount cannot be 0".


## OpenAPI

````yaml /openapi.json post /api/services/app/PaymentGateway/RefundPayment
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/RefundPayment:
    post:
      tags:
        - PaymentGateway
      summary: Refund Payment
      description: >-
        **The payment gateway requests a refund payment**


        Initiate a full or partial refund for a successful payment transaction.
        See [Refund Integration](/docs/refund-integration) for full vs. partial
        refund behavior and bank support. The response's `refundStatus` reflects
        the outcome directly — if it comes back as `ProcessingRefund`, use
        [Query Refund Payment](/api-reference/query-refund-payment) to check
        when it completes.
      operationId: ApiServicesAppPaymentgatewayRefundpaymentPost
      parameters:
        - $ref: '#/components/parameters/AbpTenantId'
        - $ref: '#/components/parameters/Authorization'
        - $ref: '#/components/parameters/CapSignature'
      requestBody:
        content:
          application/json-patch+json:
            schema:
              $ref: '#/components/schemas/RefundPaymentInputDto'
          application/json:
            schema:
              $ref: '#/components/schemas/RefundPaymentInputDto'
          text/json:
            schema:
              $ref: '#/components/schemas/RefundPaymentInputDto'
          application/*+json:
            schema:
              $ref: '#/components/schemas/RefundPaymentInputDto'
      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
                      transaction is not in Success status.
                FailedToRequestRefund:
                  value:
                    code: 2042
                    message: Refund amount cannot be 0
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:
    RefundPaymentInputDto:
      type: object
      additionalProperties: false
      required:
        - transactionNumber
        - reason
        - timestamp
      properties:
        transactionNumber:
          type: string
          description: Unique CAP Transaction Number
          maxLength: 24
          nullable: true
        reason:
          type: string
          description: A description for refund.
          example: Purchase wrong item
          nullable: true
        amount:
          type: integer
          description: "Please take note: The Amount parameter only accepts integer units. For example, 1000 is equivalent to 10.00 for the backend.Show all...\r\n\r\n\r\nExample: 100\r\n\r\n[Please pass the required amount if issuing a partial refund; ignore this attribute if issuing a full refund.]"
          format: int32
          nullable: true
        timestamp:
          type: integer
          format: int64
          description: new Date().getTime()
          example: 1621851652617
    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'

````