> ## Documentation Index
> Fetch the complete documentation index at: https://adyen-preview.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Check the Balance of a Gift Card

> Query the balance of a gift card at the point of sale.

You can check the funds remaining on an [activated gift card](https://adyen-preview.mintlify.site/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/activate.md), by making a balance request. This allows you to verify the gift card's value before a transaction and determine if a partial payment is needed.

## Requirements

Before you begin, take into account the following requirements, limitations, and preparations.

| Requirement | Description |
| - | - |
| **Integration type** | A [Terminal API](https://adyen-preview.mintlify.site/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](https://adyen-preview.mintlify.site/point-of-sale/what-we-support/payment-methods#add-payment-methods-to-your-account). Complete the onboarding process with the gift card provider. |

## Make a balance inquiry

To see the funds remaining on a gift card:

1. Determine the [card entry method](https://adyen-preview.mintlify.site/point-of-sale/alternative-payment-methods/gift-cards-terminal-api#card-entry-methods):

   * 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 [Terminal API](https://adyen-preview.mintlify.site/point-of-sale/design-your-integration/terminal-api) balance inquiry request, specifying:

   * The standard [`SaleToPOIRequest.MessageHeader` ](https://adyen-preview.mintlify.site/point-of-sale/design-your-integration/terminal-api#request-message-header)object, with `MessageClass` set to **Service** and `MessageCategory` set to **BalanceInquiry**.

     | Parameter | Required | Description |
     | - | - | - |
     | `ProtocolVersion` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | **3.0** |
     | `MessageClass` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | **Service** |
     | `MessageCategory` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | **BalanceInquiry** |
     | `MessageType` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | **Request** |
     | `ServiceID` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | 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-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | Your unique ID for the POS system component to send this request from. |
     | `POIID` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | The unique ID of the terminal to send this request to. Format: *\[device model]-\[serial number]*. The [BalanceInquiryRequest.PaymentAccountReq.PaymentInstrumentData](https://docs.adyen.com/api-explorer/terminal-api/latest/post/balanceinquiry#request-PaymentAccountReq-PaymentInstrumentData) object with: |

     | Parameter | Required | Description |
     | - | - | - |
     | `ProtectedCardData` | | Optional secondary security (SSC) code for SVS gift cards. The SSC allows up to 8 digits. For example, `ssc=1111`.If the secondary security code is required, encode it to Base64 and pass the resulting string. For example, `{"ssc=1111"}` needs to be passed as `"ProtectedCardData": "eyJzc2MiOiIxMTExIn0="` |
     | `PaymentInstrumentType` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | **StoredValue** |
     | `StoredValueAccountID` | ![-white\_check\_mark-](https://docs.adyen.com/user/data/smileys/emoji/white_check_mark.png) | The gift card details: `StoredValueAccountType`: **GiftCard** `StoredValueProvider`: the gift card issuer: **givex**, **svs**, **valuelink**, or **[any Intersolve-supported card type](https://adyen-preview.mintlify.site/payment-methods/gift-cards#supported-gift-cards)**. `IdentificationType`: **PAN** `EntryMode`, `StoredValueID` and `ExpiryDate`: these parameters depend on the [card entry method](https://adyen-preview.mintlify.site/point-of-sale/alternative-payment-methods/gift-cards-terminal-api#card-entry-methods) 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 check the balance for a scanned gift card. It includes an optional `ProtectedCardData` field required for stored value solution gift cards with the SSC converted to a Base64-encoded string.

   #### JSON

   ```json theme={null}
   {
       "SaleToPOIRequest":{
           "MessageHeader":{
               "ProtocolVersion":"3.0",
               "MessageClass":"Service",
               "MessageCategory":"BalanceInquiry",
               "MessageType":"Request",
               "ServiceID":"9266",
               "SaleID":"POSSystemID12345",
               "POIID":"V400m-324688179"
           },
           "BalanceInquiryRequest":{
               "PaymentAccountReq":{
                   "PaymentInstrumentData":{
                       "ProtectedCardData": "eyJzc2MiOiIxMTExIn0=",
                       "PaymentInstrumentType":"StoredValue",
                       "StoredValueAccountID":{

                           "StoredValueAccountType":"GiftCard",
                           "StoredValueProvider":"svs",
                           "IdentificationType":"PAN",
                           "EntryMode":[
                               "Scanned"
                           ],
                           "StoredValueID":"6006491260550218066",
                           "ExpiryDate":"1122"
                       }
                   }
               }
           }
       }
   }
   ```

   #### Java

   ```java theme={null}
   String serviceID = "YOUR_UNIQUE_ATTEMPT_ID";
   String saleID = "YOUR_CASH_REGISTER_ID";
   String POIID = "YOUR_TERMINAL_ID";

   SaleToPOIRequest saleToPOIRequest = new SaleToPOIRequest();
   MessageHeader messageHeader = new MessageHeader();
   messageHeader.setProtocolVersion("3.0");
   messageHeader.setMessageClass( MessageClassType.SERVICE );
   messageHeader.setMessageCategory( MessageCategoryType.BALANCE_INQUIRY );
   messageHeader.setMessageType( MessageType.REQUEST );
   messageHeader.setServiceID(serviceID);
   messageHeader.setSaleID(saleID);
   messageHeader.setPOIID(POIID);
   saleToPOIRequest.setMessageHeader(messageHeader);

   BalanceInquiryRequest balanceInquiryRequest = new BalanceInquiryRequest();
   PaymentAccountReq paymentAccountReq = new PaymentAccountReq();
   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);
   paymentAccountReq.setPaymentInstrumentData(paymentInstrumentData);
   balanceInquiryRequest.setPaymentAccountReq(paymentAccountReq);
   saleToPOIRequest.setBalanceInquiryRequest(balanceInquiryRequest);
   terminalAPIRequest.setSaleToPOIRequest(saleToPOIRequest);
   ```

3. In the [BalanceInquiryResponse](https://docs.adyen.com/api-explorer/terminal-api/latest/post/balanceinquiry#responses-200-Response), check the following:

   * `PaymentAccountStatus.CurrentBalance`: the value of the gift card balance.
   * `PaymentAccountStatus.Currency`: the currency of the gift card balance.

   The example below indicates that the gift card has a balance of GBP 98.75.

   ```json theme={null}
   {
     "SaleToPOIResponse":{
       "BalanceInquiryResponse":{
         "Response":{
           "Result":"Success"
         },
         "PaymentAccountStatus":{
           "CurrentBalance":98.75,
             "PaymentAcquirerData":{
               "AcquirerPOIID":"V400m-324688179"
             },
           "Currency":"GBP"
         }
       },
       "MessageHeader":{
         "ProtocolVersion":"3.0",
         "SaleID":"POSSystemID12345",
         "MessageClass":"Service",
         "MessageCategory":"BalanceInquiry",
         "ServiceID":"9266",
         "POIID":"V400m-324688179",
         "MessageType":"Response"
       }
     }
   }
   ```

## See also

* [Gift cards and other stored value cards](https://adyen-preview.mintlify.site/point-of-sale/alternative-payment-methods/gift-cards-terminal-api)
* [Activate a gift card](https://adyen-preview.mintlify.site/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/activate.md)
* [Load funds to a gift card](https://adyen-preview.mintlify.site/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/load-a-balance.md)
* [Make a gift card payment](https://adyen-preview.mintlify.site/point-of-sale/alternative-payment-methods/gift-cards-terminal-api/payment.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.