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

# Cancelar o extornar operacion ecommerce

> Cancela o extorna una transaccion generada previamente por el API de autorizacion.

Con el metodo DELETE del orquestador, las transacciones se podran cancelar o extornar segun el estado en el que se encuentran. Las transacciones en estado REGISTRADO o PENDIENTE pasan a CANCELADO para CARD cuando es por Redirect, CUOTEALO, QR, BANK_TRANSFER y PAGOEFECTIVO. Las transacciones en estado AUTORIZADO pasan a EXTORNADO para CARD y YAPE.



## OpenAPI

````yaml /openapi.json delete /charges/{merchant_code}/{merchant_operation_number}
openapi: 3.1.0
info:
  title: Alignet API
  version: 1.0.0
  description: >-
    Referencia OpenAPI para autenticacion, autorizacion, consulta, cancelacion,
    devoluciones y notificaciones de pagos ecommerce en PayIn.
servers:
  - url: https://auth.preprod.alignet.io
    description: Pre-Produccion
  - url: https://auth.alignet.io
    description: Produccion
security: []
paths:
  /charges/{merchant_code}/{merchant_operation_number}:
    delete:
      tags:
        - PayIn
      summary: Cancelar o extornar operacion ecommerce
      description: >-
        Cancela o extorna una transaccion generada previamente por el API de
        autorizacion.


        Con el metodo DELETE del orquestador, las transacciones se podran
        cancelar o extornar segun el estado en el que se encuentran. Las
        transacciones en estado REGISTRADO o PENDIENTE pasan a CANCELADO para
        CARD cuando es por Redirect, CUOTEALO, QR, BANK_TRANSFER y PAGOEFECTIVO.
        Las transacciones en estado AUTORIZADO pasan a EXTORNADO para CARD y
        YAPE.
      operationId: cancelOrReverseEcommercePayment
      parameters:
        - name: Authorization
          in: header
          required: true
          description: Token Bearer obtenido desde autenticacion.
          schema:
            type: string
            default: Bearer {{access_token}}
          example: Bearer {{access_token}}
        - name: ALG-API-VERSION
          in: header
          required: true
          description: Version del API a usar.
          schema:
            type: string
            default: '1709847567'
          example: '1709847567'
        - name: payment-facilitator-code
          in: header
          required: false
          description: Identificador del Facilitador de Pago.
          schema:
            type: string
          example: your_pf_code
        - name: merchant_code
          in: path
          required: true
          description: Identificador del comercio.
          schema:
            type: string
          example: your_merchant_code
        - name: merchant_operation_number
          in: path
          required: true
          description: Numero de operacion registrado por el comercio.
          schema:
            type: string
          example: '2391645'
      responses:
        '200':
          description: Operacion cancelada o extornada correctamente.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChargeCancelResponse'
              examples:
                cancel_success:
                  summary: Cancelacion exitosa
                  value:
                    success: true
                    merchant_code: abc
                    merchant_operation_number: '2836824'
                    operation:
                      merchant_operation_number: '2836824'
                      amount: '1000'
                      currency: '604'
                      created_at:
                        utc_time: '2024-07-05T16:46:12'
                        unix_time: 1720197972
                      state: CANCELADO
                      transactions:
                        - transaction_id: 9namjcnjvqzas2t33xyfrqr2h
                          channel: ecommerce
                          state: CANCELADO
                          state_reason: Usuario cancelo el metodo de pago
                          amount: '1000'
                          currency: '604'
                          additional_fields: null
                          payment_method:
                            method_name: PAGOEFECTIVO
                            method_details:
                              callback_url: >-
                                https://jjap9ekgee.execute-api.us-east-1.amazonaws.com/development/redirect/prueba/merchant_notification_response
                          expiration_date: null
                          processor_response: null
                          lifecycle:
                            - state: REGISTRADO
                              date:
                                utc_time: '2024-07-05T16:46:12'
                                unix_time: 1720197972
                            - state: PENDIENTE
                              date:
                                utc_time: '2024-07-05T16:46:13'
                                unix_time: 1720197973
                            - state: CANCELADO
                              date:
                                utc_time: '2024-07-05T16:47:22'
                                unix_time: 1720198042
                    meta:
                      status:
                        code: '00'
                        message_ilgn:
                          - locale: es_PE
                            value: Se proceso correctamente la peticion
                reverse_success:
                  summary: Extorno exitoso
                  value:
                    success: true
                    merchant_code: abc
                    merchant_operation_number: '8522366'
                    operation:
                      merchant_operation_number: '8522366'
                      amount: '150'
                      currency: '604'
                      created_at:
                        utc_time: '2024-07-05T20:34:18'
                        unix_time: 1720211658
                      state: EXTORNADO
                      transactions:
                        - transaction_id: 0fuwnd6miwsomisn0ikqivav9
                          channel: ecommerce
                          state: EXTORNADO
                          state_reason: Pago anulado
                          amount: '150'
                          currency: '604'
                          additional_fields: null
                          payment_method:
                            method_name: CARD
                            method_details:
                              redirect_url: null
                              callback_url: null
                              masked_pan: 545545******3401
                              brand: MASTERCARD
                              bin: '545545'
                              last_pan: '3401'
                              card_type: CIRRUS
                              card_country: PE
                              issuer: SCOTIABANK PERU S.A.A.
                          continue_url: null
                          expiration_date: null
                          risk_evaluation: null
                          authentication_result: null
                          processor_response:
                            reverse_date: 05-07-2024 20:34:19
                            reverse_code: T90261
                            brand_transaction_id: '0705203422939657'
                            result_message:
                              code: '00'
                              description: Aprobado
                          lifecycle:
                            - state: REGISTRADO
                              date:
                                utc_time: '2024-07-05T20:34:18'
                                unix_time: 1720211658
                            - state: PENDIENTE
                              date:
                                utc_time: '2024-07-05T20:34:19'
                                unix_time: 1720211659
                            - state: AUTORIZADO
                              date:
                                utc_time: '2024-07-05T20:34:24'
                                unix_time: 1720211664
                            - state: EXTORNADO
                              date:
                                utc_time: '2024-07-05T21:34:24'
                                unix_time: 1720211664
                    meta:
                      status:
                        code: '00'
                        message_ilgn:
                          - locale: es_PE
                            value: Se proceso correctamente la peticion
        '400':
          description: Request invalido.
        '401':
          description: Token invalido o expirado.
      servers:
        - url: https://api.preprod.alignet.io
          description: Pre-Produccion
        - url: https://api.alignet.io
          description: Produccion
components:
  schemas:
    ChargeCancelResponse:
      type: object
      required:
        - success
        - merchant_code
        - operation
        - meta
      properties:
        success:
          type: boolean
          example: true
        merchant_code:
          type: string
          example: your_merchant_code
        merchant_operation_number:
          type: string
          example: '2391645'
        operation:
          $ref: '#/components/schemas/ChargeQueryOperation'
        meta:
          $ref: '#/components/schemas/ChargeMeta'
    ChargeQueryOperation:
      type: object
      required:
        - merchant_operation_number
        - state
        - amount
        - currency
        - transactions
      properties:
        merchant_operation_number:
          type: string
          example: '2391645'
        created_at:
          $ref: '#/components/schemas/TransactionLifecycleDate'
        state:
          type: string
          example: AUTORIZADO
        amount:
          type: string
          example: '15000'
        currency:
          type: string
          example: '604'
        transactions:
          type: array
          items:
            $ref: '#/components/schemas/ChargeQueryTransaction'
    ChargeMeta:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/ChargeMetaStatus'
    TransactionLifecycleDate:
      type: object
      required:
        - utc_time
        - unix_time
      properties:
        utc_time:
          type: string
          example: '2024-03-12T22:49:36.018Z'
        unix_time:
          type: integer
          example: 1710282940
    ChargeQueryTransaction:
      type: object
      required:
        - transaction_id
        - channel
        - state
        - amount
        - currency
        - payment_method
        - lifecycle
      properties:
        transaction_id:
          type: string
          example: 5hk8rwa3h3cq9oyfs3a28v1ms
        channel:
          type: string
          example: ecommerce
        state:
          type: string
          example: AUTORIZADO
        state_reason:
          type: string
          example: Approval and completed successfully
        continue_url:
          type: string
          example: >-
            https://api.dev.alignet.io/payment/continue/card/81vrxn30vja1gwcfsdng4i5g5
        amount:
          type: string
          example: '15000'
        currency:
          type: string
          example: '604'
        payment_method:
          description: Metodo de pago utilizado y detalle disponible segun el flujo.
          oneOf:
            - $ref: '#/components/schemas/CardTransactionPaymentMethod'
            - $ref: '#/components/schemas/YapeTransactionPaymentMethod'
            - $ref: '#/components/schemas/BankTransferTransactionPaymentMethod'
            - $ref: '#/components/schemas/CuotealoTransactionPaymentMethod'
            - $ref: '#/components/schemas/PagoEfectivoTransactionPaymentMethod'
            - $ref: '#/components/schemas/QrTransactionPaymentMethod'
        expiration_date:
          $ref: '#/components/schemas/TransactionExpirationDate'
        processor_response:
          $ref: '#/components/schemas/ProcessorResponse'
        authentication_result:
          $ref: '#/components/schemas/TransactionAuthenticationResult'
        risk_evaluation:
          type:
            - object
            - 'null'
          example: null
        additional_fields:
          type:
            - object
            - 'null'
          example: null
        lifecycle:
          type: array
          items:
            $ref: '#/components/schemas/TransactionLifecycleEvent'
    ChargeMetaStatus:
      type: object
      properties:
        code:
          type: string
          description: >-
            Codigo del resultado tecnico del servicio o request. No valida si un
            pago fue autorizado o denegado; para eso usa el estado de la
            transaccion.
          example: '00'
        message_ilgn:
          type: array
          items:
            $ref: '#/components/schemas/ChargeStatusMessage'
    CardTransactionPaymentMethod:
      title: Tarjeta
      type: object
      required:
        - method_name
      properties:
        method_name:
          type: string
          enum:
            - CARD
          example: CARD
        method_details:
          $ref: '#/components/schemas/TransactionCardMethodDetails'
    YapeTransactionPaymentMethod:
      title: Yape
      type: object
      required:
        - method_name
      properties:
        method_name:
          type: string
          enum:
            - YAPE
          example: YAPE
        method_details:
          $ref: '#/components/schemas/TransactionYapeMethodDetails'
    BankTransferTransactionPaymentMethod:
      title: Transferencia bancaria
      type: object
      required:
        - method_name
      properties:
        method_name:
          type: string
          enum:
            - BANK_TRANSFER
          example: BANK_TRANSFER
        method_details:
          $ref: '#/components/schemas/TransactionBankTransferMethodDetails'
    CuotealoTransactionPaymentMethod:
      title: Cuotealo
      type: object
      required:
        - method_name
      properties:
        method_name:
          type: string
          enum:
            - CUOTEALO
          example: CUOTEALO
        method_details:
          $ref: '#/components/schemas/TransactionCuotealoMethodDetails'
    PagoEfectivoTransactionPaymentMethod:
      title: PagoEfectivo
      type: object
      required:
        - method_name
      properties:
        method_name:
          type: string
          enum:
            - PAGOEFECTIVO
          example: PAGOEFECTIVO
        method_details:
          $ref: '#/components/schemas/TransactionPagoEfectivoMethodDetails'
    QrTransactionPaymentMethod:
      title: QR
      type: object
      required:
        - method_name
      properties:
        method_name:
          type: string
          enum:
            - QR
          example: QR
        method_details:
          $ref: '#/components/schemas/TransactionQrMethodDetails'
    TransactionExpirationDate:
      type: object
      properties:
        utc_time:
          type: string
          example: '2024-03-12T22:49:36.018Z'
        unix_time:
          type: integer
          example: 1711585037
    ProcessorResponse:
      type:
        - object
        - 'null'
      properties:
        authorization_code:
          type: string
          example: '055552'
        brand_transaction_id:
          type: string
          example: 100B
        date:
          type: string
          example: '2024-03-26 19:17:19.599715'
        qr_image:
          type: string
          example: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
        qr_id:
          type: string
          example: 6d5d1ffc79234991b5592b825d6ec097
        cip:
          type: string
          example: '1508405'
        cip_url:
          type: string
          example: >-
            https://pre1a.payment.pagoefectivo.pe/72217FA5-4580-4B16-A345-24F028F53356.html
        origin_account:
          type: string
          example: '055552'
        request_id:
          type: string
          example: '055552'
        operation_id:
          type: string
          example: '055552'
        credit_status:
          type: string
          example: APPROVED
        payment_date:
          type: string
          example: '2024-06-24T11:01:20-05:00'
        operationNumber:
          type: string
          example: '1057462'
        reverse_date:
          type: string
          example: 05-07-2024 20:34:19
        reverse_code:
          type: string
          example: T90261
        result_message:
          $ref: '#/components/schemas/ProcessorResultMessage'
    TransactionAuthenticationResult:
      type: object
      properties:
        version:
          type: string
          example: 2.1.0
        eci:
          type: string
          example: '05'
        vci:
          type: string
          example: TSYF
        ds_transaction_id:
          type: string
          example: ABC123
        3ds_transaction_id:
          type: string
          example: ABC123
    TransactionLifecycleEvent:
      type: object
      required:
        - state
        - date
      properties:
        state:
          type: string
          example: AUTORIZADO
        date:
          $ref: '#/components/schemas/TransactionLifecycleDate'
    ChargeStatusMessage:
      type: object
      properties:
        locale:
          type: string
          example: es_PE
        value:
          type: string
          example: Procesado correctamente
    TransactionCardMethodDetails:
      type: object
      properties:
        masked_pan:
          type: string
          example: 411111********1111
        brand:
          type: string
          example: VISA
        bin:
          type: string
          example: '411111'
        last_pan:
          type: string
          example: '9268'
        card_type:
          type: string
          example: DEBIT
        card_country:
          type: string
          example: PE
        issuer:
          type: string
          example: BANCO DE CREDITO DEL PERU - BCP
        installments:
          $ref: '#/components/schemas/CardInstallmentsResponse'
        redirect_url:
          type: string
          example: https://pay-me.com
        callback_url:
          type: string
          example: https://pay-me.com/callback
    TransactionYapeMethodDetails:
      type: object
      properties:
        phone:
          $ref: '#/components/schemas/PhoneWithCountryCode'
        masked_pan:
          type: string
          example: 411111********1111
        brand:
          type: string
          example: VISA
        bin:
          type: string
          example: '411111'
        last_pan:
          type: string
          example: '9268'
        card_type:
          type: string
          example: DEBIT
        card_country:
          type: string
          example: PE
        issuer:
          type: string
          example: BANCO DE CREDITO DEL PERU - BCP
        callback_url:
          type: string
          example: https://pay-me.com/callback
    TransactionBankTransferMethodDetails:
      type: object
      required:
        - redirect_url
      properties:
        redirect_url:
          type: string
          example: https://pay-me.com
        callback_url:
          type: string
          example: https://pay-me.com/callback
    TransactionCuotealoMethodDetails:
      type: object
      required:
        - redirect_url
      properties:
        redirect_url:
          type: string
          example: https://pay-me.com
        callback_url:
          type: string
          example: https://pay-me.com/callback
    TransactionPagoEfectivoMethodDetails:
      type: object
      properties:
        callback_url:
          type: string
          example: https://pay-me.com/callback
    TransactionQrMethodDetails:
      type: object
      properties:
        masked_pan:
          type: string
          example: 411111********1111
        brand:
          type: string
          example: VISA
        bin:
          type: string
          example: '411111'
        last_pan:
          type: string
          example: '9268'
        card_type:
          type: string
          example: DEBIT
        card_country:
          type: string
          example: PE
        issuer:
          type: string
          example: BANCO DE CREDITO DEL PERU - BCP
        callback_url:
          type: string
          example: https://pay-me.com/callback
    ProcessorResultMessage:
      type: object
      properties:
        code:
          type: string
          example: '00'
        description:
          type: string
          example: Approval and completed successfully
    CardInstallmentsResponse:
      type: object
      properties:
        plan:
          type: string
          example: NORMAL
        installment_number:
          type: string
          example: '2'
    PhoneWithCountryCode:
      type: object
      required:
        - country_code
        - subscriber
      properties:
        country_code:
          type: string
          example: '+51'
        subscriber:
          type: string
          example: '999835685'

````