Project

General

Profile

Programming Guide » History » Version 3

chin-yeh, 08/10/2011 11:38 AM

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
Demo application of *vp-client*:
11
> http://192.168.2.66:8080/vp-test/index.html
12
13 2 chin-yeh
h2. VP Registration
14 1 chin-yeh
15 3 chin-yeh
This method is only applicable for *new registration*, which means the member/shopper ID *is not yet registered* with VP before.
16 1 chin-yeh
17 3 chin-yeh
h3. Input Parameters
18
19
See "performRegistration":http://192.168.2.13:50000/vp_client_apidocs/com/ecosway/vp_client/VPServicesUtils.html#performRegistration(java.sql.Connection,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.math.BigDecimal,%20java.util.Date,%20java.util.Date)
20
21
h3. Output Parameters
22
23
The return object, *TransactionResponse* consists of the following fields value:
24
* *process* - For registration, the possible value is *VRegister*
25
* *transactionId* - The unique reference that passed in by the caller
26
* *countryId* - The country ID/code that passed in by the caller
27
* *centerId* - To differentiate if the caller are from POS system or online
28
* *memberId* - The member/shopper ID
29
* *status* - The status of the transaction. If success, returns *0000* 
30
** _refer to document:"VP Web Service Format" for other possible status_
31
* *errorCode* - the error code of the transaction. if success, returns *00000* 
32
** _refer to document:"VP Web Service Format" for other possible error code_
33
* *errorMessage* - the detailed description of the error code 
34
** _refer to document:"VP Web Service Format" for other possible description_
35
36
h3. Code Snippet
37
38
*Important note:* One should modify the following code to cater existing program so do not copy & paste it directly.
39
40
<pre>
41
<code class="JAVA">
42
Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
43
TransactionResponse vpResponse = new TransactionResponse();
44
45
try {
46
	vpResponse = VPServicesUtils.performRegistration(dbConnection, trxId, 
47
			countryId, memberId, memberName, vpAmount, regDate, expDate);
48
49
} catch (RemoteException ex) {
50
  // do not ignore. either log the full stack trace or handle it
51
  LOGGER.error(ex);
52
} catch (SQLException ex) {
53
  // do not ignore. either log the full stack trace or handle it
54
  LOGGER.error(ex);
55
} finally {
56
	if (dbConnection != null) {
57
		dbConnection.close();
58
	}
59
}
60
</code>
61
</pre>
62
63
h3. Exception Handling Strategies
64
65
The methods would throws the following exceptions:
66
* *RemoteException* - if there's any issue in communicating with VP
67
* *SQLException* - if there's any issue in persisting or updating the event
68
* *unchecked exception* - e.g. NullPointerException. This is more like a programming errors so do not catch it for whatever reasons.
69
70
The above exceptions should never be ignored, at least, the full error stack trace should be logged.
71 2 chin-yeh
72
h2. VP Renewal