Java Samples

Other Samples

package com.isyn.app.payment;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("unused")
public class ProxyHPCIProcessorApp {
  // define service constants
  private static final String PXY_AUTH = "/iSynSApp/paymentAuth.action";
  private static final String PXY_SALE = "/iSynSApp/paymentSale.action";
  private static final String PXY_CAPTURE = "/iSynSApp/paymentCapture.action";
  private static final String PXY_CREDIT = "/iSynSApp/paymentCredit.action";
  private static final String PXY_VOID = "/iSynSApp/paymentVoid.action";
  private static final String PXYPARAM_APIVERSION = "apiVersion";
  private static final String PXYPARAM_APITYPE = "apiType";
  private static final String PXYPARAM_APITYPE_PXYHPCI = "pxyhpci";
  private static final String PXYPARAM_USERNAME = "userName";
  private static final String PXYPARAM_USERPASSKEY = "userPassKey";
  private static final String PXYPARAM_PXY_TRANSACTION_CUSISO = "pxyTransaction.txnCurISO";
  private static final String PXYPARAM_PXY_TRANSACTION_AMOUNT = "pxyTransaction.txnAmount";
  private static final String PXYPARAM_PXY_TRANSACTION_MER_REFID_NAME = "pxyTransaction.merchantRefIdName";
  private static final String PXYPARAM_PXY_TRANSACTION_MER_REFID = "pxyTransaction.merchantRefId";
  private static final String PXYPARAM_PXY_TRANSACTION_PROCESSOR_REFID = "pxyTransaction.processorRefId";
  private static final String PXYPARAM_PXY_CC_CARDTYPE = "pxyCreditCard.cardType";
  private static final String PXYPARAM_PXY_CC_NUMBER = "pxyCreditCard.creditCardNumber";
  private static final String PXYPARAM_PXY_CC_EXPMONTH = "pxyCreditCard.expirationMonth";
  private static final String PXYPARAM_PXY_CC_EXPYEAR = "pxyCreditCard.expirationYear";
  private static final String PXYPARAM_PXY_CC_CVV = "pxyCreditCard.cardCodeVerification";
  private static final String PXYPARAM_PXY_CUSTINFO_CUSTOMERID = "pxyCustomerInfo.customerId";
  private static final String PXYPARAM_PXY_CUSTINFO_EMAIL = "pxyCustomerInfo.email";
  private static final String PXYPARAM_PXY_CUSTINFO_INSTR = "pxyCustomerInfo.instructions";
  private static final String PXYPARAM_PXY_CUSTINFO_CUSTIP = "pxyCustomerInfo.customerIP";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_FIRSTNAME = "pxyCustomerInfo.billingLocation.firstName";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_LASTNAME = "pxyCustomerInfo.billingLocation.lastName";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_COMPANYNAME = "pxyCustomerInfo.billingLocation.companyName";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_ADDRESS = "pxyCustomerInfo.billingLocation.address";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_CITY = "pxyCustomerInfo.billingLocation.city";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_STATE = "pxyCustomerInfo.billingLocation.state";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_ZIPCODE = "pxyCustomerInfo.billingLocation.zipCode";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_COUNTRY = "pxyCustomerInfo.billingLocation.country";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_PHONENUMBER = "pxyCustomerInfo.billingLocation.phoneNumber";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_FAX = "pxyCustomerInfo.billingLocation.fax";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_TAX1 = "pxyCustomerInfo.billingLocation.tax1";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_TAX2 = "pxyCustomerInfo.billingLocation.tax2";
  private static final String PXYPARAM_PXY_CUSTINFO_BILLADDR_TAX3 = "pxyCustomerInfo.billingLocation.tax3";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_FIRSTNAME = "pxyCustomerInfo.shippingLocation.firstName";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_LASTNAME = "pxyCustomerInfo.shippingLocation.lastName";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_COMPANYNAME = "pxyCustomerInfo.shippingLocation.companyName";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_ADDRESS = "pxyCustomerInfo.shippingLocation.address";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_CITY = "pxyCustomerInfo.shippingLocation.city";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_STATE = "pxyCustomerInfo.shippingLocation.state";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_ZIPCODE = "pxyCustomerInfo.shippingLocation.zipCode";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_COUNTRY = "pxyCustomerInfo.shippingLocation.country";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_PHONENUMBER = "pxyCustomerInfo.shippingLocation.phoneNumber";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_FAX = "pxyCustomerInfo.shippingLocation.fax";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_TAX1 = "pxyCustomerInfo.shippingLocation.tax1";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_TAX2 = "pxyCustomerInfo.shippingLocation.tax2";
  private static final String PXYPARAM_PXY_CUSTINFO_SHIPADDR_TAX3 = "pxyCustomerInfo.shippingLocation.tax3";
  private static final String PXYPARAM_PXY_ORDER_INVNUM = "pxyOrder.invoiceNumber";
  private static final String PXYPARAM_PXY_ORDER_DESC = "pxyOrder.description";
  private static final String PXYPARAM_PXY_ORDER_TOTALAMT = "pxyOrder.totalAmount";
  private static final String PXYPARAM_PXY_ORDER_SHIPPINGAMT = "pxyOrder.shippingAmount";
  private static final String PXYPARAM_PXY_ORDER_ORDERITEMS = "pxyOrder.orderItems[";
  private static final String PXYPARAM_PXY_ORDER_ORDERITEM_ID = "].itemId";
  private static final String PXYPARAM_PXY_ORDER_ORDERITEM_NAME = "].itemName";
  private static final String PXYPARAM_PXY_ORDER_ORDERITEM_DESC = "].itemDescription";
  private static final String PXYPARAM_PXY_ORDER_ORDERITEM_QTY = "].itemQuantity";
  private static final String PXYPARAM_PXY_ORDER_ORDERITEM_PRICE = "].itemPrice";
  private static final String PXYPARAM_PXY_ORDER_ORDERITEM_TAXABLE = "].itemTaxable";
  private static final String PXYRESP_CALL_STATUS = "status";
  private static final String PXYRESP_RESPONSE_STATUS = "pxyResponse.responseStatus";
  private static final String PXYRESP_PROCESSOR_REFID = "pxyResponse.processorRefId";
  private static final String PXYRESP_RESPSTATUS_NAME = "pxyResponse.responseStatus.name";
  private static final String PXYRESP_RESPSTATUS_CODE = "pxyResponse.responseStatus.code";
  private static final String PXYRESP_RESPSTATUS_DESCRIPTION = "pxyResponse.responseStatus.description";
  private static final String PXYRESP_CALL_STATUS_SUCCESS = "success";
  private static final String PXYRESP_CALL_STATUS_ERROR = "error";
  private static final String PXYRESP_CALL_ERRID = "errId";
  private static final String PXYRESP_CALL_ERRMSG = "errMsg";
  private static final String PXYRESP_RESPONSE_STATUS_APPROVED = "approved";
  private static final String PXYRESP_RESPONSE_STATUS_DECLINED = "declined";
  private static final String PXYRESP_RESPONSE_STATUS_ERROR = "error";
  private static final String PXYRESP_RESPONSE_STATUS_REVIEW = "review";
  // define constructor
  public ProxyHPCIProcessorApp() {
    logMessage("Init proxy processor");
  }
  public static void logMessage(String msg) {
    System.out.println(msg);
  }
  public static String callUrl(String urlString, Map paramMap) {
    String urlReturnValue = "";
    try {
      // Construct data
      StringBuffer dataBuf = new StringBuffer();
      boolean firstParam = true;
      for (String paramKey : paramMap.keySet()) {
        if (!firstParam) dataBuf.append("&");
        dataBuf.append(URLEncoder.encode(paramKey, "UTF-8")).append("=")
        .append(URLEncoder.encode(paramMap.get(paramKey), "UTF-8"));
        firstParam = false;
      }
      String data = dataBuf.toString();
      // Send data
      URL url = new URL(urlString);
      URLConnection conn = url.openConnection();
      conn.setDoOutput(true);
      OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
      wr.write(data);
      wr.flush();
      // Get the response
      BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
      String line;
      wh ile ((line = rd.readLine()) != null) {
        urlReturnValue = urlReturnValue + line;
      }
      wr.close();
      rd.close();
    } catch (Exception e) {
      e.printStackTrace();
      urlReturnValue = "";
    }
    return urlReturnValue;
  } //END: callUrl
  public static Map parseQueryString(String queryStr) {
    Map map = new HashMap();
    if (queryStr == null)
      return map;
    String[] params = queryStr.split("&");
    for (String param : params) {
      String name = "";
      String value = "";
      String[] paramPair = param.split("=");
      if (paramPair != null && paramPair.length > 0) {
        name = paramPair[0];
        if (paramPair.length > 1 && paramPair[1] != null) {
          try {
            value = URLDecoder.decode(paramPair[1], "UTF-8");
          } catch (UnsupportedEncodingException e) {
            logMessage("Could not decode:" + paramPair[1]);
          }
        }
      }
      map.put(name, value);
    }
    return map;
  } //END: parseQueryString
  private String amountToAuthStr = "4.25";
  public String authOnly(String serviceUrl, String userName, String passKey, String mappedCCNum, String merchatTxnRef) throws Exception {
    // if the authorization request id
    String resultCode = "";
    logMessage("amountToAuthStr:" + amountToAuthStr);
    // make the remote call
    String callUrl = serviceUrl + PXY_AUTH;
    // prepare the mapped month and year
    Map paramMap = new HashMap();
    paramMap.put(PXYPARAM_APIVERSION, "1.0.1");
    paramMap.put(PXYPARAM_APITYPE, PXYPARAM_APITYPE_PXYHPCI);
    paramMap.put(PXYPARAM_USERNAME, userName);
    paramMap.put(PXYPARAM_USERPASSKEY, passKey);
    paramMap.put(PXYPARAM_PXY_CC_CARDTYPE, "visa");
    paramMap.put(PXYPARAM_PXY_CC_NUMBER, mappedCCNum);
    paramMap.put(PXYPARAM_PXY_CC_EXPMONTH, "10");
    paramMap.put(PXYPARAM_PXY_CC_EXPYEAR, "2014");
    paramMap.put(PXYPARAM_PXY_CC_CVV, "123");
    paramMap.put(PXYPARAM_PXY_TRANSACTION_AMOUNT, amountToAuthStr);
    paramMap.put(PXYPARAM_PXY_TRANSACTION_CUSISO, "USD");
    paramMap.put(PXYPARAM_PXY_TRANSACTION_MER_REFID, "merRef:" + merchatTxnRef);
    paramMap.put(PXYPARAM_PXY_CUSTINFO_EMAIL, "hpcitest1@mailinator.com");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_CUSTOMERID, "hpcitest1");
    // setup addresses
    paramMap.put(PXYPARAM_PXY_CUSTINFO_BILLADDR_FIRSTNAME, "FirstName");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_BILLADDR_LASTNAME, "LastName");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_BILLADDR_ADDRESS, "123 Elm Street");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_BILLADDR_CITY, "Beverly Hills");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_BILLADDR_STATE, "CA");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_BILLADDR_ZIPCODE, "90210");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_BILLADDR_COUNTRY, "US");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_SHIPADDR_FIRSTNAME, "FirstName");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_SHIPADDR_LASTNAME, "LastName");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_SHIPADDR_ADDRESS, "123 Elm Street");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_SHIPADDR_CITY, "Beverly Hills");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_SHIPADDR_STATE, "CA");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_SHIPADDR_ZIPCODE, "90210");
    paramMap.put(PXYPARAM_PXY_CUSTINFO_SHIPADDR_COUNTRY, "US");
    // following are optional parameters
    paramMap.put(PXYPARAM_PXY_CUSTINFO_CUSTIP, "173.32.21.248");
    paramMap.put(PXYPARAM_PXY_ORDER_INVNUM, "Order:" + merchatTxnRef);
    paramMap.put(PXYPARAM_PXY_ORDER_DESC, "Test Order");
    paramMap.put(PXYPARAM_PXY_ORDER_TOTALAMT, amountToAuthStr);
    // paramMap.put(PXYPARAM_PXY_ORDER_SHIPPINGAMT, "1.00");
    // item 1
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "0" + PXYPARAM_PXY_ORDER_ORDERITEM_ID, "Item-1-" + merchatTxnRef);
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "0" + PXYPARAM_PXY_ORDER_ORDERITEM_NAME, "Item-Name1");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "0" + PXYPARAM_PXY_ORDER_ORDERITEM_DESC, "Item Description 1");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "0" + PXYPARAM_PXY_ORDER_ORDERITEM_QTY, "1");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "0" + PXYPARAM_PXY_ORDER_ORDERITEM_PRICE, "2.00");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "0" + PXYPARAM_PXY_ORDER_ORDERITEM_TAXABLE, "N"); // Y/N
    // item 2
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "1" + PXYPARAM_PXY_ORDER_ORDERITEM_ID, "Item-2-" + merchatTxnRef);
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "1" + PXYPARAM_PXY_ORDER_ORDERITEM_NAME, "Item-Name2");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "1" + PXYPARAM_PXY_ORDER_ORDERITEM_DESC, "Item Description 2");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "1" + PXYPARAM_PXY_ORDER_ORDERITEM_QTY, "1");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "1" + PXYPARAM_PXY_ORDER_ORDERITEM_PRICE, "1.25");
    paramMap.put(PXYPARAM_PXY_ORDER_ORDERITEMS + "1" + PXYPARAM_PXY_ORDER_ORDERITEM_TAXABLE, "N"); // Y/N
    logMessage("Make the call: " + callUrl);
    String callResult = callUrl(callUrl, paramMap);
    logMessage("Call result:" + callResult);
    // parse the url encoded key value pairs
    Map resultMap = parseQueryString(callResult);
    // get the network call status
    String callStatus = resultMap.get(PXYRESP_CALL_STATUS);
    // get the payment processing status
    String paymentStatus = resultMap.get(PXYRESP_RESPONSE_STATUS);
    String processorRefId = null;
    if (callStatus != null && callStatus.equals(PXYRESP_CALL_STATUS_SUCCESS)
    && paymentStatus != null && paymentStatus.equals(PXYRESP_RESPONSE_STATUS_APPROVED)) {
      logMessage("Successful transaction");
      processorRefId = resultMap.get(PXYRESP_PROCESSOR_REFID);
      logMessage("Auth Processor Ref Id:" + processorRefId);
    }
    else {
      logMessage("Unsuccessful transaction");
      resultCode = paymentStatus;
      String statusCode = resultMap.get(PXYRESP_RESPSTATUS_CODE);
      String statusName = resultMap.get(PXYRESP_RESPSTATUS_NAME);
      String statusDesc = resultMap.get(PXYRESP_RESPSTATUS_DESCRIPTION);
      logMessage("Auth Status Code:" + statusCode);
      logMessage("Auth Status Name:" + statusName);
      logMessage("Auth Status Desc:" + statusDesc);
    }
    return processorRefId;
  }
  public void captureOnly(String serviceUrl, String userName, String passKey, String authProcessorRefId, String merchatTxnRef) throws Exception {
    // get the auth to capture
   // make the remote call
   String callUrl = serviceUrl + PXY_CAPTURE;
   Map paramMap = new HashMap();
   paramMap.put(PXYPARAM_APIVERSION, "1.0.1");
   paramMap.put(PXYPARAM_APITYPE, PXYPARAM_APITYPE_PXYHPCI);
   paramMap.put(PXYPARAM_USERNAME, userName);
   paramMap.put(PXYPARAM_USERPASSKEY, passKey);
   // format amount
   paramMap.put(PXYPARAM_PXY_TRANSACTION_AMOUNT, amountToAuthStr);
   paramMap.put(PXYPARAM_PXY_TRANSACTION_CUSISO, "USD");
   paramMap.put(PXYPARAM_PXY_TRANSACTION_MER_REFID, "merRef:" + merchatTxnRef);
   paramMap.put(PXYPARAM_PXY_TRANSACTION_PROCESSOR_REFID, authProcessorRefId);
   logMessage("Make the call: " + callUrl);
   String callResult = callUrl(callUrl, paramMap);
   logMessage("Call result:" + callResult);
   // parse the url encoded key value pairs
   Map resultMap = parseQueryString(callResult);
   // get the network call status
   String callStatus = resultMap.get(PXYRESP_CALL_STATUS);
   // get the payment processing status
   String paymentStatus = resultMap.get(PXYRESP_RESPONSE_STATUS);
   if (callStatus != null && callStatus.equals(PXYRESP_CALL_STATUS_SUCCESS)
   && paymentStatus != null && paymentStatus.equals(PXYRESP_RESPONSE_STATUS_APPROVED)) {
     logMessage("Successful transaction");
     String processorRefId = resultMap.get(PXYRESP_PROCESSOR_REFID);
     logMessage("Capture Processor Ref Id:" + processorRefId);
    }
    else {
      logMessage("Unsuccessful transaction");
      String statusCode = resultMap.get(PXYRESP_RESPSTATUS_CODE);
      String statusName = resultMap.get(PXYRESP_RESPSTATUS_NAME);
      String statusDesc = resultMap.get(PXYRESP_RESPSTATUS_DESCRIPTION);
      logMessage("Capture Status Code:" + statusCode);
      logMessage("Capture Status Name:" + statusName);
      logMessage("Capture Status Desc:" + statusDesc);
    }
  }
  public void voidOnly(String serviceUrl, String userName, String passKey, String authProcessorRefId, String merchatTxnRef) throws Exception {
    // get the auth to capture
    // make the remote call
    String callUrl = serviceUrl + PXY_VOID;
    Map paramMap = new HashMap();
    paramMap.put(PXYPARAM_APIVERSION, "1.0.1");
    paramMap.put(PXYPARAM_APITYPE, PXYPARAM_APITYPE_PXYHPCI);
    paramMap.put(PXYPARAM_USERNAME, userName);
    paramMap.put(PXYPARAM_USERPASSKEY, passKey);
    // format amount
    paramMap.put(PXYPARAM_PXY_TRANSACTION_AMOUNT, amountToAuthStr);
    paramMap.put(PXYPARAM_PXY_TRANSACTION_CUSISO, "USD");
    paramMap.put(PXYPARAM_PXY_TRANSACTION_MER_REFID, "merRef:" + merchatTxnRef);
    paramMap.put(PXYPARAM_PXY_TRANSACTION_PROCESSOR_REFID, authProcessorRefId);
    logMessage("Make the call: " + callUrl);
    String callResult = callUrl(callUrl, paramMap);
    logMessage("Call result:" + callResult);
    // parse the url encoded key value pairs
    Map resultMap = parseQueryString(callResult);
    // get the network call status
    String callStatus = resultMap.get(PXYRESP_CALL_STATUS);
    // get the payment processing status
    String paymentStatus = resultMap.get(PXYRESP_RESPONSE_STATUS);
    if (callStatus != null && callStatus.equals(PXYRESP_CALL_STATUS_SUCCESS)
    && paymentStatus != null && paymentStatus.equals(PXYRESP_RESPONSE_STATUS_APPROVED)) {
      logMessage("Successful transaction");
      String processorRefId = resultMap.get(PXYRESP_PROCESSOR_REFID);
      logMessage("Void Processor Ref Id:" + processorRefId);
    }
    else {
      logMessage("Unsuccessful transaction");
      String statusCode = resultMap.get(PXYRESP_RESPSTATUS_CODE);
      String statusName = resultMap.get(PXYRESP_RESPSTATUS_NAME);
      String statusDesc = resultMap.get(PXYRESP_RESPSTATUS_DESCRIPTION);
      logMessage("Void Status Code:" + statusCode);
      logMessage("Void Status Name:" + statusName);
      logMessage("Void Status Desc:" + statusDesc);
    }
  }
  public void creditOnly(String serviceUrl, String userName, String passKey, String captureProcessorRefId, String merchatTxnRef) throws Exception {
    // get the auth to capture
    // make the remote call
    String callUrl = serviceUrl + PXY_CREDIT;
    Map paramMap = new HashMap();
    paramMap.put(PXYPARAM_APIVERSION, "1.0.1");
    paramMap.put(PXYPARAM_APITYPE, PXYPARAM_APITYPE_PXYHPCI);
    paramMap.put(PXYPARAM_USERNAME, userName);
    paramMap.put(PXYPARAM_USERPASSKEY, passKey);
    // format amount
    paramMap.put(PXYPARAM_PXY_TRANSACTION_AMOUNT, amountToAuthStr);
    paramMap.put(PXYPARAM_PXY_TRANSACTION_CUSISO, "USD");
    paramMap.put(PXYPARAM_PXY_TRANSACTION_MER_REFID, "merRef:" + merchatTxnRef);
    paramMap.put(PXYPARAM_PXY_TRANSACTION_PROCESSOR_REFID, captureProcessorRefId);
    logMessage("Make the call: " + callUrl);
    String callResult = callUrl(callUrl, paramMap);
    logMessage("Call result:" + callResult);
    // parse the url encoded key value pairs
    Map resultMap = parseQueryString(callResult);
    // get the network call status
    String callStatus = resultMap.get(PXYRESP_CALL_STATUS);
    // get the payment processing status
    String paymentStatus = resultMap.get(PXYRESP_RESPONSE_STATUS);
    if (callStatus != null && callStatus.equals(PXYRESP_CALL_STATUS_SUCCESS)
    && paymentStatus != null && paymentStatus.equals(PXYRESP_RESPONSE_STATUS_APPROVED)) {
      logMessage("Successful transaction");
      String processorRefId = resultMap.get(PXYRESP_PROCESSOR_REFID);
      logMessage("Credit Processor Ref Id:" + processorRefId);
    }
    else {
      logMessage("Unsuccessful transaction");
      String statusCode = resultMap.get(PXYRESP_RESPSTATUS_CODE);
      String statusName = resultMap.get(PXYRESP_RESPSTATUS_NAME);
      String statusDesc = resultMap.get(PXYRESP_RESPSTATUS_DESCRIPTION);
      logMessage("Credit Status Code:" + statusCode);
      logMessage("Credit Status Name:" + statusName);
      logMessage("Credit Status Desc:" + statusDesc);
    }
  }
  public static void main(String[] args) throws Exception {
    // define usage string
    String baseUsageStr = " mode[auth_capture | auth_void | credit] serviceUrl userName passKey merchatTxnRef ";
    // make sure all the parameters are present
    if (args.length < 1) {
      logMessage("Usage: java " + ProxyHPCIProcessorApp.class.getName() + baseUsageStr + " mappedCCNum");
      return;
    }
    String mode = args[0];
    if (mode.equals("auth_capture")) {
      if (args.length < 6) {
        logMessage("Usage: java " + ProxyHPCIProcessorApp.class.getName() + baseUsageStr + " mappedCCNum");
        return;
      }
      String serviceUrl = args[1];
      String userName = args[2];
      String passKey = args[3];
      String merchatTxnRef = args[4];
      String mappedCCNum = args[5];
      ProxyHPCIProcessorApp app = new ProxyHPCIProcessorApp();
      String processorRefId = app.authOnly(serviceUrl, userName, passKey, mappedCCNum, merchatTxnRef);
      if (processorRefId != null) {
        app.captureOnly(serviceUrl, userName, passKey, processorRefId, merchatTxnRef);
      }
      logMessage("Operation complete:" + mode);
    }
    else if (mode.equals("auth_void")) {
      if (args.length < 6) {
        logMessage("Usage: java " + ProxyHPCIProcessorApp.class.getName() + baseUsageStr + " mappedCCNum");
        return;
      }
      String serviceUrl = args[1];
      String userName = args[2];
      String passKey = args[3];
      String merchatTxnRef = args[4];
      String mappedCCNum = args[5];
      ProxyHPCIProcessorApp app = new ProxyHPCIProcessorApp();
      String processorRefId = app.authOnly(serviceUrl, userName, passKey, mappedCCNum, merchatTxnRef);
      if (processorRefId != null) {
        app.voidOnly(serviceUrl, userName, passKey, processorRefId, merchatTxnRef);
      }
      logMessage("Operation complete:" + mode);
    }
    else if (mode.equals("credit")) {
      if (args.length < 6) {
        logMessage("Usage: java " + ProxyHPCIProcessorApp.class.getName() + baseUsageStr + " captureTxnRef");
        return;
      }
      String serviceUrl = args[1];
      String userName = args[2];
      String passKey = args[3];
      String merchatTxnRef = args[4];
      String captureTxnRef = args[5];
      ProxyHPCIProcessorApp app = new ProxyHPCIProcessorApp();
      app.creditOnly(serviceUrl, userName, passKey, captureTxnRef, merchatTxnRef);
      logMessage("Operation complete:" + mode);
    }
    else {
      logMessage("Unknown mode:" + mode);
    }
  }
}