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

# Reverse an Intent Refund

> Declare the reversal of a refund processed by a third-party PSP

This endpoint allows you to reverse an Intent Refund in full or in part if the refund processed by the third-party PSP was not successful and the funds were returned to the platform.

This endpoint effectively changes the Intent Refund `Status` to `REFUND_REVERSED` and re-calculates the `RefundedAmount` of the `LineItem`.

You can only reverse the same amount that was refunded.

### Path parameters

<ParamField path="IntentId" type="string" required>
  The unique identifier of the Intent.
</ParamField>

### Body parameters

<Tabs>
  <Tab title="Full reversal">
    If the Intent Refund was for the full amount of the Intent, then you only need to send the `ExternalData`.

    <ParamField body="ExternalData" type="object" required>
      Information about the refund processed by the third-party PSP.

      <Expandable>
        <ParamField body="ExternalProcessingDate" type="Unix timestamp" required>
          The date at which the capture was created.
        </ParamField>

        <ParamField body="ExternalProviderReference" type="string" required>
          The unique identifier of the capture at the provider level.
        </ParamField>

        <ParamField body="ExternalMerchantReference" type="string">
          The unique identifier of the capture at the merchant level.
        </ParamField>

        <ParamField body="ExternalProviderName" type="string" required>
          The [supported third-party PSP](/api-reference/echo/supported-providers) processing the transaction.

          **Note:** The uppercase value is expected. The API returns the sentence-case value.
        </ParamField>

        <ParamField body="ExternalProviderPaymentMethod" type="string">
          One of the [supported payment methods](/api-reference/echo/supported-payment-methods) used to process the capture.
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Partial reversal">
    If the Intent Refund was for part of the Intent in one or more `LineItems.Amount` values, then you need to send the `Amount` and `LineItems` in the call. The `LineItems.Amount` and total `Amount` must match and be the same as the initial refund.

    <ParamField body="Amount" type="integer" required>
      The amount of the Refund, required for a partial refund. The Refund `Amount` must equal the sum of the `Amount` values refunded for all line items.
    </ParamField>

    <ParamField body="Currency" type="integer">
      The currency of the intent.
    </ParamField>

    <ParamField body="PlatformFees" type="integer">
      The amount of fees to be diverted to the platform's Fees Wallet when the Intent is split. This value can be overridden when the Split is created.

      The `PlatformFees` value must the sum of all line item `Seller.FeesAmount` values.
    </ParamField>

    <ParamField body="ExternalData" type="object" required>
      Information about the refund processed by the third-party PSP.

      <Expandable>
        <ParamField body="ExternalProcessingDate" type="Unix timestamp" required>
          The date at which the capture was created.
        </ParamField>

        <ParamField body="ExternalProviderReference" type="string" required>
          The unique identifier of the capture at the provider level.
        </ParamField>

        <ParamField body="ExternalMerchantReference" type="string">
          The unique identifier of the capture at the merchant level.
        </ParamField>

        <ParamField body="ExternalProviderName" type="string" required>
          The [supported third-party PSP](/api-reference/echo/supported-providers) processing the transaction.

          **Note:** The uppercase value is expected. The API returns the sentence-case value.
        </ParamField>

        <ParamField body="ExternalProviderPaymentMethod" type="string">
          One of the [supported payment methods](/api-reference/echo/supported-payment-methods) used to process the capture.
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="LineItems" type="array (object)" required>
      Information about the amount refunded for each line item, required for a partial refund.

      <Expandable defaultOpen>
        <ParamField body="Id" type="string" required>
          The unique identifier of the line item in Mangopay ecosystem.
        </ParamField>

        <ParamField body="Amount" type="integer" required>
          The amount of the refund. The sum of the Refund's `LineItems.Amount` values must equal the `Amount` of the Refund.
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>
</Tabs>

### Responses

<AccordionGroup>
  <Accordion title="200 - Response parameters">
    <ResponseField name="Id" type="string">
      The unique identifier of the intent.
    </ResponseField>

    <ResponseField name="Amount" type="integer">
      The full amount authorized in the Intent, which must equal the sum of the total amounts of all `LineItems`.
    </ResponseField>

    <ResponseField name="AvailableAmountToSplit" type="integer">
      The remaining amount of the Intent that can be split and transferred to the sellers' wallets.
    </ResponseField>

    <ResponseField name="UnfundedAmount" type="integer">
      The amount needing to be settled to the Platform's escrow wallet before the Intent Splits can be executed.
    </ResponseField>

    <ResponseField name="Currency" type="integer">
      The currency of the intent.
    </ResponseField>

    <ResponseField name="PlatformFees" type="integer">
      The amount of fees to be diverted to the platform's Fees Wallet when the Intent is split. This value can be overridden when the Split is created.

      The `PlatformFees` value must the sum of all line item `Seller.FeesAmount` values.
    </ResponseField>

    <ResponseField name="Status" type="string">
      The status of the Intent, as declared by the platform through Intent Captures, Refunds (and reversals), or Disputes (and decisions). Where partial actions occur, the top-level Intent `Status` may differ from the `Status` of Intent `LineItems`.

      Intent `Status` values:

      * `AUTHORIZED` – The Intent `Amount` was authorized for acquisition by the PSP and can be captured or canceled.
      * `PARTIALLY_CAPTURED` – Part of the Intent `Amount` from one or more `LineItems` was captured. The other parts are either still available for capture or cancel.
      * `CAPTURED` – All of the Intent `Amount` was captured. Part of it may have been subsequently refunded or disputed.
      * `CANCELLED` – All of the Intent `Amount` was canceled.
      * `REFUNDED` – All of the `CapturedAmount` of all `LineItems` was refunded.
      * `REFUND_REVERSED` – The refund could not be completed and the funds were returned to the platform.
      * `DISPUTED` – All of the `CapturedAmount` of all `LineItems` was disputed.
      * `DEFENDED` – The dispute is being defended by the platform.
      * `DISPUTED_WON` – The dispute was resolved in favor of the platform.
      * `DISPUTED_LOST` – The dispute was resolved against the platform.
    </ResponseField>

    <ResponseField name="NextActions" type="string">
      The possible next actions on the intent.
    </ResponseField>

    <ResponseField name="ExternalData" type="object">
      Information about the refund processed by the third-party PSP.

      <Expandable>
        <ResponseField name="ExternalProcessingDate" type="Unix timestamp">
          The date at which the refund was created.
        </ResponseField>

        <ResponseField name="ExternalProviderReference" type="string">
          The unique identifier of the refund at the provider level.
        </ResponseField>

        <ResponseField name="ExternalMerchantReference" type="string">
          The unique identifier of the refund at the merchant level.
        </ResponseField>

        <ResponseField name="ExternalProviderName" type="string">
          The [supported third-party PSP](/api-reference/echo/supported-providers) processing the transaction.

          **Note:** The uppercase value is expected. The API returns the sentence-case value.
        </ResponseField>

        <ResponseField name="ExternalProviderPaymentMethod" type="string">
          One of the [supported payment methods](/api-reference/echo/supported-payment-methods) used to process the refund.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="Buyer" type="object">
      Information about the buyer.

      <Expandable>
        <ResponseField name="Id" type="string">
          If it exists, the unique identifier of the Mangopay user making the payment via the third-party PSP. Must be a valid Mangopay `UserId`.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="LineItems" type="array (object)">
      Information about the line items included in the intent action.

      <Expandable>
        <ResponseField name="Id" type="string">
          The unique identifier of the line item in Mangopay's ecosystem.
        </ResponseField>

        <ResponseField name="TotalLineItemAmount" type="integer">
          The total amount of the line item calculated as ((`UnitAmount` x `Quantity`) - `DiscountAmount`).
        </ResponseField>

        <ResponseField name="CapturedAmount" type="integer">
          The item total `CAPTURED` amount
        </ResponseField>

        <ResponseField name="RefundedAmount" type="integer">
          The item total `REFUNDED` amount
        </ResponseField>

        <ResponseField name="DisputedAmount" type="integer">
          The item total `DISPUTED` amount.
        </ResponseField>

        <ResponseField name="SplitAmount" type="integer">
          The item total `COMPLETED` amount.
        </ResponseField>

        <ResponseField name="UnfundedSellerAmount" type="integer">
          The amount needing to be settled to the Platform's escrow wallet before the Intent Splits can be executed for this seller.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="CreationDate" type="string">
      The date and time at which the Intent was created.
    </ResponseField>

    <ResponseField name="ExecutionDate" type="Unix timestamp">
      The date and time at which the Intent moved to `AUTHORIZED`.
    </ResponseField>

    <ResponseField name="Refund" type="object">
      Information about the Refund.

      <Expandable>
        <ResponseField name="Id" type="string">
          The unique identifier of the Refund.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

<ResponseExample>
  ```json Full reversal theme={null}
  {
      "Id": "int_019c105a-cd37-73bf-9245-e4e7a76310d5",
      "Amount": 20000,
      "AvailableAmountToSplit": 20000,
      "UnfundedAmount": 0,
      "Currency": "EUR",
      "PlatformFeesAmount": 0,
      "Status": "REFUND_REVERSED",
      "NextActions": "REFUND, DISPUTE",
      "ExternalData": {
          "ExternalProcessingDate": 1769800920,
          "ExternalProviderReference": "refund-stripe-e9e318a2-2f5e-4dec-90a6-010854f16861",
          "ExternalMerchantReference": "order-1f895705-f0e1-4c68-9822-4cf1c62678f6",
          "ExternalProviderName": "Stripe",
          "ExternalProviderPaymentMethod": "MASTERCARD"
      },
      "Buyer": {
          "Id": "user_m_01KF3087EDXEAK8VPD9DTMZW8N"
      },
      "LineItems": [
          {
              "Id": "int_li_019c105a-cd39-7422-a8ce-cf79862a68f2",
              "TotalLineItemAmount": 10000,
              "CapturedAmount": 10000,
              "RefundedAmount": 0,
              "DisputedAmount": 0,
              "SplitAmount": 0,
              "CancelledAmount": 0,
              "UnfundedSellerAmount": 0
          },
          {
              "Id": "int_li_019c105a-cd39-7422-a8ce-cf79862a68f3",
              "TotalLineItemAmount": 10000,
              "CapturedAmount": 10000,
              "RefundedAmount": 0,
              "DisputedAmount": 0,
              "SplitAmount": 0,
              "CancelledAmount": 0,
              "UnfundedSellerAmount": 0
          }
      ],
      "CreationDate": 1769800912,
      "ExecutionDate": 1769800924,
      "Refund": {
          "Id": "int_refund_019c105a-ee2a-7422-9058-96da3cf06b94"
      }
  }
  ```

  ```json Partial reversal theme={null}
  {
      "Id": "int_019c104e-6360-7540-a303-80c6c252827c",
      "Amount": 10000,
      "AvailableAmountToSplit": 20000,
      "UnfundedAmount": 0,
      "Currency": "EUR",
      "PlatformFeesAmount": 0,
      "Status": "CAPTURED",
      "NextActions": "REFUND, DISPUTE",
      "ExternalData": {
          "ExternalProcessingDate": 1769800102,
          "ExternalProviderReference": "refund-stripe-34a4fd98-83a6-4498-b4d4-28f4e0c916fd",
          "ExternalMerchantReference": "refund-order-6e66b81d-8700-4375-956a-d7d70caef902",
          "ExternalProviderName": "Stripe",
          "ExternalProviderPaymentMethod": "MASTERCARD"
      },
      "Buyer": {
          "Id": "user_m_01KF3087EDXEAK8VPD9DTMZW8N"
      },
      "LineItems": [
          {
              "Id": "int_li_019c104e-6361-7f41-b3bf-189c6a305604",
              "TotalLineItemAmount": 10000,
              "CapturedAmount": 10000,
              "RefundedAmount": 0,
              "DisputedAmount": 0,
              "SplitAmount": 0,
              "CancelledAmount": 0,
              "UnfundedSellerAmount": 0
          },
          {
              "Id": "int_li_019c104e-6361-7f41-b3bf-189c6a305605",
              "TotalLineItemAmount": 10000,
              "CapturedAmount": 10000,
              "RefundedAmount": 0,
              "DisputedAmount": 0,
              "SplitAmount": 0,
              "CancelledAmount": 0,
              "UnfundedSellerAmount": 0
          }
      ],
      "CreationDate": 1769800098,
      "ExecutionDate": 1769800836,
      "Refund": {
          "Id": "int_refund_019c104e-7294-71af-9952-b34f2fc5cca0"
      }
  }
  ```
</ResponseExample>

<RequestExample>
  ```json Full reversal theme={null}
  {   
      "ExternalData": {
          "ExternalProcessingDate": 1769800102,
          "ExternalProviderReference": "reverse-stripe-{{$guid}}",
          "ExternalMerchantReference": "order-{{$guid}}",
          "ExternalProviderName": "Stripe",
          "ExternalProviderPaymentMethod": "MASTERCARD"
      }
  }
  ```

  ```json Partial reversal theme={null}
  {   
      "Amount": 10000,
      "Currency": "EUR",
      "PlatformFeesAmount": 0,
      "ExternalData": {
          "ExternalProcessingDate": 1769800102,
          "ExternalProviderReference": "reverse-stripe-{{$guid}}",
          "ExternalMerchantReference": "order-{{$guid}}",
          "ExternalProviderName": "Stripe",
          "ExternalProviderPaymentMethod": "MASTERCARD"
      },
      "LineItems": [
          {
              "Id": "int_li_019c104e-6361-7f41-b3bf-189c6a305604",
              "Amount": 10000
          }
      ]
  }
  ```

  ```java Java theme={null}
  // idempotencyKey is null in this example
  PayInIntent reverseResult = api.getPayInApi().reversePayInIntentRefund(intent.getId(), intent.getRefund().getId(), reverseToBeCreated, null);
  ```

  ```c# .NET theme={null}
  await Api.PayIns.PartialReversePayInIntentRefundAsync(dto, intent.Id, intent.Refund.Id);

  await Api.PayIns.FullReversePayInIntentRefundAsync(dto, intent.Id, intent.Refund.Id);
  ```

  ```javascript NodeJS theme={null}
  api.PayIns.reversePayInIntentRefund(intent.Id, intent.Refund.Id, reverseDto)
  ```

  ```php PHP theme={null}
  _api->PayIns->ReversePayInIntentRefund($intent->Id, $intent->Refund->Id, $reverseRefundDto);
  ```

  ```py Python theme={null}
  PayInIntent.reverse_refund(intent.id, intent.refund.id, **dto)
  ```

  ```ruby Ruby theme={null}
  MangoPay::PayIn::PayInIntent::Refund.reverse(intent['Id'], intent['Refund']['Id'], dto)
  ```
</RequestExample>
