Project

General

Profile

Programming Guide » History » Version 6

chin-yeh, 08/25/2011 02:20 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
h3. Output Parameters
73
74
h3. Code Snippet
75
76
77
h2. Commit Sales
78
79
h3. Input Parameters
80
81 6 chin-yeh
See "performSalesCommit":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
82
83 3 chin-yeh
h3. Output Parameters
84
85
h3. Code Snippet
86
87
88 6 chin-yeh
h2. Sales Return / Sales Exchange
89
90
h3. Input Parameters
91
92
See "performSalesReturn":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
93
94
h3. Output Parameters
95
96
h3. Code Snippet
97
98
99
h2. VIP Upgrade to BO
100
101
h3. Input Parameters
102
103
See "performVipUpgrade":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/dp_client/DPServicesUtils.html
104
105
h3. Output Parameters
106
107
h3. Code Snippet
108
109
110 3 chin-yeh
h2. Generate the redirect URL for VIP Details page
111
112
h3. Input Parameters
113 6 chin-yeh
114
See "vipDetailsPage":http://192.168.2.13:50000/dp_client_apidocs/com/ecosway/utils/DpRedirectUtils.html
115 3 chin-yeh
116
h3. Output Parameters
117
118
h3. Code Snippet
119
120
121
122
h2. Exception Handling Strategies
123
124
The APIs would throw the following exceptions:
125 4 chin-yeh
* *RemoteException* - if there's any issue in communicating with the DP
126 3 chin-yeh
* *SQLException* - if there's any issue in persisting or updating the event
127
* *unchecked exception* - e.g. NullPointerException. This is more like a programming errors so do not catch it for whatever reasons.
128
** _note: catch the *Exception* will catch both checked & unchecked exception_
129
130
The above exceptions should never be ignored, at least, the full error stack trace should be logged.