--- title: "Make a refund to a gift card" description: "Make a referenced refund if you have the original payment data, or an unreferenced refund if you do not." url: "https://docs.adyen.com/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/refund-gift-cards" source_url: "https://docs.adyen.com/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/refund-gift-cards.md" canonical: "https://docs.adyen.com/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/refund-gift-cards" last_modified: "2019-11-14T11:17:00+01:00" language: "en" --- # Make a refund to a gift card Make a referenced refund if you have the original payment data, or an unreferenced refund if you do not. [View source](/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/refund-gift-cards.md) If you want to return funds to a shopper's gift card, you can make a referenced refund or an unreferenced refund: * **Referenced refund**: a `ReversalRequest` with a reference to the original payment's transaction identifier. Use this if you want to refund a payment made with this gift card. The transaction identifier references the gift card details, so you do not need to specify them in the refund request. You can also make (multiple) partial refunds in this way. For the detailed steps, refer to [Referenced refund](/point-of-sale/basic-tapi-integration/refund-payment/referenced). * **Unreferenced refund**: a `PaymentRequest` with `PaymentType` **Refund**. Use this if you cannot connect the refund to a payment made with the gift card but still want to return the funds to this gift card. For example, in a 'merchandise return' where the shopper returns an unwanted birthday gift. Because an unreferenced refund to a gift card requires specifying the gift card details, we explain this transaction on this page. If you want to give the balance of a gift card to a shopper in cash, you should [make a cashback request](/point-of-sale/gift-cards-terminal-api/deactivate#cashing-back-gift-card) instead. ## Requirements Before you begin, take into account the following requirements, limitations, and preparations. | Requirement | Description | | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | A [Terminal API](/point-of-sale/design-your-integration/terminal-api) integration with payment terminals. | | **Setup steps** | Before you begin:- [Add the payment method to your Adyen account](/point-of-sale/what-we-support/payment-methods#add-payment-methods-to-your-account). - Complete the onboarding process with the gift card provider. | ## Make an unreferenced refund To issue a refund to a gift card: 1. Determine the [card entry method](/point-of-sale/gift-cards-terminal-api#card-entry): * If you want to scan the card, do that first and use the obtained card details in your request. * If you want to swipe the card or use manual keyed entry (MKE), send the request first. The payment terminal will show a prompt to swipe the card or enter the card details. 2. [Make a payment request](/point-of-sale/basic-tapi-integration/make-a-payment), specifying: * The standard [`SaleToPOIRequest.MessageHeader` ](/point-of-sale/design-your-integration/terminal-api#request-message-header)object, with `MessageClass` set to **Service** and `MessageCategory` set to **Payment**. | Parameter | Required | Description | | ----------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | `ProtocolVersion` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **3.0** | | `MessageClass` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **Service** | | `MessageCategory` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **Payment** | | `MessageType` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **Request** | | `ServiceID` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Your unique ID for this request, consisting of 1-10 alphanumeric characters. Must be unique within the last 48 hours for the terminal (`POIID`) being used. | | `SaleID` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Your unique ID for the POS system component to send this request from. | | `POIID` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The unique ID of the terminal to send this request to. Format: *\[device model]-\[serial number]*. | - The [PaymentRequest.SaleData](https://docs.adyen.com/api-explorer/terminal-api/latest/post/payment#request-SaleData) object with: | Parameter | Required | Description | | --------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `SaleTransactionID.TransactionID` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Your reference to identify this refund. | | `SaleTransactionID.TimeStamp` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Date and time of the request, in [UTC format](https://en.wikipedia.org/wiki/ISO_8601#Coordinated_Universal_Time_\(UTC\)). | | `SaleReferenceID` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | Your reference to the order that you want to do a refund for. In the [Customer Area](https://ca-test.adyen.com/), it will appear as the **Merchant Order** for the transaction. | | `SaleToAcquirerData` | | * Optional for manually keying in the card number (MKE): **maxLength** and **cardMask**. Use these fields to specify card numbers with more than 24 digits. * Optional for Stored Value Solutions (SVS) gift cards: **ssc**. This is the secondary security code of the gift card, and allows up to 8 digits. For example, `ssc`: **1111**. To add these, follow the [instructions below](#sale-to-acquirer-data). | []()\ In `SaleData.SaleToAcquirerData`, specify the parameter in one of the following formats: * Option 1: a JSON object converted to a Base64 encoded string.\ Encode `{"maxLength": "27", "cardMask": "****-****-****-****-****-****-***"}` to Base64, and pass the resulting string:\ `"SaleToAcquirerData": "eyJtYXhMZW5ndGgiOiAiMjciLCAiY2FyZE1hc2siOiAiKioqKi0qKioqLSoqKiotKioqKi0qKioqLSoqKiotKioqIn0="` * Option 2: a key-value pair:\ `"SaleToAcquirerData": "maxLength=27&cardMask=****-****-****-****-****-****-***"` The format that you use here will also be the format of the `AdditionalResponse` that you receive. If there are more tender options (for example, **ReceiptHandler** ) or other data elements that you need to pass in the `SaleToAcquirerData` field, refer to [Add information to a payment](/point-of-sale/add-data). - The [PaymentTransaction](https://docs.adyen.com/api-explorer/terminal-api/latest/post/payment#request-PaymentTransaction) object with: | Parameter | Required | Description | | ------------ | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | | `AmountsReq` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The `Currency` and `RequestedAmount` being refunded to the gift card. | - The [PaymentData](https://docs.adyen.com/api-explorer/terminal-api/latest/post/payment#request-PaymentData) object with: | Parameter | Required | Description | | --------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `PaymentType` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **Refund** | | `PaymentInstrumentData.PaymentInstrumentType` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | **StoredValue** | | `PaymentInstrumentData.StoredValueAccountID` | ![-white\_check\_mark-](/user/data/smileys/emoji/white_check_mark.png "-white_check_mark-") | The gift card details:- `StoredValueAccountType`: **GiftCard** - `StoredValueProvider`: the gift card issuer: **givex**, **svs**, **valuelink**, or **[any Intersolve-supported card type](/payment-methods/gift-cards#supported-gift-cards)**. - `IdentificationType`: **PAN**. - `EntryMode`, `StoredValueID` and `ExpiryDate`: these parameters depend on the [card entry method](/point-of-sale/gift-cards-terminal-api#card-entry) you are using. See the following table. | | Card entry | Parameters | | ---------- | ------------------------------------------------------------------------------------------------------------- | | Scan | * `EntryMode`: **Scanned** * `StoredValueID`: gift card number. * `ExpiryDate`: expiry date of the gift card. | | Swipe | - `EntryMode`: **MagStripe** - `StoredValueID`: include this parameter but do not provide a value. | | MKE | * `EntryMode`: **Keyed** * `StoredValueID`: include this parameter but do not provide a value. | The example below shows how to issue a refund of GBP 30.00 to a scanned gift card. #### JSON ```json { "SaleToPOIRequest":{ "MessageHeader":{ "ProtocolVersion":"3.0", "MessageClass":"Service", "MessageCategory":"Payment", "MessageType":"Request", "ServiceID":"9268", "SaleID":"POSSystem", "POIID":"V400m-324688179" }, "PaymentRequest":{ "SaleData":{ "SaleTransactionID":{ "TransactionID":"44741", "TimeStamp":"2019-06-22T12:20:27+00:00" }, "SaleReferenceID":"YOUR_ORDER_REFERENCE" }, "PaymentTransaction":{ "AmountsReq":{ "Currency":"GBP", "RequestedAmount":30 } }, "PaymentData":{ "PaymentType":"Refund", "PaymentInstrumentData":{ "PaymentInstrumentType":"StoredValue", "StoredValueAccountID":{ "StoredValueAccountType":"GiftCard", "StoredValueProvider":"svs", "IdentificationType":"PAN", "EntryMode":[ "Scanned" ], "StoredValueID":"6006491260550218066", "ExpiryDate":"1122" } } } } } } ``` #### Java ```java String serviceID = "YOUR_UNIQUE_ATTEMPT_ID"; String saleID = "YOUR_CASH_REGISTER_ID"; String POIID = "YOUR_TERMINAL_ID"; String transactionID = "YOUR_UNIQUE_TRANSACTION_ID"; SaleToPOIRequest saleToPOIRequest = new SaleToPOIRequest(); MessageHeader messageHeader = new MessageHeader(); messageHeader.setProtocolVersion("3.0"); messageHeader.setMessageClass( MessageClassType.SERVICE ); messageHeader.setMessageCategory( MessageCategoryType.PAYMENT ); messageHeader.setMessageType( MessageType.REQUEST ); messageHeader.setServiceID(serviceID); messageHeader.setSaleID(saleID); messageHeader.setPOIID(POIID); saleToPOIRequest.setMessageHeader(messageHeader); PaymentRequest paymentRequest = new PaymentRequest(); SaleData saleData = new SaleData(); TransactionIdentification saleTransactionID = new TransactionIdentification(); saleTransactionID.setTransactionID(transactionID); saleTransactionID.setTimeStamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar())); saleData.setSaleTransactionID(saleTransactionID); saleData.setSaleReferenceID("YOUR_ORDER_REFERENCE"); paymentRequest.setSaleData(saleData); PaymentTransaction paymentTransaction = new PaymentTransaction(); AmountsReq amountsReq = new AmountsReq(); amountsReq.setCurrency("GBP"); amountsReq.setRequestedAmount( BigDecimal.valueOf(30) ); paymentTransaction.setAmountsReq(amountsReq); paymentRequest.setPaymentTransaction(paymentTransaction); PaymentData paymentData = new PaymentData(); paymentData.setPaymentType( PaymentType.REFUND ); PaymentInstrumentData paymentInstrumentData = new PaymentInstrumentData(); paymentInstrumentData.setPaymentInstrumentType( PaymentInstrumentType.STORED_VALUE ); StoredValueAccountID storedValueAccountID = new StoredValueAccountID(); storedValueAccountID.setStoredValueAccountType( StoredValueAccountType.GIFT_CARD ); storedValueAccountID.setStoredValueProvider("svs"); storedValueAccountID.setIdentificationType( IdentificationType.PAN ); storedValueAccountID.getEntryMode().add( EntryModeType.SCANNED ); storedValueAccountID.setStoredValueID("6006491260550218066"); storedValueAccountID.setExpiryDate("1122"); paymentInstrumentData.setStoredValueAccountID(storedValueAccountID); paymentData.setPaymentInstrumentData(paymentInstrumentData); paymentRequest.setPaymentData(paymentData); saleToPOIRequest.setPaymentRequest(paymentRequest); terminalAPIRequest.setSaleToPOIRequest(saleToPOIRequest); ``` 3. In the [PaymentResponse](https://docs.adyen.com/api-explorer/terminal-api/latest/post/payment#responses-200), check the following: * `POIData.POITransactionID.TransactionID`: The [transaction identifier](/point-of-sale/design-your-integration/terminal-api#transaction-identifier) for the refund. * `PaymentReceipt`: An object containing data you can use to [generate a receipt](/point-of-sale/basic-tapi-integration/generate-receipts). * `Response.Result`: **Success** The example below indicates that the refund of GBP 30.00 was successfully issued to the gift card. ```json { "SaleToPOIResponse":{ "PaymentResponse":{ "POIData":{ "POITransactionID":{ "TimeStamp":"2019-06-22T12:20:31.000Z", "TransactionID":"u6W7001529670031000.NC6HT9CRT65ZGN82" } }, "SaleData":{ "SaleTransactionID":{ "TimeStamp":"2019-06-22T12:20:27.000Z", "TransactionID":"44741" }, "SaleReferenceID":"SalesRefABC" }, "PaymentReceipt":[...], "PaymentResult":{ "PaymentAcquirerData":{ "AcquirerPOIID":"V400m-324688179", "AcquirerTransactionID":{ "TimeStamp":"2019-06-22T12:20:31.000Z", "TransactionID":"NC6HT9CRT65ZGN82" }, "MerchantID":"TestMerchantPOS" }, "PaymentInstrumentData":{ "StoredValueAccountID":{ "IdentificationType":"PAN", "EntryMode":[ "MagStripe" ], "StoredValueID":"603628173862001915498", "StoredValueAccountType":"GiftCard", "StoredValueProvider":"givex", "ExpiryDate":"1249" }, "PaymentInstrumentType":"StoredValue" }, "AmountsResp":{ "AuthorizedAmount":30.00, "Currency":"GBP" }, "PaymentType":"Refund" }, "Response":{ "Result":"Success", "AdditionalResponse":"..." } }, "MessageHeader":{ "ProtocolVersion":"3.0", "SaleID":"POSSystem", "MessageClass":"Service", "MessageCategory":"Payment", "ServiceID":"9268", "POIID":"V400m-324688179", "MessageType":"Response" } } } ``` ## See also * [Activate a gift card](/point-of-sale/gift-cards-terminal-api/activate) * [Check the balance of a gift card](/point-of-sale/gift-cards-terminal-api/query-the-balance) * [Deactivate a gift card](/point-of-sale/gift-cards-terminal-api/deactivate) * [Referenced refund](/point-of-sale/basic-tapi-integration/refund-payment/referenced)