How to Use a Token
This code steps you through the process of using a token to validate a customer's credit card information and capture authorization information for a charge against the card. Tokens can be used to process many types of future transactions such as payments, sales, refunds, and cancellations. Other returned information includes the status, a message, an address verification (AVS) result, and card verification data (CVV2) result.
The token that this code returns is an assigned Transaction ID. Depending on the interface you're using, this Transaction ID is either "Master ID" or "RRNO."
You can test for both outcomes:
Approved: When you pass odd dollar amounts, payment authorizations are returned with an 'Approved' status and authorization information is also captured.
Declined: When you pass even dollar amounts, payment authorizations are returned with a 'Declined' status and no authorization information is passed.
The following sample code calls a routine from our Code Library.
* BluePay Java Sample code.
* This code sample runs a $3.00 Credit Card Sale transaction
* against a customer using test payment information from a
* previously generated token.
* If using TEST mode, odd dollar amounts will return
* an approval and even dollar amounts will return a decline.
public class How_To_Use_Token
public static void main(String args)
String ACCOUNT_ID = "MERCHANT'S ACCOUNT ID HERE";
String SECRET_KEY = "MERCHANT'S SECRET KEY HERE";
String MODE = "TEST";
String TOKEN = "TOKEN HERE";
// Merchant's Account ID
// Merchant's Secret Key
// Transaction Mode: TEST (can also be LIVE)
BluePayPayment_BP10Emu payment = new BluePayPayment_BP10Emu(
// Sale Amount: $3.00
catch (Exception ex)
System.out.println("Exception: " + ex.toString());
System.out.println("Error: " + payment.getMessage());
else if(payment.isApproved() || payment.isDeclined())
// Outputs response from BluePay gateway
System.out.println("Transaction Status: " + payment.getStatus());
System.out.println("Transaction ID: " + payment.getTransID());
System.out.println("Transaction Message: " + payment.getMessage());
System.out.println("AVS Result: " + payment.getAVS());
System.out.println("CVV2: " + payment.getCVV2());
System.out.println("Masked Payment Account: " + payment.getMaskedPaymentAccount());
System.out.println("Card Type: " + payment.getCardType());
System.out.println("Authorization Code: " + payment.getAuthCode());