Auth-Capture

Situations may arise wherein the amount of the transaction that will settle and be charged to the cardholder will be different form the amount originally authorized. The most common example is full-service restaurants wherein the original authorization does not include the server tip. The server gets an authorization for the amount of the check, then returns to the POS to add the tip. Here, the captured and settled amount is greater than the amount that was authorized. Keep in mind that, under card network rules, certain industries can settle an amount greater than the authorization without paying an interchange penalty such as restaurants, hotels, and rental cars. If you are not one of these industries and you expect to settle amounts greater than the initial authorization, you may wish to add some amount to the authorization to insure that the captured and settled amount is not greater. There is no interchange penalty for settling an amount that is less than the authorization.

Address o_address = new Address( Address.XS_ADDRESS_NAME_BILLING );
o_address.setLine1( "123 Maple Ave" );
o_address.setZipcode( "12345" );

BankCardTransaction o_bc_transaction = new BankCardTransaction();
o_bc_transaction.setBillingAddress( o_address );
o_bc_transaction.setType(BankCardTransaction.XS_BCT_TYPE_AUTH);
o_bc_transaction.setAmount(10.00);
o_bc_transaction.setCardName("Sample Bank Card Transaction");
o_bc_transaction.setCardNumber("4111111111111111");
o_bc_transaction.setCardExpirationMonth("01");
o_bc_transaction.setCardExpirationYear("2020");
o_bc_transaction.setCardCVV2( "111" );

BaseCommerceClient o_client = new BaseCommerceClient( "username", "password", "key" );
o_client.setSandbox(true);
o_bc_transaction = o_client.processBankCardTransaction(o_bc_transaction);
int n_transaction_id = o_bc_transaction.getTransactionId();
System.out.println( o_bc_transaction.getTransactionId() );

o_bc_transaction = new BankCardTransaction();
o_bc_transaction.setTransactionId( n_transaction_id );
o_bc_transaction.setType( BankCardTransaction.XS_BCT_TYPE_CAPTURE );
o_bc_transaction.setAmount( 9.50 );

o_bc_transaction = o_client.processBankCardTransaction(o_bc_transaction);

if ( o_bc_transaction.isStatus(BankCardTransaction.XS_BCT_STATUS_FAILED) ) {
       // Transaction failed, look at messages for
       // reasons why
       System.out.println( o_bc_transaction.getAuthorizationCode() );
       System.out.println( o_bc_transaction.getTransactionId() );
       System.out.println( o_bc_transaction.getResponseCode() );
       System.out.println( o_bc_transaction.getResponseMessage() );
       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.getTransactionId() );
       System.out.println( o_bc_transaction.getResponseCode() );
       System.out.println( o_bc_transaction.getResponseMessage() );
} else if ( o_bc_transaction.isStatus(BankCardTransaction.XS_BCT_STATUS_CAPTURED) ) {
       // Transaction successful
       System.out.println( o_bc_transaction.getAuthorizationCode() );
       System.out.println( o_bc_transaction.getTransactionId() );
       System.out.println( o_bc_transaction.getResponseCode() );
       System.out.println( o_bc_transaction.getResponseMessage() );
}
System.out.println("avs code : " + o_bc_transaction.getAVSResponseCode() );
System.out.println("cvv code : " + o_bc_transaction.getCVVResponseCode() );