Base Commerce Technical Documentation

Using The SDK

To take a test drive of our SDK in our sand box environment please click here to register for a demo account. In order to use the SDK in the production environment you will need to have an active merchant account with Base Commerce.

Regardless of which programming language you are using the architecture of the SDK is the same. Examples throughout this document are in JAVA.

Each request to the Base Commerce Platform begins by initializing the BaseCommerceClient object with your username, password, and transaction key.

BaseCommerceClient o_client = new BaseCommerceClient( “username”, ”password”, ”key”);

Once you have created your client instance you will then create an object the represents the type of action you wish to preform on the platform (detailed in the following sections). The following example authorizing a credit card for 1 dollar.

BankCardTransaction o_bc_transaction = new BankCardTransaction();
o_bc_transaction.setAmount(1);
o_bc_transaction.setCardExpirationMonth(“03”);
o_bc_transaction.setCardExpirationYear(“2015”);
o_bc_transaction.setCardNumber( "4111111111111111");
o_bc_transaction.setCardName( "Test Card");
o_bc_transaction.setType( BankCardTransaction.XS_BCT_TYPE_AUTH );

Next you will invoke the method on the BaseCommerceClient which corresponds to the desired function. This will make the client connect to our platform via SSL and execute your request. Upon completion of the request, the object you passed as a parameter will be updated with the results of the request.

o_bc_transaction = o_client.processBankCardTransaction( o_bc_transaction );

In this example we want to confirm that the transaction was approved, so we will check the status on the BankCardTransaction object.

if ( o_bc_transaction.isStatus(BankCardTransaction.XS_BCT_STATUS_FAILED) ) {

       // Transaction failed, look at messages for reasons why
       System.out.println( o_bc_transaction.getMessages() );

} else if ( o_bc_transaction.isStatus(BankCardTransaction.XS_BCT_STATUS_DECLINED) ) {

       // Transaction declined, look at response code and response message
       System.out.println( o_bc_transaction.getResponseCode() );
       System.out.println( o_bc_transaction.getResponseMessage() );

} else if ( o_transaction.isStatus( BankCardTransaction.XO_AUTHORIZED ) {

       // Transaction was successfully authorized

}

This completes the process of authorizing a card and checking the response. In the event you are processing multiple transactions the same client object can be reused multiple times, however the BankCardTransaction object should not be reused. When you are done with the client there is no clean up to do, all resources are closed and variables reset (with the exception of the username, password, and key) after each transaction is processed.

In the event that the server is unable to process your request due to invalid credentials (username, password, key) a BaseCommercePayClientException will be thrown indicating that there is a communication error with the server.