FileDocCategorySizeDatePackage
Client.javaAPI DocExample1514Sun Mar 07 08:57:20 GMT 1999com.titan.processpayment

Client

public class Client extends Object

Fields Summary
Constructors Summary
Methods Summary
public static javax.naming.ContextgetInitialContext()

   Properties p = new Properties();
    // ... specify the JNDI properties specific to the vendor
   return new InitialContext(p);
 
public static voidmain(java.lang.String[] agrs)

    try{
        Context ctx = getInitialContext();

        CustomerHome ch = (CustomerHome)getInitialContext().lookup("CustomerHome");
        CustomerPK pk = new CustomerPK();
        pk.id = 1;
        Customer customer = ch.findByPrimaryKey(pk);

        ProcessPaymentHome home = (ProcessPaymentHome)ctx.lookup("ProcessPaymentHome");
        ProcessPayment p = home.create( );
        boolean b;
        java.util.GregorianCalendar calendar = new java.util.GregorianCalendar();
        calendar.add(java.util.GregorianCalendar.DAY_OF_YEAR,1);
        CreditCard card = new CreditCard(4029302, calendar.getTime(), CreditCard.VISA);
        try{
        b = p.byCredit(customer,card, 7400.00);
        System.out.println(b);
        }catch(PaymentException pe){
        pe.printStackTrace();
        }
        b = p.byCash(customer,774.00);
        System.out.println(b);
        Check check = new Check("8374938-48384",100);
        b = p.byCheck(customer, check, 8438.09);
        System.out.println(b);
        }catch(Exception e){e.printStackTrace();}