Project

General

Profile

Programming Guide » History » Version 6

chin-yeh, 08/10/2011 03:31 PM

1 2 chin-yeh
{{toc}}
2
3 1 chin-yeh
h1. Programming Guide
4 2 chin-yeh
5 3 chin-yeh
There are number of APIs provided by VP. All of these APIs are wrapped and exposed through a client application, [[documentation#list-of-components|vp-client]]. Refer to the following sub sections for more information.
6 1 chin-yeh
7 3 chin-yeh
The Javadoc of *vp-client*:
8
> http://192.168.2.13:50000/vp_client_apidocs/
9
10 4 chin-yeh
The binary or source files of *vp-client*:
11
> [[wiki#SCM|SCM]]
12
13 3 chin-yeh
Demo application of *vp-client*:
14
> http://192.168.2.66:8080/vp-test/index.html
15
16 2 chin-yeh
h2. VP Registration
17 1 chin-yeh
18 3 chin-yeh
This method is only applicable for *new registration*, which means the member/shopper ID *is not yet registered* with VP before.
19 1 chin-yeh
20 3 chin-yeh
h3. Input Parameters
21
22 5 chin-yeh
See "performRegistration":http://192.168.2.13:50000/vp_client_apidocs/com/ecosway/vp_client/VPServicesUtils.html#performRegistration%28java.sql.Connection,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.math.BigDecimal,%20java.util.Date,%20java.util.Date,%20java.util.Date%29
23 3 chin-yeh
24
h3. Output Parameters
25
26
The return object, *TransactionResponse* consists of the following fields value:
27
* *process* - For registration, the possible value is *VRegister*
28
* *transactionId* - The unique reference that passed in by the caller
29
* *countryId* - The country ID/code that passed in by the caller
30
* *centerId* - To differentiate if the caller are from POS system or online
31
* *memberId* - The member/shopper ID
32
* *status* - The status of the transaction. If success, returns *0000* 
33
** _refer to document:"VP Web Service Format" for other possible status_
34
* *errorCode* - the error code of the transaction. if success, returns *00000* 
35
** _refer to document:"VP Web Service Format" for other possible error code_
36
* *errorMessage* - the detailed description of the error code 
37
** _refer to document:"VP Web Service Format" for other possible description_
38
39
h3. Code Snippet
40
41
*Important note:* One should modify the following code to cater existing program so do not copy & paste it directly.
42
43
<pre>
44
<code class="JAVA">
45
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
46
TransactionResponse vpResponse = new TransactionResponse();
47
48
try {
49
	vpResponse = VPServicesUtils.performRegistration(dbConnection, trxId, 
50
			countryId, memberId, memberName, vpAmount, regDate, expDate);
51
52
} catch (RemoteException ex) {
53
  // do not ignore. either log the full stack trace or handle it
54
  LOGGER.error(ex);
55
} catch (SQLException ex) {
56
  // do not ignore. either log the full stack trace or handle it
57
  LOGGER.error(ex);
58
} finally {
59
	if (dbConnection != null) {
60
		dbConnection.close();
61
	}
62
}
63
</code>
64
</pre>
65
66
h3. Exception Handling Strategies
67 1 chin-yeh
68 4 chin-yeh
This method would throws the following exceptions:
69 3 chin-yeh
* *RemoteException* - if there's any issue in communicating with VP
70
* *SQLException* - if there's any issue in persisting or updating the event
71
* *unchecked exception* - e.g. NullPointerException. This is more like a programming errors so do not catch it for whatever reasons.
72
73
The above exceptions should never be ignored, at least, the full error stack trace should be logged.
74 2 chin-yeh
75 1 chin-yeh
h2. VP Renewal
76 4 chin-yeh
77
This method is only applicable for renewal. The member/shopper ID should have already registered with VP before.
78
79
h3. Input Parameters
80
81 6 chin-yeh
See "performRenewal":http://192.168.2.13:50000/vp_client_apidocs/com/ecosway/vp_client/VPServicesUtils.html#performRenewal(java.sql.Connection,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.math.BigDecimal,%20java.util.Date,%20java.util.Date,%20java.util.Date)
82 4 chin-yeh
83
h3. Output Parameters
84
85
The return object, *TransactionResponse* consists of the following fields value:
86
* *process* - For registration/renewal, the possible value is *VRegister*
87
* *transactionId* - The unique reference that passed in by the caller
88
* *countryId* - The country ID/code that passed in by the caller
89
* *centerId* - To differentiate if the caller are from POS system or online
90
* *memberId* - The member/shopper ID
91
* *status* - The status of the transaction. If success, returns *0000* 
92
** _refer to document:"VP Web Service Format" for other possible status_
93
* *errorCode* - the error code of the transaction. if success, returns *00000* 
94
** _refer to document:"VP Web Service Format" for other possible error code_
95
* *errorMessage* - the detailed description of the error code 
96
** _refer to document:"VP Web Service Format" for other possible description_
97
98
h3. Code Snippet
99
100
*Important note:* One should modify the following code to cater existing program so do not copy & paste it directly.
101
102
<pre>
103
<code class="JAVA">
104
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
105
TransactionResponse vpResponse = new TransactionResponse();
106
107
try {
108
	vpResponse = VPServicesUtils.performRenewal(dbConnection, trxId, 
109
			countryId, memberId, memberName, vpAmount, regDate, expDate);
110
111
} catch (RemoteException ex) {
112
  // do not ignore. either log the full stack trace or handle it
113
  LOGGER.error(ex);
114
} catch (SQLException ex) {
115
  // do not ignore. either log the full stack trace or handle it
116
  LOGGER.error(ex);
117
} finally {
118
	if (dbConnection != null) {
119
		dbConnection.close();
120
	}
121
}
122
</code>
123
</pre>
124
125
126
h3. Exception Handling Strategies
127
128
This method would throws the following exceptions:
129
* *RemoteException* - if there's any issue in communicating with VP
130
* *SQLException* - if there's any issue in persisting or updating the event
131
* *unchecked exception* - e.g. NullPointerException. This is more like a programming errors so do not catch it for whatever reasons.
132
133
The above exceptions should never be ignored, at least, the full error stack trace should be logged.