> **Description:** Process full or partial refunds of captured payments back to the customer's account.

# Refund a payment

A [Refund][refund-payment-endpoint] will reverse the direction of a transaction and move money from the merchant back to the customer.

Refunds can be made in full or partially as needed. The refund amount must be defined in the refund API request.

Refunded funds will be deducted from the merchant's settlement account after two business days. See [Settlement Information](https://developer.vippsmobilepay.com/docs/knowledge-base/settlements.md) for more details.

For general information about refunds, see [General info: Refunds](https://developer.vippsmobilepay.com/docs/knowledge-base/refund.md).

## Authorization

All ePayment API requests must include a valid Bearer token in the `Authorization` header.
See [Authorization](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/api-guide/concepts.md#authorization) for how to obtain one.

## Creating the refund request

### Full refund

If a customer has returned the goods or the service is not delivered, you should refund the payment.
This can be done through the [refund endpoint][refund-payment-endpoint].

For example, if the amount you have captured is 499,00 NOK, and you want to refund the whole amount (499,00 NOK):

```bash
curl -X POST https://apitest.vipps.no/epayment/v1/payments/UNIQUE-PAYMENT-REFERENCE/refund \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "Merchant-Serial-Number: YOUR-MSN" \
-H 'Idempotency-Key: YOUR-IDEMPOTENCY-KEY' \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
-d '{
  "modificationAmount": {
    "currency": "NOK",
    "value": 49900
  }
}'
```

In the response, the `aggregate` object will be updated to reflect the refunded amount.
Here you see that you have refunded 499,00 NOK of the originally captured amount, 499,00 NOK.

```json
{
  "aggregate": {
    "authorizedAmount": {
      "currency": "NOK",
      "value": 49900
    },
    "cancelledAmount": {
      "currency": "NOK",
      "value": 0
    },
    "capturedAmount": {
      "currency": "NOK",
      "value": 49900
    },
    "refundedAmount": {
      "currency": "NOK",
      "value": 49900
    }
  }
}
```

**Webhooks**
Register for the webhook event `epayments.payment.refunded.v1`
to be notified when the refund is complete.
For setup and event details, see [webhooks](https://developer.vippsmobilepay.com/docs/APIs/epayment-api/api-guide/webhooks.md).

### Partial refund

If you don't want to refund the entire amount, a smaller amount than captured can be refunded.
This can be done multiple times.

The `Idempotency-Key` header is there to help you ensure at most once operation where needed.

For example, if the amount you have captured is 499,00 NOK, and you want to refund 100,00 NOK:

```bash
curl -X POST https://apitest.vipps.no/epayment/v1/payments/UNIQUE-PAYMENT-REFERENCE/refund \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "Merchant-Serial-Number: YOUR-MSN" \
-H 'Idempotency-Key: YOUR-IDEMPOTENCY-KEY' \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
-d '{
  "modificationAmount": {
    "currency": "NOK",
    "value": 10000
  }
}'
```

In the response, you see that you have refunded 100,00 NOK of the originally captured amount, 499,00 NOK.
Then, you know that you have 399,00 NOK remaining to refund (i.e., `capturedAmount.value` - `refundedAmount.value`).
You can also check the [event log endpoint](https://developer.vippsmobilepay.com/redocusaurus/epayment-swagger-id.yaml).

```json
{
  "aggregate": {
    "authorizedAmount": {
      "currency": "NOK",
      "value": 49900
    },
    "cancelledAmount": {
      "currency": "NOK",
      "value": 0
    },
    "capturedAmount": {
      "currency": "NOK",
      "value": 49900
    },
    "refundedAmount": {
      "currency": "NOK",
      "value": 10000
    }
  }
}
```

For more general information, see [General info: Partial refund](https://developer.vippsmobilepay.com/docs/knowledge-base/refund.md#partial-refunds).

### Partial refund after partial capture

During a partial capture, you authorize an amount and capture only a part of this.

To refund and clear this charge, you refund the amount you have captured and then cancel the payment.

For example, if the amount you have authorized is 499,00 NOK, and you have captured 100,00 NOK.
First, refund the 100,00 NOK:

```bash
curl -X POST https://apitest.vipps.no/epayment/v1/payments/UNIQUE-PAYMENT-REFERENCE/refund \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "Merchant-Serial-Number: YOUR-MSN" \
-H 'Idempotency-Key: YOUR-IDEMPOTENCY-KEY' \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
-d '{
  "modificationAmount": {
    "currency": "NOK",
    "value": 10000
  }
}'
```

In the response, you see that you have refunded all of the originally captured amount
(i.e., `capturedAmount.value` - `refundedAmount.value`).

```json
{
  "aggregate": {
    "authorizedAmount": {
      "currency": "NOK",
      "value": 49900
    },
    "cancelledAmount": {
      "currency": "NOK",
      "value": 0
    },
    "capturedAmount": {
      "currency": "NOK",
      "value": 10000
    },
    "refundedAmount": {
      "currency": "NOK",
      "value": 10000
    }
  }
}
```

Second, cancel the payment:

```bash
curl -X POST https://apitest.vipps.no/epayment/v1/payments/UNIQUE-PAYMENT-REFERENCE/cancel \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-ACCESS-TOKEN" \
-H "Ocp-Apim-Subscription-Key: YOUR-SUBSCRIPTION-KEY" \
-H "Merchant-Serial-Number: YOUR-MSN" \
-H 'Idempotency-Key: YOUR-IDEMPOTENCY-KEY' \
-H "Vipps-System-Name: acme" \
-H "Vipps-System-Version: 3.1.2" \
-H "Vipps-System-Plugin-Name: acme-webshop" \
-H "Vipps-System-Plugin-Version: 4.5.6" \
-d ''
```

The response shows:

```json
   "aggregate": {
        "authorizedAmount": {
            "currency": "NOK",
            "value": 1995
        },
        "cancelledAmount": {
            "currency": "NOK",
            "value": 995
        },
        "capturedAmount": {
            "currency": "NOK",
            "value": 1000
        },
        "refundedAmount": {
            "currency": "NOK",
            "value": 1000
        }
```

The event log shows progression of steps.

**NOTE**

The payment state returned by
[`getPayment`](https://developer.vippsmobilepay.com/redocusaurus/epayment-swagger-id.yaml) will show `AUTHORIZED` even though the payment has been refunded.

To learn more about partial capture, see [General info: Partial capture](https://developer.vippsmobilepay.com/docs/knowledge-base/reserve-and-capture.md#partial-capture).

[refund-payment-endpoint]: https://developer.vippsmobilepay.com/redocusaurus/epayment-swagger-id.yaml

## Related pages

* [Refunding Vipps/MobilePay payments](https://developer.vippsmobilepay.com/docs/knowledge-base/refund.md)

> **Full site overview:** For every page in this documentation, read [https://developer.vippsmobilepay.com/llms.txt](https://developer.vippsmobilepay.com/llms.txt).
