KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > lp > samples > ITEMS_W_ESD


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 ITEMS_W_ESD extends JLinkPointSample {
20   public ITEMS_W_ESD() {
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 'creditcard'
44
op.clear();
45        op.put("cardnumber","4111-1111-1111-1111");
46        op.put("cardexpmonth","03");
47        op.put("cardexpyear","05");
48        // add 'creditcard to order
49
order.addPart("creditcard", op );
50
51         // Build 'payment'
52
op.clear();
53        op.put("subtotal","45.98");
54        op.put("tax","0.32");
55        op.put("shipping","1.02");
56        op.put("chargetotal","47.32");
57    // add 'payment to order
58
order.addPart("payment", op );
59
60        // Build 'billing'
61
// Required for AVS. If not provided,
62
// transactions will downgrade.
63
op.clear();
64        op.put("zip","12345");
65        op.put("addrnum","123");
66    // When using ESD items - name must present
67
op.put("name","Joe Customer");
68        // add 'billing to order
69
order.addPart("billing", op );
70
71
72   // Create some parts we use to build order itmes
73
LPOrderPart items = LPOrderFactory.createOrderPart();
74        LPOrderPart item = LPOrderFactory.createOrderPart();
75        LPOrderPart options = LPOrderFactory.createOrderPart();
76
77                // build 'item1'
78
item.put("id","123456-A98765");
79                item.put("description","Logo T-Shirt");
80                item.put("quantity","1");
81                item.put("price","12.99");
82                item.put("serial","0987654321");
83
84                // build item's options
85
op.clear();
86                        op.put("name","Color");
87                        op.put("value","Red");
88                        options.addPart("option",op,1);
89
90                        op.clear();
91                        op.put("name","Size");
92                        op.put("value","XL");
93                        options.addPart("option",op,2);
94
95                // add 'options' to item
96
item.addPart("options", options );
97          // add 'item' to 'items' collection
98
items.addPart("item", item, 1 );
99                // build 'item2'
100
item.clear();
101                item.put("id","123456-A98767");
102                item.put("description","Blast-Em Software");
103                item.put("price","32.99");
104                item.put("quantity","1");
105                item.put("serial","0987654321");
106                item.put("esdtype","softgood");
107                item.put("softfile","blastem.exe");
108
109          // add 'item' to 'items' collection
110
items.addPart("item", item, 2 );
111
112    // add 'items' to order
113
order.addPart("items", items );
114
115  return order.toXML();
116  }
117
118 }
Popular Tags