KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > lp > samples > MULTIPLE


1 /*****************************************************************************
2 ' Copyright 2003 LinkPoint International, Inc. All Rights Reserved.
3 '
4 ' This software is the proprietary information of LinkPoint International, Inc.
5 ' Use is subject to license terms.
6 '
7 '******************************************************************************/

8 package lp.samples;
9 import lp.order.*;
10 /**
11  * <p>Title: </p>
12  * <p>Description: </p>
13  * <p>Copyright: Copyright (c) 2003</p>
14  * <p>Company: LinkPoint International</p>
15  * @author Sergey Chudnovsky
16  * @version 1.0
17  */

18
19 public class MULTIPLE extends JLinkPointSample {
20
21 // This sample demonstrates running an array of PREAUTH transactions.
22
//
23
// This could equally well be a series of POSTAUTHS or RETURNS if the
24
// OIDs match those previously approved.
25

26   // Definition of an array of transactions specific data.
27
// For minimal transaction we use following fields:
28
// 1 TOTAL,
29
// 2 CREDIT CARD NUMBER
30
// 3 CREDIT CARD EXP. MONTH
31
// 4 CREDIT CARD EXP. YEAR
32
// Next two are required for AVS. If not provided
33
// transaction will dongrade
34
// 5 ADDRESS NUMBERS
35
// 6 ZIP
36
String JavaDoc orders[][]= { {"1.11","4111-1111-1111-1111","01","04","123","12345"},
37                          {"2.22","4111-1111-1111-1111","02","05","234","23456"},
38                          {"3.33","4111-1111-1111-1111","03","06","345","34567"}};
39
40   public MULTIPLE() {
41   }
42
43   public boolean process()
44   {
45     // Assign common fields for all transactions
46
// 1.1 'orderoptions'
47
op.put("ordertype","PREAUTH");
48          op.put("result","GOOD");
49      // add 'orderoptions to order
50
order.addPart("orderoptions", op );
51          // 1.2 'merchantinfo'
52
op.clear();
53          op.put("configfile",configfile);
54      // add 'merchantinfo to order
55
order.addPart("merchantinfo", op );
56
57      for ( idxTxn=0; idxTxn<3; idxTxn++)
58      {
59       // this will call back to getOrderXML()
60
super.process();
61      }
62
63   return true;
64   }
65   protected String JavaDoc getOrderXML() {
66     // Add transaction specific fields
67

68     // Build 'billing'
69
// Required for AVS. If not provided,
70
// transactions will downgrade.
71
op.clear();
72     op.put("zip",orders[idxTxn][5]);
73     op.put("addrnum",orders[idxTxn][4]);
74     // add 'billing to order
75
order.addPart("billing", op );
76
77     // Build 'creditcard'
78
op.clear();
79     op.put("cardnumber",orders[idxTxn][1]);
80     op.put("cardexpmonth",orders[idxTxn][2]);
81     op.put("cardexpyear",orders[idxTxn][3]);
82     // add 'creditcard to order
83
order.addPart("creditcard", op );
84
85      // Build 'payment'
86
op.clear();
87     op.put("chargetotal",orders[idxTxn][0]);
88     // add 'payment to order
89
order.addPart("payment", op );
90
91  return order.toXML();
92 }
93
94   // Create an empty order
95
private LPOrderPart order = LPOrderFactory.createOrderPart("order");
96  // Create a part we will use to build the order
97
private LPOrderPart op = LPOrderFactory.createOrderPart();
98  // Keep current transaction num
99
private int idxTxn=0;
100 }
Popular Tags