Project

General

Profile

Programming Guide » History » Version 7

chin-yeh, 08/25/2011 02:21 PM

1 2 chin-yeh
{{toc}}
2
3 1 chin-yeh
h1. Programming Guide
4 2 chin-yeh
5
There are number of APIs provided by DP. All of these APIs are wrapped and exposed through a client application, [[documentation#list-of-components|dp-client]]. Refer to the following sub sections for more information.
6
7
The Javadoc of *dp-client*:
8
> http://192.168.2.13:50000/dp_client_apidocs/
9
10
The binary or source files of *dp-client*:
11
> [[wiki#SCM|SCM]]
12
13
Demo application of *dp-client*:
14
> http://192.168.2.66:8080/dp-test/index.html
15 3 chin-yeh
16 5 chin-yeh
h2. Query DP balance
17 1 chin-yeh
18 5 chin-yeh
Queries the available DP balance. 
19
20 3 chin-yeh
h3. Input Parameters
21 1 chin-yeh
22 5 chin-yeh
See "queryBalance":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
23
24 3 chin-yeh
h3. Output Parameters
25 1 chin-yeh
26 5 chin-yeh
The return object, *TransactionResponse* consists of:
27
* *process* - Sales1
28
* *transactionId* - the unique reference that passed in by the caller
29
* *countryId* - the country ID that passed in by the caller
30
* *centerId* - possible value is *ONLINE*. It's used to differentiate if the caller are from POS system or online mall.
31
* *memberId* - the member/shopper ID
32
* *status* - the status of the transaction. If success, returns *0000*
33
** refer to document:"DP Web Services" for other possible status
34
* *balance* - the available DP balance
35
* *errorCode* - the error code of the transaction. if success, returns *00000*
36
** refer to document:"DP Web Services" for other possible error code
37
* *errorMessage* - the detailed description of the error code 
38
** refer to document:"DP Web Services" for other possible description
39
40
41 1 chin-yeh
h3. Code Snippet
42 5 chin-yeh
43
<pre>
44
<code class="JAVA">
45
TransactionResponse dpResponse;
46
try {
47
  dpResponse = DPServicesUtils.queryBalance(countryCode, shopperId); 
48
49
} catch (RemoteException ex) {
50
  // do not ignore. either log the full stack trace or handle it
51
  LOGGER.error(ex);
52
}
53
</code>
54
</pre>
55 3 chin-yeh
56
h2. Impose Sales Lock
57
58 6 chin-yeh
Imposes the *Sales Lock* on the particular member ID. This method is usually to be used conjunction with *Commit Sales*. Without sales lock, the *Commit Sales* won't succeed.
59
60 3 chin-yeh
h3. Input Parameters
61
62 6 chin-yeh
See "imposeSalesLock":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
63
64 3 chin-yeh
h3. Output Parameters
65
66
h3. Code Snippet
67
68
h2. Release Sales Lock
69
70
h3. Input Parameters
71
72 7 chin-yeh
See "releaseSalesLock":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
73
74 3 chin-yeh
h3. Output Parameters
75
76
h3. Code Snippet
77
78
79
h2. Commit Sales
80
81
h3. Input Parameters
82
83 6 chin-yeh
See "performSalesCommit":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
84
85 3 chin-yeh
h3. Output Parameters
86
87
h3. Code Snippet
88
89
90 6 chin-yeh
h2. Sales Return / Sales Exchange
91
92
h3. Input Parameters
93
94
See "performSalesReturn":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
95
96
h3. Output Parameters
97
98
h3. Code Snippet
99
100
101
h2. VIP Upgrade to BO
102
103
h3. Input Parameters
104
105
See "performVipUpgrade":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
106
107
h3. Output Parameters
108
109
h3. Code Snippet
110
111
112 3 chin-yeh
h2. Generate the redirect URL for VIP Details page
113
114
h3. Input Parameters
115 6 chin-yeh
116
See "vipDetailsPage":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/utils/DpRedirectUtils.html
117 3 chin-yeh
118
h3. Output Parameters
119
120
h3. Code Snippet
121
122
123
124
h2. Exception Handling Strategies
125
126
The APIs would throw the following exceptions:
127 4 chin-yeh
* *RemoteException* - if there's any issue in communicating with the DP
128 3 chin-yeh
* *SQLException* - if there's any issue in persisting or updating the event
129
* *unchecked exception* - e.g. NullPointerException. This is more like a programming errors so do not catch it for whatever reasons.
130
** _note: catch the *Exception* will catch both checked & unchecked exception_
131
132
The above exceptions should never be ignored, at least, the full error stack trace should be logged.