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

# Rimborsare un payin

Questo endpoint ti permette di rimborsare integralmente una transazione Payin autorizzata in precedenza.

**Requisiti per il rimborso**:

* L'importo del rimborso deve corrispondere all'importo del Payin originale.
* Il rimborso deve essere inviato allo stesso beneficiario e allo stesso conto usati per il Payin originale.


## OpenAPI

````yaml openapi/it/localpayment.json PATCH /api/payin/{externalId}/refund
openapi: 3.1.0
info:
  version: '1.0'
  title: Localpayment
  contact:
    name: Support
    url: mailto:support@localpayment.com
servers:
  - url: https://api.stage.localpayment.com
    description: Stage
security:
  - token: []
paths:
  /api/payin/{externalId}/refund:
    patch:
      summary: Rimborsare un payin
      operationId: refund-a-payin
      parameters:
        - name: Authorization
          in: header
          description: >-
            Token di accesso Bearer per l'autenticazione. Questo token si
            ottiene dagli endpoint [Ottenere il token di
            accesso](/it/reference/get-token) o [Rinnovare il token di
            accesso](/it/reference/refresh-token).
          required: true
          schema:
            type: string
        - name: externalId
          in: path
          description: >-
            ID generato dal tuo lato per la tracciabilità della transazione.
            Deve essere univoco e accetta solo caratteri alfanumerici e trattini
            (ad esempio UUID4).
          required: true
          schema:
            type: string
            pattern: '[a-zA-Z0-9\- ]+'
            examples:
              - 53025bf4-4c87-4b4f-8fea-b47004440f37
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                externalId:
                  type: string
                  description: >-
                    Identificatore univoco generato dal tuo sistema per
                    tracciare la transazione (caratteri alfanumerici e
                    trattini). Consigliamo di usare UUID4 per garantirne
                    l'univocità. **Obbligatorio solo per Pix (Brasile) e per i
                    rimborsi in contanti.**
                beneficiary:
                  type: object
                  description: >-
                    Oggetto contenente i dettagli sul beneficiario del
                    rimborso.  **Obbligatorio solo per Pix (Brasile) e per i
                    rimborsi in contanti.**
                  properties:
                    type:
                      type: string
                      enum:
                        - COMPANY
                        - INDIVIDUAL
                      description: Tipo di beneficiario (ad es. `INDIVIDUAL`, `COMPANY`).
                    name:
                      type: string
                      description: >-
                        Nome del beneficiario. I caratteri consentiti dipendono
                        dal campo `type`: per `individual`, lettere (inclusi i
                        caratteri accentati), spazi e punti (`.`); per
                        `company`, lo stesso insieme più cifre, trattino basso
                        (`_`) e trattino (`-`).
                      minLength: 2
                      maxLength: 255
                    lastname:
                      type: string
                      description: >-
                        Cognome del beneficiario. Obbligatorio quando `type` è
                        `individual` e ignorato quando `type` è `company`. I
                        caratteri consentiti dipendono da `type`: per
                        `individual`, lettere (inclusi i caratteri accentati),
                        spazi e punti (`.`); per `company`, lo stesso insieme
                        più cifre, trattino basso (`_`) e trattino (`-`).
                      minLength: 2
                      maxLength: 255
                    document:
                      type: object
                      properties:
                        type:
                          type: string
                          description: >-
                            Il [tipo di documento
                            d'identità](/it/reference/identity-document-types),
                            ad esempio un numero di identità nazionale, un
                            numero di previdenza sociale o una patente di guida,
                            a seconda del paese di emissione.
                        id:
                          type: string
                          description: >-
                            Numero del documento d'identità (di solito un
                            numero). Deve essere un numero valido secondo le
                            regole del tipo di documento specifico.
                    bank:
                      type: object
                      description: Dati bancari del beneficiario.
                      properties:
                        name:
                          type: string
                          description: Nome della banca.
                        code:
                          type: string
                          description: 'Codice della banca. '
                        account:
                          type: object
                          description: 'Dettagli del conto bancario del beneficiario. '
                          properties:
                            type:
                              type: string
                              description: 'Tipo di conto bancario (ad es. `C`, `S`). '
                            number:
                              type: string
                              description: Numero di conto bancario.
                          required:
                            - type
                            - number
                        branch:
                          type: object
                          description: '**Solo Brasile.** '
                          properties:
                            code:
                              type: string
                              description: Codice della filiale (da 1 a 5 cifre).
                            name:
                              type: string
                              description: 'Nome della filiale. '
                      required:
                        - name
                        - code
                        - account
                  required:
                    - type
                    - name
                    - bank
                comment:
                  type: string
                  description: >-
                    Commento o nota che fornisce informazioni aggiuntive sulla
                    transazione di rimborso.
              required:
                - externalId
                - beneficiary
              x-examples:
                Example 1:
                  comment: Refund API VA
                  beneficiary:
                    type: Type
                    name: Name
                    lastname: LastName
                    document:
                      type: DocumentType
                      id: DocumentId
                    bank:
                      name: BankName
                      code: Code
                      account:
                        type: BankAccountType
                        number: AccountNumber
            examples:
              Pix (Brazil) Refund:
                value:
                  comment: Pix refund
                  beneficiary:
                    type: INDIVIDUAL
                    name: John
                    lastname: Doe
                    document:
                      type: DocumentType
                      id: DocumentId
                    bank:
                      name: BankName
                      code: Code
                      account:
                        type: BankAccountType
                        number: AccountNumber
              902 - The payin was refunded:
                value:
                  externalId: e9407459-1ecc-4e18-800b-4bbae006afe2
                  internalId: 3e90d58c-8d3a-4c75-916e-a6d0add4f3b3
                  status:
                    code: '902'
                    description: REFUNDED
                    detail: The payin was refunded
              Cash refund:
                value:
                  comment: Cash refund
                  beneficiary:
                    type: INDIVIDUAL
                    name: John
                    lastname: Doe
                    document:
                      type: DocumentType
                      id: DocumentId
                    bank:
                      name: BankName
                      code: Code
                      account:
                        type: BankAccountType
                        number: AccountNumber
              Capture refund:
                value:
                  comment: Credit Card refund
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  externalId:
                    type: string
                    description: >-
                      Identificatore univoco generato dal tuo sistema per
                      tracciare la transazione (caratteri alfanumerici e
                      trattini). Consigliamo di usare UUID4 per garantirne
                      l'univocità.
                  internalId:
                    type: string
                    description: Identificatore della transazione Localpayment.
                  status:
                    type: object
                    title: status
                    description: Stato dell'operazione.
                    properties:
                      code:
                        type: string
                        description: >-
                          [Codice di
                          stato](/it/reference/transaction-status-error-codes).
                        examples:
                          - '902'
                      description:
                        type: string
                        description: >-
                          [Descrizione dello
                          stato](/it/reference/transaction-status-error-codes).
                        examples:
                          - REFUNDED
                      detail:
                        type: string
                        description: Informazioni aggiuntive sullo stato.
                        examples:
                          - The payin was refunded
                x-examples:
                  Example 1:
                    externalId: '{{ExternalId}}'
                    internalId: '{{InternalId}}'
                    status:
                      code: '902'
                      description: REFUNDED
                      detail: The payin was refunded
              examples:
                902 - The payin was refunded.:
                  value:
                    externalId: e36ef929-c2d4-fcf0-b30c-99dc51798f4b
                    internalId: c09095fb-6a0e-47af-9f43-3d9452b0f290
                    status:
                      code: '902'
                      description: REFUNDED
                      detail: The payin was refunded
        '400':
          description: Richiesta non valida
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    description: Stato dell'operazione.
                    properties:
                      code:
                        type: string
                        description: >-
                          [Codice di
                          stato](/it/reference/transaction-status-error-codes).
                      description:
                        type: string
                        description: Descrizione dello stato.
                      detail:
                        type: string
                        description: Informazioni aggiuntive sullo stato.
                x-examples:
                  Example 1:
                    status:
                      code: '400'
                      description: ERROR
                      detail: Invalid operation
              examples:
                400 - Invalid operation:
                  value:
                    status:
                      code: '400'
                      description: ERROR
                      detail: Invalid operation
        '401':
          description: Non autorizzato.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: Informazioni aggiuntive della risposta.
                  code:
                    type: string
                    description: Codice di stato.
                  messages:
                    type: array
                    description: Elenco dei messaggi.
                    items:
                      type: object
                      properties:
                        token_class:
                          type: string
                          description: Classe del token.
                        token_type:
                          type: string
                          description: Tipo di token.
                        message:
                          type: string
                          description: Messaggio con informazioni aggiuntive.
                x-examples:
                  Example 1:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
              examples:
                401 - Token is invalid or expired:
                  value:
                    detail: Given token not valid for any token type
                    code: token_not_valid
                    messages:
                      - token_class: AccessToken
                        token_type: access
                        message: Token is invalid or expired
        '404':
          description: Non trovato
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    title: status
                    description: Stato dell'operazione.
                    properties:
                      code:
                        type: string
                        description: >-
                          [Codice di
                          stato](/it/reference/transaction-status-error-codes).
                      description:
                        type: string
                        description: Descrizione dello stato.
                      detail:
                        type: string
                        description: Informazioni aggiuntive sullo stato.
                x-examples:
                  Example 1:
                    status:
                      code: '404'
                      description: ERROR
                      detail: Payin not found
              examples:
                404 - Payin not found.:
                  value:
                    status:
                      code: '404'
                      description: ERROR
                      detail: Payin not found
      security:
        - token: []
      servers:
        - url: https://api.stage.localpayment.com
          description: Stage
components:
  securitySchemes:
    token:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.