Project

General

Profile

Programming Guide » History » Version 5

chin-yeh, 08/25/2011 02:09 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
h3. Input Parameters
59
60
h3. Output Parameters
61
62
h3. Code Snippet
63
64
h2. Release Sales Lock
65
66
h3. Input Parameters
67
68
h3. Output Parameters
69
70
h3. Code Snippet
71
72
73
h2. Commit Sales
74
75
h3. Input Parameters
76
77
h3. Output Parameters
78
79
h3. Code Snippet
80
81
82
h2. Generate the redirect URL for VIP Details page
83
84
h3. Input Parameters
85
86
h3. Output Parameters
87
88
h3. Code Snippet
89
90
91
92
h2. Exception Handling Strategies
93
94
The APIs would throw the following exceptions:
95 4 chin-yeh
* *RemoteException* - if there's any issue in communicating with the DP
96 3 chin-yeh
* *SQLException* - if there's any issue in persisting or updating the event
97
* *unchecked exception* - e.g. NullPointerException. This is more like a programming errors so do not catch it for whatever reasons.
98
** _note: catch the *Exception* will catch both checked & unchecked exception_
99
100
The above exceptions should never be ignored, at least, the full error stack trace should be logged.