Refund a Payment {#klarna-refund-intro}
=======================================

Refunding a payment returns the entire captured amount or part of the captured amount to the customer's account. Klarna supports multiple refund requests when the total amount of all refunds is less than the captured amount.'  
`Cybersource` recommends using the optional fields for a refund to ensure the request is successful. For more information, see [Optional Fields for a Refund](/docs/cybs/en-us/klarna/developer/all/so/klarna/klarna-services/klarna-refund-intro/klarna-refund-opt-fields.md "").

Endpoints {#klarna-refund-intro_section_tw1_4fm_lyb}
----------------------------------------------------

Set the apRefundService_run field to `true`, and send the request to one of these endpoints:  
**Production:** `https://ics2ws.ic3.com/commerce/1.x/transactionProcessor`  
**Test:** `https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor`

Response Statuses {#klarna-refund-intro_section_uxl_fpm_lyb}
------------------------------------------------------------

The refund service responds with one of these statuses as the apRefundReply_status field value:

* `FAILED`: The refund request is not successful. Send a new refund request. A failed request can be due to either Klarna rejecting the transaction or a technical error.{#klarna-refund-intro_status-failed}
  {#klarna-refund-intro_status-failed}
* `PENDING`: The refund request is accepted but is not refunded. Request the check status service to retrieve status updates. For more information, see [Check a Request Status](/docs/cybs/en-us/klarna/developer/all/so/klarna/klarna-services/klarna-status-intro.md "").
* `REFUNDED`: The captured payment is successfully refunded.{#klarna-refund-intro_status-refunded}
  {#klarna-refund-intro_status-refunded} {#klarna-refund-intro_ul_chy_fz1_cyb}

Required Fields for a Refund {#klarna-refund-req-fields}
========================================================

Include these required fields to refund a payment.

[apPaymentType](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ap-payment-type.md "")
:
Set to `KLI`.

[apRefundService_refundRequestID](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ap-refund-service-refund-request-id.md "")
:
Set to the request ID included in the capture response.

[apRefundService_run](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/ap-refund-service-run.md "")
:
Set to `true`.

[merchantID](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/merchant-id.md "")
:

[merchantReferenceCode](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/merchant-reference-code.md "")
:

[purchaseTotals_currency](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/purchase-totals-currency.md "")
:

[purchaseTotals_grandTotalAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/purchase-totals-grand-total-amount.md "")
:

Optional Fields for a Refund {#klarna-refund-opt-fields}
========================================================

[billTo_email](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-email.md "")
:

[billTo_firstName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-first-name.md "")
:

billTo_language
:
> If this field is not included, the language is set to English by default.

:
For a list of possible values, see the [*ISO Standard Language Codes*](https://developer.cybersource.com/docs/cybs/en-us/language-codes/reference/all/na/language-codes/language-codes.md "") guide.

[billTo_lastName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/bill-to-last-name.md "")
:

[item_#_productCode](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-product-code.md "")
:
Set to `coupon`.
:
Replace the `#` character with the number `0` for the first item and consecutive numbers for any additional items.

[item_#_productName](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-product-name.md "")
:
Replace the `#` character with the number `0` for the first item and consecutive numbers for any additional items.

[item_#_productSKU](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-product-sku.md "")
:
Replace the `#` character with the number `0` for the first item and consecutive numbers for any additional items.

[item_#_quantity](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-quantity.md "")
:
Replace the `#` character with the number `0` for the first item and consecutive numbers for any additional items.

[item_#_totalAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-total-amount.md "")
:
Replace the `#` character with the number `0` for the first item and consecutive numbers for any additional items.

[item_#_unitPrice](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/item-no-unit-price.md "")
:
Replace the `#` character with the number `0` for the first item and consecutive numbers for any additional items.

[purchaseTotals_discountAmount](https://developer.cybersource.com/docs/cybs/en-us/api-fields/reference/all/so/api-fields/purchase-totals-discount-amount.md "")
:

XML Example: Refund {#klarna-refund-ex-so}
==========================================

Request

```
&lt;requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.213"&gt;
	&lt;merchantID&gt;test_merchant&lt;/merchantID&gt;
	&lt;merchantReferenceCode&gt;refnum-1234&lt;/merchantReferenceCode&gt;
	&lt;purchaseTotals&gt;
		&lt;currency&gt;USD&lt;/currency&gt;
		&lt;grandTotalAmount&gt;154.50&lt;/grandTotalAmount&gt;
	&lt;/purchaseTotals&gt;
	&lt;apPaymentType&gt;KLI&lt;/apPaymentType&gt;
	&lt;apRefundService run="true"&gt;
		&lt;refundRequestID&gt;6957576170986768803011&lt;/refundRequestID&gt;
	&lt;/apRefundService&gt;
&lt;/requestMessage&gt;
```

Response

```
&lt;replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.213"&gt;
	&lt;merchantReferenceCode&gt;refnum-1234&lt;/merchantReferenceCode&gt;
	&lt;requestID&gt;6957582387066840103011&lt;/requestID&gt;
	&lt;decision&gt;ACCEPT&lt;/decision&gt;
	&lt;reasonCode&gt;100&lt;/reasonCode&gt;
	&lt;requestToken&gt;AxjnrwSTeSvaHi+ZXThj/6IZYjWmrWbZoV7NKCojmjMcX7SB3i0ZiwyaSZejFlof+k3krsEu93k+yRAABS1G&lt;/requestToken&gt;
	&lt;purchaseTotals&gt;
		&lt;currency&gt;USD&lt;/currency&gt;
	&lt;/purchaseTotals&gt;
	&lt;apRefundReply&gt;
		&lt;reasonCode&gt;100&lt;/reasonCode&gt;
		&lt;transactionID&gt;b30d7de1-215d-4989-8b82-f190d39457a4&lt;/transactionID&gt;
		&lt;status&gt;REFUNDED&lt;/status&gt;
		&lt;processorResponse&gt;00006&lt;/processorResponse&gt;
		&lt;amount&gt;154.50&lt;/amount&gt;
		&lt;dateTime&gt;2023-09-26T19:57:19Z&lt;/dateTime&gt;
		&lt;reconciliationID&gt;XFZ55MYPWYRA&lt;/reconciliationID&gt;
		&lt;returnRef&gt;XFZ40MYVGPWJ&lt;/returnRef&gt;
		&lt;paymentStatus&gt;refunded&lt;/paymentStatus&gt;
		&lt;responseCode&gt;00006&lt;/responseCode&gt;
	&lt;/apRefundReply&gt;
&lt;/replyMessage&gt;
```

