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

# Refund invoice

> Refund an invoice by ID. The refund is delegated to the underlying payment order. Multiple partial refunds are supported up to the invoice amount.



## OpenAPI

````yaml /api-reference/link-product-openapi.json post /invoices/{id}/refund
openapi: 3.0.0
info:
  title: Link Product API
  description: RESTful API for managing payment links, customers, and invoices
  version: 1.0.0
servers:
  - url: https://api.sandbox.cheqpay.mx/lps
    description: Sandbox environment
  - url: https://prod.cheqpay.mx/lps
    description: Production environment
security: []
tags:
  - name: Payment Links
    description: Operations related to payment links
  - name: Invoices
    description: Invoice creation and retrieval
  - name: Products
    description: Product management operations
paths:
  /invoices/{id}/refund:
    post:
      tags:
        - Invoices
      summary: Refund invoice
      description: >-
        Refund an invoice by ID. The refund is delegated to the underlying
        payment order. Multiple partial refunds are supported up to the invoice
        amount.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-f\d]{24}$
          description: Invoice ID (MongoDB ObjectId)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - amount
              properties:
                amount:
                  type: number
                  description: >-
                    Amount to refund, in major currency units (e.g. 50 = $50.00
                    MXN). Must be positive. Pass the full invoice amount for a
                    full refund.
                  example: 50
      responses:
        '200':
          description: Invoice refunded successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Invoice'
        '404':
          description: Invoice not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    Invoice:
      type: object
      description: Invoice details
      properties:
        _id:
          type: string
          description: Invoice ID
        customerId:
          type: string
          description: Customer ID
        merchantId:
          type: string
          pattern: ^[a-f\d]{24}$
          description: Merchant ID
        paymentOrderId:
          type: string
          description: Payment order ID
        paymentLinkId:
          type: string
          description: Payment link ID
        reference:
          type: string
          description: Merchant reference
        externalId:
          type: string
          description: Merchant reference
        orderNumber:
          type: string
          description: Order number
        invoiceNumber:
          type: string
          nullable: true
          description: >-
            Merchant-provided invoice number; shown to customers instead of
            orderNumber when present
        products:
          type: array
          items:
            $ref: '#/components/schemas/PaymentLinkProduct'
          description: Products in the invoice
        totals:
          type: object
          properties:
            total:
              type: number
              description: Total amount charged to the customer (subtotal + surcharge).
            subtotal:
              type: number
              description: Merchandise subtotal — the amount agreed before any surcharge.
            taxes:
              type: number
              description: Tax amount
            shipping:
              type: number
              description: Shipping amount
            fees:
              type: number
              description: Fees amount
            discounts:
              type: number
              description: Discount amount
            surcharge:
              type: number
              description: >-
                Surcharge applied on top of subtotal. Omitted when no surcharge
                applies.
            surchargeRate:
              type: number
              description: >-
                Snapshot of the merchant's surcharge rate (percent) at charge
                time. Omitted when no surcharge applies.
        billingAddress:
          $ref: '#/components/schemas/BillingAddress'
        shippingAddress:
          $ref: '#/components/schemas/Address'
        paymentMethod:
          $ref: '#/components/schemas/InvoicePaymentMethod'
        status:
          type: string
          enum:
            - pending
            - paid
            - cancelled
            - refunded
            - failed
            - abandoned
          description: Invoice status
        customFields:
          type: array
          items:
            $ref: '#/components/schemas/CustomFieldAnswer'
          description: >-
            Snapshot of the customer-submitted answers for the payment link's
            custom fields
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
    NotFoundError:
      type: object
      description: Not found error response
      properties:
        message:
          type: string
          description: Error message
          example: Resource not found
    InternalError:
      type: object
      description: Internal server error response
      properties:
        message:
          type: string
          description: Error message
          example: Internal server error
    PaymentLinkProduct:
      type: object
      description: Product in a payment link
      required:
        - name
        - qty
        - price
        - total
      properties:
        id:
          type: string
          description: Product identifier (optional for new products)
        name:
          type: string
          description: Product name
        description:
          type: string
          description: Product description
        qty:
          type: number
          minimum: 1
          description: Product quantity
        price:
          type: number
          minimum: 0
          description: Product price
        total:
          type: number
          minimum: 0
          description: Total price for this product
        imageUrl:
          type: string
          description: Product image URL
        isQtyAdjustable:
          type: boolean
          description: Whether the quantity is adjustable by the customer
        minQty:
          type: number
          description: Minimum quantity if adjustable
        maxQty:
          type: number
          description: Maximum quantity if adjustable
    BillingAddress:
      allOf:
        - $ref: '#/components/schemas/Address'
        - type: object
          properties:
            isSameAsShipping:
              type: boolean
              description: Whether billing address is same as shipping
    Address:
      type: object
      description: Address information
      properties:
        firstName:
          type: string
          description: First name
        lastName:
          type: string
          description: Last name
        organizationName:
          type: string
          description: Organization name
        email:
          type: string
          format: email
          description: Email address
        phone:
          type: string
          description: Phone number
        addressLine1:
          type: string
          description: Street address
        addressLine2:
          type: string
          description: Additional address information (apartment, suite, unit, etc.)
        city:
          type: string
          description: City
        state:
          type: string
          description: State
        postalCode:
          type: string
          description: Postal code
        country:
          type: string
          pattern: ^[A-Z]{2}$
          description: Country code (2 letters)
    InvoicePaymentMethod:
      type: object
      description: Payment method details
      properties:
        type:
          type: string
          description: Payment method type
          enum:
            - card
            - saved
            - spei
            - cie_cash_net
        card:
          type: object
          description: Card details
          properties:
            bin:
              type: string
              description: Bank identification number
            brand:
              type: string
              description: Card brand
            country:
              type: string
              description: Card country
            expiryMonth:
              type: string
              description: Expiry month
            expiryYear:
              type: string
              description: Expiry year
            issuerBank:
              type: string
              description: Issuer bank
            last4:
              type: string
              description: Last 4 digits of card
            type:
              type: string
              description: Card type
        spei:
          type: object
          description: SPEI payment details
          properties:
            clabe:
              type: string
              description: CLABE number
        cieCashNet:
          type: object
          description: CIE Cash Net payment details
          properties:
            reference:
              type: string
              description: CIE reference number for cash payment at convenience stores
              example: CIE0000000001
            convenio:
              type: string
              description: BBVA account number for same-bank payments
              example: '0123456789'
            clabe:
              type: string
              description: Interbank account number (CLABE) for transfers from other banks
              example: '012345678901234567'
    CustomFieldAnswer:
      type: object
      description: >-
        Customer-submitted answer for a payment link custom field. `value` must
        match the field's `type`: string for
        text/number/email/phone/date/radio/select, boolean for switch, string
        array for checkbox.
      required:
        - label
        - type
      properties:
        label:
          type: string
          minLength: 1
          maxLength: 255
          description: Label of the matching custom field on the payment link
        type:
          type: string
          enum:
            - text
            - number
            - email
            - phone
            - date
            - switch
            - radio
            - checkbox
            - select
          description: Field type, must match the payment link definition
        value:
          oneOf:
            - type: string
            - type: boolean
            - type: array
              items:
                type: string
          description: Customer-submitted value
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for merchant authentication

````