com.ibm.etill.kitcashcassette.test.card
Class KitCashDriver

java.lang.Object
  |
  +--com.ibm.etill.kitcashcassette.test.card.KitCashDriver

public class KitCashDriver
extends java.lang.Object

KitCash is a cash based internet payment protocol. Cash is stored on a 'KitCash card' and can be transferred from one KitCash card to another. All parties (consumers, merchants and banks) will have at least one KitCash card of their own.

A KitCashDriver object allows Java code to access an imitation KitCash card. No special hardware is required in order to run this sample cassette and test harness. Instead, the balance and card number of the KitCash card are stored as instance variables of KitCashDriver objects.

To start or receive a payment, you must use a KitCashTransaction object which is returned as a result of initializing the driver. Each payment consists of a number of message flows going between the payer and the receiver.

To make a payment with a KitCashDriver, you should write code as follows:

   KitCashDriver driver = new KitCashDriver(1000);  // construct a new driver with $10.00 on it
   KitCashTransaction trans = driver.init();        // initialize the driver and retrieve a transaction object
   KitCashMessage msg = trans.pay(20);              // tell the card to start a payment for $0.20

   // keep going until the KitCash card says no more messages need be sent to the receiver
   while ((msg != null) && msg.toBeForwarded()) {
     // wrap the message in a MIME message and send it to another KitCash card
     KitCashMessageWrapper request = new KitCashMessageWrapper("Merchant xxx", "Order no yyy", msg);
     KitCashMessageWrapper response = wrapper.getResponse(merchantHostName, merchantPortNumber);

     msg = response.getContents();                  // retrieve the KitCash message from the MIME wrapper
     msg = trans.processMsg(msg);                   // get the next request message from the KitCash card
   }
 

See Also:
KitCashTransaction, KitCashMessage, KitCashMessageWrapper

Constructor Summary
KitCashDriver()
          Constructs a new KitCash driver for a KitCash card with no money in it
KitCashDriver(int b)
          Constructs a new KitCash driver for a KitCash card with the given amount in it
 
Method Summary
 int getBalance()
          Read balance information from the KitCash CardWallet applet
 byte getCardNumber(int i)
          Returns the ID of the KitCash card
 KitCashTransaction init()
          Initializes the KitCash card driver
static java.lang.String text(java.lang.String textID)
          Returns the internationalized text for the given ID from the KitCashWallet.properties file.
static java.lang.String text(java.lang.String textID, java.lang.String[] parms)
          Returns the internationalized text for the given ID from the KitCashWallet.properties file and inserts the given parameters into the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KitCashDriver

public KitCashDriver()
Constructs a new KitCash driver for a KitCash card with no money in it

KitCashDriver

public KitCashDriver(int b)
Constructs a new KitCash driver for a KitCash card with the given amount in it
Parameters:
b - the new balance (in cents) of the KitCash card
Method Detail

getBalance

public int getBalance()
Read balance information from the KitCash CardWallet applet

getCardNumber

public byte getCardNumber(int i)
Returns the ID of the KitCash card

init

public KitCashTransaction init()
Initializes the KitCash card driver
Returns:
a new KitCashTransaction

text

public static java.lang.String text(java.lang.String textID)
Returns the internationalized text for the given ID from the KitCashWallet.properties file.
Parameters:
textID - the code to lookup up the in the properties file
Returns:
internationalized text for the given textID

text

public static java.lang.String text(java.lang.String textID,
                                    java.lang.String[] parms)
Returns the internationalized text for the given ID from the KitCashWallet.properties file and inserts the given parameters into the result.
Parameters:
textID - the code to lookup up the in the properties file
parms - the parameters strings to insert into the internationalized message
Returns:
internationalized text for the given textID