# Create a refund

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/refunds:
    post:
      summary: Create a refund
      deprecated: false
      description: >-
        When you create a new refund, you must specify a PaymentIntent object on
        which to create it. Creating a new refund will refund a charge that has
        previously been created but not yet refunded. Funds will be refunded to
        the credit or debit card that was originally charged. You can optionally
        refund only part of a charge. You can do so multiple times, until the
        entire charge has been refunded.


        Once entirely refunded, a charge can’t be refunded again. This method
        will return an error when called on an already-refunded charge, or when
        trying to refund more money than is left on a charge.
      tags:
        - API Reference/Refunds
      parameters:
        - name: Accept
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                amount:
                  type: string
                  description: >-
                    A positive integer in cents  representing how much of this
                    charge to refund. Can refund only up to the remaining,
                    unrefunded amount of the charge.
                metadata:
                  type: object
                  properties: {}
                  description: >-
                    A set of key-value pairs that you can attach to a Refund 
                    object. This can be useful for storing additional
                    information about the refund in a structured format. You can
                    unset individual keys if you POST an empty value for that
                    key. You can clear all keys if you POST an empty value for
                    metadata
                  x-apifox-orders: []
                  x-apifox-ignore-properties: []
                payment_intent:
                  type: string
                  description: ID of the PaymentIntent to refund.
                reason:
                  type: string
                  description: >-
                    String indicating the reason for the refund. If set,
                    possible values are duplicate , fraudulent , and
                    requested_by_customer.
                  enum:
                    - duplicate
                    - fraudulent
                    - requested_by_customer
                    - resolved_dispute
                  x-apifox-enum:
                    - value: duplicate
                      name: ''
                      description: ''
                    - value: fraudulent
                      name: ''
                      description: ''
                    - value: requested_by_customer
                      name: ''
                      description: ''
                    - value: resolved_dispute
                      name: ''
                      description: ''
              x-apifox-orders:
                - amount
                - metadata
                - payment_intent
                - reason
              required:
                - payment_intent
              x-apifox-ignore-properties: []
            example:
              reason: requested_by_customer
              payment_intent: pi_1787730829493927936
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                x-apifox-refs:
                  01GMQ223G7FM7ANDVV3A1QVPN5:
                    $ref: '#/components/schemas/Refund'
                    x-apifox-overrides:
                      balance_transaction: null
                      receipt_number: null
                      source_transfer_reversal: null
                      transfer_reversal: null
                      charge: null
                x-apifox-orders:
                  - 01GMQ223G7FM7ANDVV3A1QVPN5
                properties:
                  id:
                    type: string
                    description: Unique identifier for the object, like 're_xxxx'.
                  object:
                    type: string
                    description: '''refund'''
                  amount:
                    type: integer
                    description: Amount, in cents.
                  created:
                    type: integer
                    description: >-
                      Time at which the object was created. Measured in seconds
                      since the Unix epoch.
                  currency:
                    type: string
                    description: >-
                      Three-letter ISO currency code, in lowercase. Must be a
                      supported currency.
                  metadata:
                    type: object
                    properties: {}
                    x-apifox-orders: []
                    description: Set of key-value pairs that you can attach to an object.
                    x-apifox-ignore-properties: []
                  payment_intent:
                    type: string
                    description: ID of the PaymentIntent that was refunded.
                  reason:
                    type: string
                    description: >-
                      Reason for the refund, either user-provided (duplicate,
                      fraudulent, or requested_by_customer)
                    enum:
                      - duplicate
                      - fraudulent
                      - requested_by_customer
                      - expired_uncaptured_charge
                      - resolved_dispute
                    x-apifox-enum:
                      - value: duplicate
                        name: ''
                        description: ''
                      - value: fraudulent
                        name: ''
                        description: ''
                      - value: requested_by_customer
                        name: ''
                        description: ''
                      - value: expired_uncaptured_charge
                        name: ''
                        description: ''
                      - value: resolved_dispute
                        name: ''
                        description: ''
                  status:
                    type: string
                    description: >-
                      Status of the refund. For credit card refunds, this can be
                      pending, succeeded, or failed. For other types of refunds,
                      it can be pending, succeeded, failed, or canceled.
                  description:
                    type: string
                    description: >-
                      An arbitrary string attached to the object. Often useful
                      for displaying to users.
                  failure_reason:
                    type: string
                    description: >-
                      If the refund failed, the reason for refund failure if
                      known. Possible values are lost_or_stolen_card,
                      expired_or_canceled_card, or unknown.
                    enum:
                      - lost_or_stolen_card
                      - expired_or_canceled_card
                      - unknown
                    x-apifox-enum:
                      - value: lost_or_stolen_card
                        name: ''
                        description: ''
                      - value: expired_or_canceled_card
                        name: ''
                        description: ''
                      - value: unknown
                        name: ''
                        description: ''
                x-apifox-ignore-properties:
                  - id
                  - object
                  - amount
                  - created
                  - currency
                  - metadata
                  - payment_intent
                  - reason
                  - status
                  - description
                  - failure_reason
          headers: {}
          x-apifox-name: OK
      security:
        - basic: []
      x-apifox-folder: API Reference/Refunds
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/1296482/apis/api-51369554-run
components:
  schemas:
    Refund:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the object, like 're_xxxx'.
        object:
          type: string
          description: '''refund'''
        amount:
          type: integer
          description: Amount, in cents.
        charge:
          type: string
          description: ID of the charge that was refunded.
        created:
          type: integer
          description: >-
            Time at which the object was created. Measured in seconds since the
            Unix epoch.
        currency:
          type: string
          description: >-
            Three-letter ISO currency code, in lowercase. Must be a supported
            currency.
        metadata:
          type: object
          properties: {}
          x-apifox-orders: []
          description: Set of key-value pairs that you can attach to an object.
          x-apifox-ignore-properties: []
        payment_intent:
          type: string
          description: ID of the PaymentIntent that was refunded.
        reason:
          type: string
          description: >-
            Reason for the refund, either user-provided (duplicate, fraudulent,
            or requested_by_customer)
          enum:
            - duplicate
            - fraudulent
            - requested_by_customer
            - expired_uncaptured_charge
            - resolved_dispute
          x-apifox-enum:
            - value: duplicate
              name: ''
              description: ''
            - value: fraudulent
              name: ''
              description: ''
            - value: requested_by_customer
              name: ''
              description: ''
            - value: expired_uncaptured_charge
              name: ''
              description: ''
            - value: resolved_dispute
              name: ''
              description: ''
        status:
          type: string
          description: >-
            Status of the refund. For credit card refunds, this can be pending,
            succeeded, or failed. For other types of refunds, it can be pending,
            succeeded, failed, or canceled.
        description:
          type: string
          description: >-
            An arbitrary string attached to the object. Often useful for
            displaying to users.
        failure_reason:
          type: string
          description: >-
            If the refund failed, the reason for refund failure if known.
            Possible values are lost_or_stolen_card, expired_or_canceled_card,
            or unknown.
          enum:
            - lost_or_stolen_card
            - expired_or_canceled_card
            - unknown
          x-apifox-enum:
            - value: lost_or_stolen_card
              name: ''
              description: ''
            - value: expired_or_canceled_card
              name: ''
              description: ''
            - value: unknown
              name: ''
              description: ''
        transfer_reversal:
          type: string
          description: （未实现）
        source_transfer_reversal:
          type: string
          description: （未实现）
        receipt_number:
          type: string
          description: （未实现）
        balance_transaction:
          type: string
          description: （未实现）
      x-apifox-orders:
        - id
        - object
        - amount
        - charge
        - created
        - currency
        - metadata
        - payment_intent
        - reason
        - status
        - description
        - failure_reason
        - transfer_reversal
        - source_transfer_reversal
        - receipt_number
        - balance_transaction
      x-apifox-ignore-properties: []
      x-apifox-folder: ''
  securitySchemes:
    basic:
      type: http
      scheme: basic
servers:
  - url: https://apitest.wooshpay.com
    description: 官网测试
security:
  - basic: []

```
