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

# 查看退款

> 通过 Anyway 退款 ID 获取一笔退款。

请使用属于目标组织的 API 密钥进行认证。属于其他组织的退款会返回 `404`，与不存在的 ID 相同。

可以用 `refund.succeeded` 或 `refund.failed` Webhook 中的 `refundId` 查询退款的当前状态。`totalRefundedCents` 和 `fullyRefunded` 反映请求时订单的状态。Webhook 中的这两个字段是事件发生时的值；同一订单之后又有退款成功时，API 返回的合计会高于之前那条 Webhook。


## OpenAPI

````yaml api-reference/openapi.json GET /v1/refunds/{id}
openapi: 3.0.3
info:
  description: >-
    Organization-scoped commerce API for merchant backends: create and manage
    checkout sessions, and query commerce records.
  title: Anyway Merchant API
  contact: {}
  version: '1.0'
  x-source: anyway-backend-go
servers:
  - url: https://merchant-api-prod.anyway.sh
security: []
paths:
  /v1/refunds/{id}:
    get:
      tags:
        - refunds
      summary: Get a refund
      description: >-
        Returns one refund by its Anyway ID (RFN_...), in the same shape as the
        refund webhooks. A refund that belongs to another organization returns
        404. totalRefundedCents and fullyRefunded describe the order as of the
        request, so they can be higher than in the webhook for this refund if a
        later refund on the order succeeded.
      parameters:
        - description: Refund ID (RFN_...)
          name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/response.ApiResponse-merchantapi_RefundResponse
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/response.ApiResponse-any'
      security:
        - APIKeyAuth: []
components:
  schemas:
    response.ApiResponse-merchantapi_RefundResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/merchantapi.RefundResponse'
        error:
          $ref: '#/components/schemas/response.ErrorDetail'
        message:
          type: string
        success:
          type: boolean
    response.ApiResponse-any:
      type: object
      properties:
        data: {}
        error:
          $ref: '#/components/schemas/response.ErrorDetail'
        message:
          type: string
        success:
          type: boolean
    merchantapi.RefundResponse:
      type: object
      properties:
        amountCents:
          description: this refund, in the order's currency
          type: integer
        createdAt:
          description: when the refund was requested
          type: string
        currency:
          description: lowercase ISO 4217
          type: string
        failedAt:
          description: 'failed: when it was rejected or declined'
          type: string
        failureReason:
          description: >-
            FailureReason (failed only) is "rejected" (declined during Anyway's
            review)

            or "declined" (declined when processed).
          type: string
        fullyRefunded:
          type: boolean
        orderId:
          type: string
        orgId:
          type: string
        reason:
          type: string
          nullable: true
        refundId:
          description: Anyway RFN_ id
          type: string
        refundedAt:
          description: 'succeeded: when the payment partner confirmed it'
          type: string
        status:
          description: '"succeeded" | "failed"; Merchant API reads also "pending"'
          type: string
        totalRefundedCents:
          description: >-
            TotalRefundedCents sums every succeeded refund on the order (this
            one

            included when it succeeded); FullyRefunded is true once it reaches
            the

            order's total paid. A webhook carries both as of its event; a
            Merchant API

            read, as of the request. They differ once a later refund on the
            order succeeds.
          type: integer
    response.ErrorDetail:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
  securitySchemes:
    APIKeyAuth:
      description: 'Merchant API key (format: ak_BASE64)'
      type: apiKey
      name: X-API-Key
      in: header

````

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