Valuelink Gift Cards 
In addition to processing transactions with debit and credit payment cards, the 
TransactionProvider
 makes it easy for you to accept Valuelink gift cards. Four transaction types are available:
  • Activation
  • Balance Inquiry
  • Redemption
  • Cashout
For each transaction type you have the option to add specific Valuelink metadata such as 
User1
User2
clerkId
 and 
transactionPostalCode
. Each of its fields are optional.
myMetadata = new ValueLinkMetadataBuilder() .clerkId("The clerk ID") .addUser1("User 1") .addUser2("User 2") .transactionPostalCode("12345") .build();
Activation Transactions
The first thing to do in order to make a Valuelink gift card usable is to activate it. An activation adds value and changes the status of the gift card to active. If activation was successful will return the card balance. When activating a gift card activation amount is always required. If the card is denominated the amount must exactly match the value of the card defined in the denomination promo. To perform a gift card activation use the transaction type 
ACTIVATION
TransactionParameters transactionParameters = new TransactionParameters.Builder() .activation(giftCardActivationAmount, giftCardCurrency) .subject("Gift card activation") .customIdentifier("yourReferenceForTheTransaction") .metadata(myMetadata) .build(); // Continue the transaction process...
The main determinant for this request is the transaction type parameter included in transactionParameters which has ACTIVATION as its value. Amount and currency are required parameters.
 
Balance Inquiry Transactions
 
Balance Inquiry transactions are performed when there is a need to get the current balance of an active gift card account. Balance Inquiry transaction returns the current balance on the gift card. To check the balance on a Valuelink gift card, use the transaction type 
balanceInquiry
 in the 
TransactionParameters
:
TransactionParameters transactionParameters = new TransactionParameters.Builder() .balanceInquiry() .subject("`Gift Card Balance Inquiry") .statementDescriptor("Statement Descriptor") .customDescriptor("Custom Descriptor") .metadata(metadata) .build(); // Continue the transaction process...
Redemption, No NSF Transactions
A Redemption, No NSF (No Sufficient Funds) transaction performs a redemption on an active gift card account. If the requested amount is smaller than the account balance, a redemption is performed. This reduces the balance on the account with the requested amount.
In order to do a Valuelink gift card redemption, you simply issue a 
charge
 transaction and you pass the workflow as 
GIFT_CARD
.
TransactionParameters transactionParameters = new TransactionParameters.Builder() .charge(chargeAmount, Currency.USD) .workflow(TransactionWorkflowType.GIFT_CARD) .subject("Bouquet of Flowers") .metadata(redemptionMetaData) // optional .customIdentifier("yourReferenceForTheTransaction") // optional .build();
If the requested amount is greater than the account balance (you can check that with 
TransactionProcessDetailsStateDetails
 status), the account will be reduced to zero, a split tender is prompted and the account will be closed. A split tender prompts the customer to pay the difference of the requested amount and the account balance.
Your application needs to determine how much was actually taken from the account by looking at the previous balance and new balance. The difference is applied to the Redemption in order to determine if the entire transaction was satisfied.
@Override public void onCompleted(TransactionProcess process, Transaction transaction, TransactionProcessDetails processDetails) { if (TransactionProcessDetailsState.APPROVED.equals(processDetails.getState())) { Receipt customerReceipt = transaction.getCustomerReceipt(); if (customerReceipt.getPaymentDetails().size() > 0 and ReceiptLineItemKey.PAYMENT_DETAILS_REMAINING_BALANCE.equals(customerReceipt.getPaymentDetails().get(0).getKey())) { System.out.println("Remaining Balance: " + customerReceipt.getPaymentDetails().get(0).getValue()) } if (TransactionProcessDetailsStateDetails.APPROVED.equals(processDetails.getStateDetails())) { // Transaction is fully approved System.out.println("Fully approved " + transaction.getAmount()); } else if (TransactionProcessDetailsStateDetails.APPROVED_PARTIALLY.equals(processDetails.getStateDetails())) { // Transaction is partially approved. You needs to trigger another charge transaction for the outstanding amount System.out.println("The outstanding amount is: " + chargeAmount.subtract(transaction.getAmount())); } else { // Undefined case -- should not happen. } } else if (TransactionProcessDetailsState.DECLINED.equals(processDetails.getState())) { // Transaction was declined. } else { // Transaction was neither approved nor declined! } } // Continue the transaction process
Cashout Transactions
Cashout transactions are used when there is a need to remove the remaining balance from the Valuelink gift card. The Cashout transaction will bring the account balance to zero, make the gift card inactive and returns the cashed-out amount. This transaction on gift cards is done by using the 
cashout
 transaction type.
TransactionParameters transactionParameters = new TransactionParameters.Builder() .cashout() .subject("Gift card cash-out") .statementDescriptor("Statement Descriptor") .customDescriptor("Custom Descriptor") .metadata(metadata) .build(); // Start the transaction as usual via TransactionProvider.startTransaction()