Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

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