Skip to main content

Memoirs of eXtreme DragonSlayers, Part 15

Payday: Payment processing with IBM WebSphere Commerce products

Return to article


Java Application to run against the server
import com.ibm.etill.framework.clientapi.*;
import java.util.*;
import java.io.*;
import java.net.*;


public class AcceptPayment implements IAcceptPayment, PaymentCommandConstants
{


  public void makePmt( String pan, String brand, String expiry, String street, String city, String state, String zipcode )
    {
    String paymentServerHost = "localhost";   // payment server is on the same machine
    int paymentServerPort = 80;               // standard WebServer HTTP port
    String dtdPath = null;                    // use embedded DTD
    String userid = "admin";                  // use the predefined "admin" userid
    String password = "admin";                // assume the "admin" userid has default password
    
 
    String paymentType = "OfflineCard";
    String merchantNumber = "10001";
    String orderNumber = Integer.toString((int) (System.currentTimeMillis() & 0x0fffffff));
    Integer amount = new Integer(5000);
    Integer currency = new Integer(840);
    String orderURL = "http://9.3.99.91/ordermanager";
    String country = "USA";

    PaymentServerClient server = null;

    try
      {

        server = new PaymentServerClient(dtdPath,paymentServerHost,paymentServerPort);
        
        
        Hashtable pairs = new Hashtable();
        pairs.put(KEY_PAYMENTTYPE,paymentType);
        pairs.put(KEY_MERCHANTNUMBER,merchantNumber);
        pairs.put(KEY_ORDERNUMBER,orderNumber);
        pairs.put(KEY_AMOUNT,amount);
        pairs.put(KEY_CURRENCY,currency);
        pairs.put(KEY_ORDERURL,orderURL);
        pairs.put("$PAN",pan);
        pairs.put("$BRAND",brand);
        pairs.put("$EXPIRY",expiry);
        pairs.put(PD_AVS_STREETADDRESS,street);
        pairs.put(PD_AVS_CITY,city);
        pairs.put(PD_AVS_STATEPROVINCE,state);
        pairs.put(PD_AVS_POSTALCODE,zipcode);
        pairs.put(PD_AVS_COUNTRYCODE,country);
        
        
        PaymentServerResponse response = server.issueCommand(OP_ACCEPTPAYMENT,pairs,userid,password);
        
        
        System.out.println("Primary RC  : " + response.getPrimaryRC());
        System.out.println("Secondary RC: " + response.getSecondaryRC());
        System.out.println("Buyer Message: " + response.getBuyerMessage());
	System.out.println("Merchant Message: " + response.getMerchantMessage());
      }
    catch (PaymentServerAuthorizationException e)
      {
        System.out.println(e.toString());
        e.printStackTrace();
      }
    catch (PaymentServerCommunicationException e)
      {
        System.out.println(e.toString());
        e.printStackTrace();
      }
    catch (PaymentServerClientException e)
      {
        System.out.println(e.toString());
        e.printStackTrace();
      }
    finally
      {
        if (server != null) try { server.close(); } catch (IOException e) { }
      }


    return; 

    }
}


Return to article