Sunday, November 11, 2012

Nailing the Root Cause in Java Exceptions

Java provides chained exception facility which enables to nest an exception within another .But to get the deepest level exception,there are no direct methods available as of now.
Packages like  Apache's common lang provides convenience method to  get the root cause.
(http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/exception/ExceptionUtils.html)
The root cause can also be retrieved by manually iterating down the stack trace using getCause().
The following snippet is a recursive method that is used to retrieve the Root Cause.

public Throwable getMostSpecificException( Throwable exp ) { 
        Throwable t = exp;
        logger.debug( "exp.getMessage()-->" + exp.getMessage(  ) );
        if ( exp.getCause(  ) != null ) {
            t = exp.getCause(  );
            // recursive call
            getMostSpecificException( t );
        }
        return t;
    }

Monday, February 6, 2012

Integrating with PayPal

PayPal is one of the largest online payment processors in the world.

It serves as a digital wallet which allows to purchase online in a secured manner. The PayPal System stores the User details and provides the flexibility to purchase by just using the PayPal Account Id .

To use PayPal,the user should create a PayPal account and provide information about the modes which they would like to use for payment like Credit Card ,Bank account etc. The preference order can be configured for the Payment Options. If the user has insufficient fund in their preferred option then the next available option would be used to complete the transaction.

The PayPal services can be integrated with the web applications by using either HTML or using API integration. PayPal SDK is another option to integrate with API.

Sandbox is an isolated test environment provided by PayPal to test its functionality. This is claimed to be an identical copy of PayPal Live Site and it is recommended verify all the PayPal calls in the Sandbox before deploying in the Live environment.

Its easy to get lost in the vast documentation of PayPal ,I feel it could have been organized better. The developer community and forums are better options to seek to sort out issues.