KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > lp > samples > JLinkPointXMLSamples


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
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 JLinkPointXMLSamples extends JLinkPointSample {
20
21   public static void main(String JavaDoc[] args) {
22
23
24     JLinkPointXMLSamples smpl = new JLinkPointXMLSamples();
25
26     System.out.println("\n*****************************************************");
27     System.out.println("Credit Card SALE With Minimum Fields required for AVS");
28     System.out.println("and Card Code fraud prevention measures ");
29     System.out.println("******************************************************");
30     smpl.setXML(XMLSampleData.AVS_CVM);
31     smpl.process();
32
33
34
35     System.out.println("\n*****************************************************");
36     System.out.println("Minimum Required Fields for a FORCED TICKET Transaction");
37     System.out.println("*****************************************************");
38     smpl.setXML(XMLSampleData.FORCED_TICKET);
39     smpl.process();
40
41     System.out.println("\n**********************************************************");
42     System.out.println("Required Fields for Credit Card SALE with ITEMS Transaction");
43     System.out.println( "**********************************************************");
44     smpl.setXML(XMLSampleData.ITEMS_W_ESD);
45     smpl.process();
46
47     System.out.println("\n**********************************************************");
48     System.out.println("An Example Level 2 Purchasing Card SALE Transaction");
49     System.out.println( "**********************************************************");
50     smpl.setXML(XMLSampleData.L2PURCHASING_CARD);
51     smpl.process();
52
53
54     System.out.println("\n**********************************************************");
55     System.out.println("Minimum Required Fields for a Credit Card CREDIT Transaction");
56     System.out.println( "**********************************************************");
57     smpl.setXML(XMLSampleData.RETURN);
58     smpl.process();
59
60
61     System.out.println("\n**********************************************************");
62     System.out.println("An Example Credit Card SALE with all commonly used fields included");
63     System.out.println( "**********************************************************");
64     smpl.setXML(XMLSampleData.SALE_MAXINFO);
65     smpl.process();
66
67
68     System.out.println("\n**********************************************************");
69     System.out.println("Minimum Required Fields for a Credit Card SALE");
70     System.out.println( "**********************************************************");
71     smpl.setXML(XMLSampleData.SALE_MININFO);
72     smpl.process();
73
74     System.out.println("\n**********************************************************");
75     System.out.println("An Example of Shipping Calculation Transaction");
76     System.out.println( "**********************************************************");
77     smpl.setXML(XMLSampleData.SHIPPING);
78     smpl.process();
79
80
81     System.out.println("\n**********************************************************");
82     System.out.println("An Example of Tax Calculation Transaction");
83     System.out.println( "**********************************************************");
84     smpl.setXML(XMLSampleData.TAX);
85     smpl.process();
86
87
88     System.out.println("\n**********************************************************");
89     System.out.println("An Example of PreAuth/PostAuth/Void Credit Card Transactions");
90     System.out.println("**********************************************************");
91     System.out.println("\nFirst run PREAUTH transaction:");
92
93     smpl.setXML(XMLSampleData.PREAUTH);
94     smpl.process();
95
96     if( smpl.R_Error.length() == 0)
97     {
98     System.out.println("\nNow run POSTAUTH using 'oid' recieved as r_order");
99     System.out.println("from PREAUTH transaction");
100
101     smpl.setXML(smpl.patchXML_OID(XMLSampleData.POSTAUTH));
102     smpl.process();
103     }
104
105     if( smpl.R_Error.length() == 0)
106     {
107     System.out.println("\nNow VOID transaction using its 'oid' ");
108     smpl.setXML(smpl.patchXML_OID(XMLSampleData.VOID));
109     smpl.process();
110     }
111
112     System.out.println("\n**********************************************************");
113     System.out.println("An Example of Periodic Billing Transactions");
114     System.out.println("**********************************************************");
115     System.out.println("\nFirst create new PB (with minimum required fields ):");
116
117     smpl.setXML(XMLSampleData.PB_NEW);
118     smpl.process();
119
120     if( smpl.R_Error.length() == 0)
121     {
122     System.out.println("\nNow change existing PB using 'oid' recieved as r_ordernum");
123     System.out.println("from previous transaction");
124     smpl.setXML(smpl.patchXML_OID(XMLSampleData.PB_MODIFY));
125     smpl.process();
126     }
127
128     if( smpl.R_Error.length() == 0)
129      {
130      System.out.println("\nNow we cancel existing PB using its 'oid'");
131      smpl.setXML(smpl.patchXML_OID(XMLSampleData.PB_CANCEL));
132      smpl.process();
133      }
134
135      System.out.println("\n**********************************************************");
136      System.out.println("An Example of VirtualCheck Transactions");
137      System.out.println("**********************************************************");
138      System.out.println("\nFirst, run VirtualCheck SALE transaction (with minimum required fields");
139
140      smpl.setXML(XMLSampleData.VCHECK_SALE);
141      smpl.process();
142
143      if( smpl.R_Error.length() == 0)
144      {
145      System.out.println("\nNow void the sale using its 'oid' recieved as r_ordernum");
146      System.out.println("from previous transaction");
147      smpl.setXML(smpl.patchXML_OID(XMLSampleData.VCHECK_VOID));
148      smpl.process();
149      }
150
151      System.out.println("\n**********************************************************");
152      System.out.println("An Example of Retail Keyed Credit Card SALE");
153      System.out.println("**********************************************************");
154      smpl.setXML(XMLSampleData.RETAIL_KEYED);
155      smpl.process();
156
157      System.out.println("\n**********************************************************");
158      System.out.println("An Example of Retail Credit Card SALE with partial AVS");
159      System.out.println("**********************************************************");
160      smpl.setXML(XMLSampleData.RETAIL_PARTIAL_AVS);
161      smpl.process();
162
163      System.out.println("\n**********************************************************");
164      System.out.println("An Example of Retail Swipe Credit Card SALE");
165      System.out.println("**********************************************************");
166      smpl.setXML(XMLSampleData.RETAIL_SWIPE);
167      smpl.process();
168
169   }
170
171  //
172
//
173
//
174
//
175

176   public void setXML(String JavaDoc xml)
177   {
178   sXML = setXML_Configfile(xml);
179   }
180   public String JavaDoc setXML_Configfile(String JavaDoc xml)
181   {
182   return replaceTagValue(xml,"<configfile>",configfile);
183   }
184   public String JavaDoc patchXML_OID(String JavaDoc xml)
185   {
186 /*
187     StringBuffer sb = new StringBuffer(1024);
188     String tag ="<oid>";
189     int idx = xml.indexOf(tag);
190     if( idx == -1 ) { return xml; }
191
192     sb.append(xml.substring(0,idx+tag.length()));
193     sb.append(R_OrderNum);
194     idx = xml.indexOf('<',idx+1);
195     sb.append(xml.substring(idx));
196 */

197   return replaceTagValue(xml,"<oid>",R_OrderNum);
198   }
199
200   static public String JavaDoc replaceTagValue(String JavaDoc xml, String JavaDoc tag, String JavaDoc val)
201   {
202     StringBuffer JavaDoc sb = new StringBuffer JavaDoc(1024);
203     int idx = xml.indexOf(tag);
204     if( idx == -1 ) { return xml; }
205
206     sb.append(xml.substring(0,idx+tag.length()));
207     sb.append(val);
208     idx = xml.indexOf('<',idx+1);
209     sb.append(xml.substring(idx));
210   return sb.toString();
211   }
212
213   protected String JavaDoc getOrderXML() { return sXML; }
214   String JavaDoc sXML="";
215 }
Popular Tags