Project

General

Profile

Actions

Programming Guide » History » Revision 12

« Previous | Revision 12/13 (diff) | Next »
chin-yeh, 09/28/2011 03:25 PM


Programming Guide

There are number of APIs provided by VP. All of these APIs are wrapped and exposed through a client application, vp-client. Refer to the following sub sections for more information.

The Javadoc of vp-client:

http://192.168.2.13:50000/vp_client_apidocs/

The binary or source files of vp-client:

SCM

Demo application of vp-client:

http://192.168.2.66:8080/vp-test/index.html

VP Registration

This method is only applicable for new registration, which means the member/shopper ID is not yet registered with VP before.

Method Signature:

public static TransactionResponse performRegistration(java.sql.Connection connection,
                                                      java.lang.String trxId,
                                                      java.lang.String countryId,
                                                      java.lang.String memberId,
                                                      java.lang.String memberName,
                                                      java.math.BigDecimal vpAmount,
                                                      java.util.Date trxDate,
                                                      java.util.Date regDate,
                                                      java.util.Date expDate)
                                               throws java.rmi.RemoteException,
                                                      java.sql.SQLException

Input Parameters

See performRegistration

Output Parameters

The return object, TransactionResponse consists of the following fields value:
  • process - For registration, the possible value is VRegister
  • transactionId - The unique reference that passed in by the caller
  • countryId - The country ID/code that passed in by the caller
  • centerId - To differentiate if the caller are from POS system or online
  • memberId - The member/shopper ID
  • status - The status of the transaction. If success, returns 0000
  • errorCode - the error code of the transaction. if success, returns 00000
  • errorMessage - the detailed description of the error code

Code Snippet

Important note: One should modify the following code to cater existing program so do not copy & paste it directly.

Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
TransactionResponse vpResponse = new TransactionResponse();

try {
    vpResponse = VPServicesUtils.performRegistration(dbConnection, trxId, 
            countryId, memberId, memberName, vpAmount, trxDate, regDate, expDate);

} catch (RemoteException ex) {
  // do not ignore. either log the full stack trace or handle it
  LOGGER.error("Error in connecting to VP web services", ex);
} catch (SQLException ex) {
  // do not ignore. either log the full stack trace or handle it
  LOGGER.error("Error in persisting the event", ex);
} finally {
    if (dbConnection != null) {
        dbConnection.close();
    }
}

VP Renewal

This method is only applicable for renewal. If the member is not exist, VP will create the record in the background.

Method Signature:

public static TransactionResponse performRenewal(java.sql.Connection connection,
                                                 java.lang.String trxId,
                                                 java.lang.String countryId,
                                                 java.lang.String memberId,
                                                 java.lang.String memberName,
                                                 java.math.BigDecimal vpAmount,
                                                 java.util.Date trxDate,
                                                 java.util.Date regDate,
                                                 java.util.Date expDate)
                                          throws java.rmi.RemoteException,
                                                 java.sql.SQLException

Input Parameters

See performRenewal

Output Parameters

The return object, TransactionResponse consists of the following fields value:
  • process - For registration/renewal, the possible value is VRegister
  • transactionId - The unique reference that passed in by the caller
  • countryId - The country ID/code that passed in by the caller
  • centerId - To differentiate if the caller are from POS system or online
  • memberId - The member/shopper ID
  • status - The status of the transaction. If success, returns 0000
  • errorCode - the error code of the transaction. if success, returns 00000
  • errorMessage - the detailed description of the error code

Code Snippet

Important note: One should modify the following code to cater existing program so do not copy & paste it directly.

Connection dbConnection = DBConnectionFactory.createDbConnection("java:/DB2DS2");
TransactionResponse vpResponse = new TransactionResponse();

try {
    vpResponse = VPServicesUtils.performRenewal(dbConnection, trxId, 
            countryId, memberId, memberName, vpAmount, trxDate, regDate, expDate);

} catch (RemoteException ex) {
  // do not ignore. either log the full stack trace or handle it
  LOGGER.error("Error in connecting to VP web services", ex);
} catch (SQLException ex) {
  // do not ignore. either log the full stack trace or handle it
  LOGGER.error("Error in persisting the event", ex);
} finally {
    if (dbConnection != null) {
        dbConnection.close();
    }
}

Exception Handling Strategies

The APIs would throw the following exceptions:
  • RemoteException - if there's any issue in communicating with VP
  • SQLException - if there's any issue in persisting or updating the event
  • unchecked exception - e.g. NullPointerException. This is more like a programming errors so do not catch it for whatever reasons.
    • note: catch the Exception will catch both checked & unchecked exception

The above exceptions should never be ignored, at least, the full error stack trace should be logged.

Updated by chin-yeh about 13 years ago · 12 revisions