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

# Refund order payment

> Refund a paid order via Stripe. Supports full and partial refunds.

    Requires write access, and refunds must be enabled for your workspace and on the platform — the endpoint returns 404 while refunds are not enabled; contact support to enable them.
    The customer is refunded first; the platform fee is adjusted for the refunded amount.

    Idempotency: when `idempotencyKey` is omitted, a key is derived from the request (amount, reason, metadata) and the order's refund state at request time. That protects true retries of an identical request, but a keyless retry after a lost response can be treated as a new request (and refund twice) once the first refund has applied — always send a stable `idempotencyKey` for retries. Repeating a non-exhausting partial refund with the same `idempotencyKey` returns the original refund and makes no further changes (no duplicate refund, status change, or notification). A repeat that would now be rejected by a fresh eligibility check — a full refund, an exhausting partial, or one exceeding the currently refundable amount — returns 400 instead; retry with a smaller/different request, or contact support to confirm the original refund's status.



## OpenAPI

````yaml /api-reference/api-docs.yaml patch /v0/orders/{orderIdOrNumber}/refund
openapi: 3.1.0
info:
  title: Fungies API v0
  version: 0.3.8
servers:
  - url: https://api.fungies.io
security: []
tags:
  - name: discounts
    description: Discounts related endpoints
  - name: keys
    description: Offer product keys related endpoints
  - name: orders
    description: Orders related endpoints
  - name: payments
    description: Payments related endpoints
  - name: offers
    description: Offers related endpoints
  - name: products
    description: Products related endpoints
  - name: subscriptions
    description: Subscriptions related endpoints
  - name: tax
    description: Tax calculation related endpoints
  - name: users
    description: Users related endpoints
  - name: variants
    description: Product variants related endpoints
  - name: plans
    description: Product plans related endpoints
  - name: elements
    description: Elements related endpoints
  - name: webhooks
    description: Webhooks related endpoints
paths:
  /v0/orders/{orderIdOrNumber}/refund:
    patch:
      tags:
        - orders
      summary: Refund order payment
      description: |-
        Refund a paid order via Stripe. Supports full and partial refunds.

            Requires write access, and refunds must be enabled for your workspace and on the platform — the endpoint returns 404 while refunds are not enabled; contact support to enable them.
            The customer is refunded first; the platform fee is adjusted for the refunded amount.

            Idempotency: when `idempotencyKey` is omitted, a key is derived from the request (amount, reason, metadata) and the order's refund state at request time. That protects true retries of an identical request, but a keyless retry after a lost response can be treated as a new request (and refund twice) once the first refund has applied — always send a stable `idempotencyKey` for retries. Repeating a non-exhausting partial refund with the same `idempotencyKey` returns the original refund and makes no further changes (no duplicate refund, status change, or notification). A repeat that would now be rejected by a fresh eligibility check — a full refund, an exhausting partial, or one exceeding the currently refundable amount — returns 400 instead; retry with a smaller/different request, or contact support to confirm the original refund's status.
      operationId: PatchV0OrdersOrderIdOrNumberRefund
      parameters:
        - name: orderIdOrNumber
          in: path
          required: true
          description: PATCH /v0/orders/:orderIdOrNumber/refund Parameter
          schema:
            $ref: >-
              #/components/schemas/PatchV0OrdersOrderIdOrNumberRefundParameterOrderIdOrNumber
      requestBody:
        description: PATCH /v0/orders/:orderIdOrNumber/refund Request body
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/PatchV0OrdersOrderIdOrNumberRefundRequestBody
      responses:
        '200':
          description: PATCH /v0/orders/:orderIdOrNumber/refund Positive response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PatchV0OrdersOrderIdOrNumberRefundPositiveResponse
        '400':
          description: PATCH /v0/orders/:orderIdOrNumber/refund Negative response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PatchV0OrdersOrderIdOrNumberRefundNegativeResponse
              examples:
                example1:
                  value:
                    status: error
                    error:
                      message: Sample error message
      security:
        - APIKEY_1: []
          APIKEY_2: []
components:
  schemas:
    PatchV0OrdersOrderIdOrNumberRefundParameterOrderIdOrNumber:
      oneOf:
        - type: string
          format: uuid
        - type: string
          pattern: ^#?([0-9A-Za-z]{12,32}|[0-9]+)(-[0-9]+)?$
    PatchV0OrdersOrderIdOrNumberRefundRequestBody:
      type: object
      properties:
        amount:
          type: integer
          format: int64
          exclusiveMinimum: 0
          maximum: 9007199254740991
        reason:
          type: string
          enum:
            - duplicate
            - fraudulent
            - requested_by_customer
        metadata:
          type: object
          additionalProperties:
            type: string
        idempotencyKey:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            Optional caller-supplied Stripe idempotency key. Prefer this when
            retrying after a lost response — a keyless retry of a partial refund
            can double-refund once amount_refunded has changed.
      required: []
    PatchV0OrdersOrderIdOrNumberRefundPositiveResponse:
      type: object
      properties:
        status:
          type: string
          const: success
        data:
          type: object
          properties:
            refundId:
              type: string
            orderId:
              type: string
              format: uuid
            amount:
              type: integer
              format: int64
              exclusiveMinimum: 0
              maximum: 9007199254740991
            currency:
              type: string
              enum:
                - AFN
                - ALL
                - DZD
                - AOA
                - ARS
                - AMD
                - AWG
                - AUD
                - AZN
                - BSD
                - BDT
                - BBD
                - BZD
                - BMD
                - BOB
                - BAM
                - BWP
                - BRL
                - BHD
                - GBP
                - BND
                - BGN
                - BIF
                - BYN
                - KHR
                - CAD
                - CVE
                - KYD
                - KWD
                - XAF
                - XPF
                - CLP
                - CNY
                - COP
                - KMF
                - CDF
                - CRC
                - HRK
                - CZK
                - DKK
                - DJF
                - DOP
                - XCD
                - EGP
                - ETB
                - EUR
                - FKP
                - FJD
                - GMD
                - GEL
                - GIP
                - GTQ
                - GNF
                - GYD
                - HTG
                - HNL
                - HKD
                - HUF
                - ISK
                - INR
                - IDR
                - ILS
                - JMD
                - JPY
                - JOD
                - KZT
                - KES
                - KGS
                - LAK
                - LBP
                - LSL
                - LRD
                - MOP
                - MKD
                - MGA
                - MWK
                - MYR
                - MVR
                - MRO
                - MUR
                - MXN
                - MDL
                - MNT
                - MAD
                - MZN
                - MMK
                - NAD
                - NPR
                - ANG
                - TWD
                - NZD
                - NIO
                - NGN
                - NOK
                - OMR
                - PKR
                - PAB
                - PGK
                - PYG
                - PEN
                - PHP
                - PLN
                - QAR
                - RON
                - RUB
                - RWF
                - SHP
                - SVC
                - WST
                - STD
                - SAR
                - RSD
                - SCR
                - SLL
                - SGD
                - SBD
                - SOS
                - ZAR
                - KRW
                - LKR
                - SRD
                - SZL
                - SEK
                - CHF
                - TJS
                - TZS
                - THB
                - TND
                - TOP
                - TTD
                - TRY
                - UGX
                - UAH
                - AED
                - UYU
                - USD
                - UZS
                - VUV
                - VEF
                - VND
                - XOF
                - YER
                - ZMW
                - SLE
                - XCG
                - SSP
                - VES
                - MRU
                - STN
                - VED
            status:
              type: string
              enum:
                - succeeded
                - pending
            createdAt:
              type: string
          required:
            - refundId
            - orderId
            - amount
            - currency
            - status
            - createdAt
      required:
        - status
        - data
    PatchV0OrdersOrderIdOrNumberRefundNegativeResponse:
      type: object
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          properties:
            message:
              type: string
          required:
            - message
      required:
        - status
        - error
  securitySchemes:
    APIKEY_1:
      type: apiKey
      in: header
      name: x-fngs-public-key
    APIKEY_2:
      type: apiKey
      in: header
      name: x-fngs-secret-key

````