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

# Get Refund Context

> Get the data needed to build a refund for a payment (eligible items, packages, and amounts).



## OpenAPI

````yaml get /billing/payment/{payment_id}/refund-context
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /billing/payment/{payment_id}/refund-context:
    get:
      tags:
        - Payments
      summary: Get Refund Context
      description: >-
        Get the data needed to build a refund for a payment (eligible items,
        packages, and amounts).
      operationId: get_refund_context_billing_payment__payment_id__refund_context_get
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
        - name: payment_id
          in: path
          required: true
          schema:
            type: string
            title: Payment Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RefundContext'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    RefundContext:
      properties:
        paymentId:
          type: string
          title: Paymentid
        paymentAmount:
          type: integer
          title: Paymentamount
        feeToPatient:
          type: integer
          title: Feetopatient
        refundableAmount:
          type: integer
          title: Refundableamount
        status:
          $ref: '#/components/schemas/PaymentStatus'
        paymentMedium:
          type: string
          title: Paymentmedium
        charges:
          items:
            $ref: '#/components/schemas/RefundableCharge'
          type: array
          title: Charges
      type: object
      required:
        - paymentId
        - paymentAmount
        - feeToPatient
        - refundableAmount
        - status
        - paymentMedium
      title: RefundContext
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PaymentStatus:
      type: string
      enum:
        - CANCELED
        - CREATED
        - FAILED
        - IN_REVIEW
        - PRESENTING
        - PROCESSING
        - SUCCEEDED
      title: PaymentStatus
      description: >-
        Status of a Payment or Refund.


        NOTE for any "cash collected / refunded" or settlement-style query:

        both ``SUCCEEDED`` AND ``PROCESSING`` count as money committed.
        ``SUCCEEDED``

        means cleared in the bank account; ``PROCESSING`` means the transaction
        is

        in flight (e.g. ACH still settling) but the clinic should expect it.
        Most

        accounting / analytics aggregates that filter only on ``status ==
        SUCCEEDED``

        silently undercount real cash flow — use ``status IN (SUCCEEDED,
        PROCESSING)``

        unless you specifically want only fully-cleared funds.


        Use ``COMMITTED_PAYMENT_STATUSES`` below for the common case.
    RefundableCharge:
      properties:
        chargeId:
          type: string
          title: Chargeid
        chargePaymentAmount:
          type: integer
          title: Chargepaymentamount
        remainingChargePaymentCapacity:
          type: integer
          title: Remainingchargepaymentcapacity
        items:
          items:
            $ref: '#/components/schemas/RefundableItem'
          type: array
          title: Items
      type: object
      required:
        - chargeId
        - chargePaymentAmount
        - remainingChargePaymentCapacity
      title: RefundableCharge
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    RefundableItem:
      properties:
        chargeItemId:
          type: string
          title: Chargeitemid
        chargeId:
          type: string
          title: Chargeid
        itemName:
          type: string
          title: Itemname
        unitPrice:
          type: integer
          title: Unitprice
        originalQuantity:
          type: integer
          title: Originalquantity
        refundableQuantity:
          type: integer
          title: Refundablequantity
        originalAmount:
          type: integer
          title: Originalamount
        refundableAmount:
          type: integer
          title: Refundableamount
        maxAmountFromPayment:
          type: integer
          title: Maxamountfrompayment
        pricingModes:
          items:
            $ref: '#/components/schemas/RefundItemPricingMode'
          type: array
          title: Pricingmodes
        units:
          items:
            $ref: '#/components/schemas/RefundableUnit'
          type: array
          title: Units
        blockers:
          items:
            type: string
          type: array
          title: Blockers
      type: object
      required:
        - chargeItemId
        - chargeId
        - itemName
        - unitPrice
        - originalQuantity
        - refundableQuantity
        - originalAmount
        - refundableAmount
        - maxAmountFromPayment
      title: RefundableItem
    RefundItemPricingMode:
      type: string
      enum:
        - QUANTITY
        - PACKAGE_REMAINING_VALUE
      title: RefundItemPricingMode
      description: How the backend derives one RefundItem's authoritative value.
    RefundableUnit:
      properties:
        soldPackageId:
          anyOf:
            - type: string
            - type: 'null'
          title: Soldpackageid
        issuedGiftCardId:
          anyOf:
            - type: string
            - type: 'null'
          title: Issuedgiftcardid
        label:
          type: string
          title: Label
        refundableAmount:
          type: integer
          title: Refundableamount
        requiredAction:
          $ref: '#/components/schemas/RefundItemAction'
      type: object
      required:
        - label
        - refundableAmount
        - requiredAction
      title: RefundableUnit
      description: A single exact package or gift-card unit refundable on a line.
    RefundItemAction:
      type: string
      enum:
        - RESTORE_INVENTORY
        - RESTORE_MEMBER_DISCOUNT
        - RESTORE_SAVED_ITEM
        - CANCEL_PACKAGE
        - RESTORE_PACKAGE_SESSION
        - REVERSE_MEMBERSHIP
        - DISABLE_GIFT_CARD
        - REVOKE_LOYALTY
        - REVOKE_BANKED_VALUE
      title: RefundItemAction
      description: >-
        Operational side effects a refunded item may reverse, selected per
        RefundItem.


        Stored as an ``ARRAY(TypedEnum(RefundItemAction))`` on
        ``refund_item.reversal_actions``.

        An empty array means the item refunds money only, with no operational
        reversal.

        Each value is applied by the reconciler after the refund's money
        movement succeeds,

        and every application writes an idempotent marker keyed by
        ``refund_item_id``.

````