Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this example, we want to confirm that the transaction was approved, so we will since it was a transaction of type AUTH not SALE it will comp back in the AUTHORIZED status where as if it was a SALE it would come back as CAPTURED if successful. We will check the status on the BankCardTransaction object then print out the values returned:

Code Block
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
		System.out.println( o_bc_transaction.getTransactionId() ); //Base Commerce Unique custom ID for every BankCardTransaction
		System.out.println( o_bc_transaction.getAuthorizationCode() ); //The authorization code
		System.out.println( o_bc_transaction.getAVSResponseCode() ); //The AVS response code

 }

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, as all resources are closed and variables are reset (with the exception of the username, password, and key) after each transaction is processed.

...