KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > lp > samples > SALE_MAXINFO


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 SALE_MAXINFO extends JLinkPointSample {
20   public SALE_MAXINFO() {
21   }
22   protected String JavaDoc getOrderXML() {
23     // Create an empty order
24
LPOrderPart order = LPOrderFactory.createOrderPart("order");
25
26   // Create a part we will use to build the order
27
LPOrderPart op = LPOrderFactory.createOrderPart();
28
29   // Build 'orderoptions'
30
op.put("ordertype","SALE");
31       // live transaction
32
op.put("result","LIVE");
33   // add 'orderoptions to order
34
order.addPart("orderoptions", op );
35
36       // Build 'merchantinfo'
37
op.clear();
38       op.put("configfile",configfile);
39   // add 'merchantinfo to order
40
order.addPart("merchantinfo", op );
41
42
43       // Build 'transactiondetails'
44
op.clear();
45       op.put("transactionorigin","MOTO");
46       // If there is no PO Number for this order,
47
// pass a department code or other value, but make sure the value you pass is supplied by the customer
48
op.put("ponumber","09876543-Q1234");
49       // If the purchase is tax exempt,
50
// pass a value of Y for taxexempt
51
op.put("taxexempt","N");
52       op.put("terminaltype","UNSPECIFIED");
53       op.put("ip","123.123.123.123");
54       // add 'billing to order
55
order.addPart("transactiondetails", op );
56
57       // Build 'billing'
58
// Required for AVS. If not provided,
59
// transactions will downgrade.
60
op.clear();
61       op.put("zip","12345");
62       op.put("addrnum","123");
63
64       op.put("name","Joe Customer");
65       op.put("company","SomeWhere, Inc.");
66       op.put("address1","123 Broadway");
67       op.put("address2","Suite 23");
68       op.put("city","Moorpark");
69       op.put("state","CA");
70       op.put("country","US");
71       op.put("phone","8051234567");
72       op.put("fax","8059876543");
73       op.put("email","joe.customer@somewhere.com");
74       // add 'billing to order
75
order.addPart("billing", op );
76
77
78   // build shipping
79
op.clear();
80       op.put("name","Joe Customer");
81       op.put("address1","123 Broadway");
82       op.put("address2","Suite 23");
83       op.put("city","Moorpark");
84       op.put("state","CA");
85       op.put("country","US");
86       op.put("zip","12345");
87   order.addPart("shipping",op);
88
89       // Build 'creditcard'
90
op.clear();
91       op.put("cardnumber","4111-1111-1111-1111");
92       op.put("cardexpmonth","03");
93       op.put("cardexpyear","05");
94       op.put("cvmvalue","123");
95       op.put("cvmindicator","provided");
96   // add 'creditcard to order
97
order.addPart("creditcard", op );
98
99        // Build 'payment'
100
op.clear();
101       op.put("subtotal","12.99");
102       op.put("tax","0.34");
103       op.put("shipping","1.45");
104       op.put("vattax","0.00");
105       op.put("chargetotal","14.78");
106   // add 'payment to order
107
order.addPart("payment", op );
108
109   // add notes to order
110
op.clear();
111       op.put("referred","Saw ad on Web site.");
112       op.put("comments","Repeat customer. Ship immediately.");
113       order.addPart("notes",op);
114
115   // Create some parts we use to build order itmes
116
LPOrderPart items = LPOrderFactory.createOrderPart();
117       LPOrderPart item = LPOrderFactory.createOrderPart();
118       LPOrderPart options = LPOrderFactory.createOrderPart();
119
120               // build and build 'item1'
121
item.put("id","123456-A98765");
122               item.put("description","Logo T-Shirt");
123               item.put("quantity","1");
124               item.put("price","12.99");
125               item.put("serial","0987654321");
126
127               // build item's options
128
op.clear();
129                       op.put("name","Color");
130                       op.put("value","Red");
131                       options.addPart("option",op,1);
132
133                       op.clear();
134                       op.put("name","Size");
135                       op.put("value","XL");
136                       options.addPart("option",op,2);
137
138               // add 'options' to item
139
item.addPart("options", options );
140
141         // add 'item' to 'items' collection
142
items.addPart("item", item, 1 );
143   // add 'items' to order
144
order.addPart("items", items );
145
146    return order.toXML();
147    }
148
149 }
Popular Tags