# Query refunds

> Query refund records by Payment Intent, refund transaction, original transaction, or time range.

```yaml
openapi: 3.1.0
info:
  title: Query refunds
  version: 1.0.0
  description: Query refund records by Payment Intent, refund transaction,
    original transaction, or time range.
paths:
  /v1/txn/queryRefunds:
    post:
      summary: Query refunds
      description: Query refund records by Payment Intent, refund transaction,
        original transaction, or time range.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                merchantNo:
                  type: string
                  description: Merchant number assigned by Onerway. See
                    [Setup](/payments/get-started/setup#retrieve-your-credentials)
                    for how to obtain it.
                paymentId:
                  type: string
                  description: Payment intent ID, transmitted as a JSON string and used to
                    retrieve associated transactions and refund records at the
                    Payment level.
                  x-onerway-required: conditional
                  x-onerway-condition:
                    - Provide this field as one query condition. At least one of
                      `paymentId`, `transactionId`, `originTransactionId`, or
                      `startTime` + `endTime` is required.
                transactionId:
                  type: string
                  description: Refund transaction number, transmitted as a JSON string and used to
                    precisely query a single refund record.
                  x-onerway-required: conditional
                  x-onerway-condition:
                    - Provide this field as one query condition. At least one of
                      `paymentId`, `transactionId`, `originTransactionId`, or
                      `startTime` + `endTime` is required.
                originTransactionId:
                  type: string
                  description: Original Onerway transaction ID associated with the refund,
                    transmitted as a JSON string and used to query refund
                    records by original transaction.
                  x-onerway-required: conditional
                  x-onerway-condition:
                    - Provide this field as one query condition. At least one of
                      `paymentId`, `transactionId`, `originTransactionId`, or
                      `startTime` + `endTime` is required.
                startTime:
                  type: string
                  description: Start of the query time range, filtered by transaction creation
                    time, in `yyyy-MM-dd HH:mm:ss` format.
                  x-onerway-required: conditional
                  x-onerway-condition:
                    - Required together with `endTime` when querying by time
                      range. At least one of `paymentId`, `transactionId`,
                      `originTransactionId`, or `startTime` + `endTime` is
                      required.
                  x-onerway-constraints:
                    - kind: rule
                      text: The maximum range between `startTime` and `endTime` is 90 days.
                endTime:
                  type: string
                  description: End of the query time range, in `yyyy-MM-dd HH:mm:ss` format.
                  x-onerway-required: conditional
                  x-onerway-condition:
                    - Required together with `startTime` when querying by time
                      range.
                  x-onerway-constraints:
                    - kind: consistency
                      text: "`endTime` must be later than `startTime`."
                    - kind: rule
                      text: The maximum range between `startTime` and `endTime` is 90 days.
                current:
                  type: string
                  description: Refund query page number. `0` and `1` both mean the first page.
                    When omitted, Onerway uses the first page. The response
                    `current` value is always returned as a 1-based page number.
                size:
                  type: string
                  description: Page size. This endpoint returns up to `10` records per page and
                    does not support custom page sizes.
                sign:
                  type: string
                  description: Request signature string. See [Request
                    signing](/payments/get-started/request-signing) for how to
                    generate it.
              required:
                - merchantNo
                - sign
            examples:
              query-refunds-by-payment-id:
                summary: Query refunds by payment ID
                value:
                  current: "1"
                  merchantNo: replace_with_merchant_no
                  paymentId: "2031908578000000000"
                  sign: "{{SIGN}}"
                  size: "10"
      responses:
        "200":
          description: Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  respCode:
                    type: string
                    description: "`20000` means the query request was processed successfully. It
                      does not mean each refund record has succeeded. Other
                      values are error codes. See [Response
                      codes](/payments/api-reference/response-codes)."
                  respMsg:
                    type: string
                    description: Human-readable message for the response code.
                  data:
                    type: object
                    properties:
                      content:
                        type: array
                        description: Refund records matching the query conditions. Each item represents
                          one refund transaction.
                        items:
                          type: object
                          properties:
                            paymentId:
                              type: string
                              description: Payment intent ID, transmitted as a JSON string. One `paymentId`
                                can be associated with multiple transactions or
                                refund records.
                            originTransactionId:
                              type: string
                              description: Original Onerway transaction ID associated with this refund,
                                transmitted as a JSON string. Use it to link the
                                refund record back to the original transaction.
                            transactionId:
                              type: string
                              description: Refund transaction ID, transmitted as a JSON string and identifying
                                a single refund transaction.
                            status:
                              type: string
                              description: Current refund transaction status. Values follow `TxnStatusEnum`;
                                `N` indicates a canceled refund.
                              enum:
                                - S
                                - F
                                - P
                                - R
                                - N
                                - I
                                - U
                              x-enum-descriptions:
                                S: Successful transaction. This is a terminal status.
                                F: Failed transaction. This is a terminal status.
                                P: Transaction is processing. Do not treat it as final before a terminal status
                                  is returned.
                                R: Redirect is required to continue payment.
                                N: Canceled transaction. The transaction was closed because it was not paid
                                  within its validity window — for example, the
                                  checkout session timed out before the customer
                                  paid. This is a terminal status with no fund
                                  movement.
                                I: Transaction is under review or approval.
                                U: Waiting for payment.
                            reason:
                              type:
                                - string
                                - "null"
                              description: Refund failure reason.
                              x-onerway-value:
                                nullable: true
                                when:
                                  en: Has a value when the refund failed or a failure reason needs to be returned.
                                    Successful refund records can return `null`.
                                  zh: 退款失败或需要返回失败原因时才有值；成功退款记录可能为 `null`。
                            amount:
                              type: string
                              description: Refund amount.
                            currency:
                              type: string
                              description: Refund currency as a three-letter [ISO
                                4217](https://en.wikipedia.org/wiki/ISO_4217)
                                currency code.
                            arn:
                              type:
                                - string
                                - "null"
                              description: Acquirer Reference Number (ARN), used for reconciliation and
                                dispute handling.
                              x-onerway-value:
                                nullable: true
                                when:
                                  en: Has a value after the acquiring network or channel returns an ARN; returns
                                    `null` when ARN is not available.
                                  zh: 收单网络或渠道返回 ARN 后才有值；ARN 不可用时返回 `null`。
                            createTime:
                              type: string
                              description: Refund creation time in `yyyy-MM-dd HH:mm:ss` format.
                      current:
                        type: string
                        description: Returned page number, using 1-based numbering.
                      size:
                        type: number
                        description: Page size used for pagination. Use `totalElements` for the total
                          number of matching records.
                      totalPages:
                        type: number
                        description: Total number of pages.
                      totalElements:
                        type: number
                        description: Total number of refund records matching the query conditions.
                    description: Business data object containing refund records and pagination
                      information.
```
