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

# 返金

> 完了済みの決済を返金します



## OpenAPI

````yaml /api-reference/openapi.ja.json post /v1/payments/{id}/refund
openapi: 3.1.0
info:
  title: ZAFA PAY API
  description: 複数のPSPを統合した決済APIプラットフォーム
  version: 1.0.0
servers:
  - url: https://api.sandbox.zafapay.com
    description: Sandbox環境
  - url: https://api.zafapay.com
    description: 本番環境
security:
  - bearerAuth: []
paths:
  /v1/payments/{id}/refund:
    post:
      tags:
        - Payments
      summary: 返金
      description: 完了済みの決済を返金します
      operationId: refundPayment
      parameters:
        - name: id
          in: path
          required: true
          description: トランザクションID
          schema:
            type: string
            example: tx_abc123
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RefundRequest'
      responses:
        '200':
          description: 返金成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefundResponse'
        '400':
          description: 返金エラー
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 認証エラー
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: トランザクションが見つからない
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    RefundRequest:
      type: object
      properties:
        amount:
          type: number
          description: 返金金額（小数点以下2桁まで対応）。省略時は全額返金。
          example: 5.5
        currency:
          type: string
          description: >-
            返金金額の通貨（3文字のISOコード）。決済通貨（例: usd）と異なる元通貨（例:
            sgd）で返金する場合に使用します。元の為替レートで自動変換されます。
          example: sgd
        reason:
          type: string
          description: 返金理由
          example: お客様都合
    RefundResponse:
      type: object
      properties:
        id:
          type: string
          description: 返金ID
          example: orf_xyz789
        transaction_id:
          type: string
          description: トランザクションID
          example: tx_abc123
        amount:
          type: string
          description: 返金金額（文字列形式）
          example: '5.50'
        status:
          type: string
          description: 返金ステータス
          example: succeeded
        psp_refund_id:
          type: string
          description: PSP側の返金ID
          example: re_xxxxx
        refund_fee:
          type: string
          description: 返金手数料（文字列形式）
          example: '1.00'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              description: エラーの種類
              enum:
                - authentication_error
                - authorization_error
                - invalid_request_error
                - payment_error
                - rate_limit_error
                - api_error
              example: invalid_request_error
            code:
              type: string
              description: エラーコード
              example: validation_error
            message:
              type: string
              description: エラーメッセージ
              example: Invalid request parameters
            param:
              type: string
              description: エラーの原因となったパラメータ名
              example: amount
            details:
              type: array
              description: バリデーションエラーの詳細
              items:
                type: object
                properties:
                  path:
                    type: array
                    items:
                      type: string
                  message:
                    type: string
            request_id:
              type: string
              description: リクエストID
              example: req_abc123xyz789
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: アクセストークンを使用したBearer認証

````