Using a Card Swiper

To use a normal magnetic strip card swiper (not an EMV device) it is a fairly simple setup!

To obtain a card swiper you will want to reach out to your Relationship Manager or sales agent to discuss your options.

A card swiper is basically the same as using a keyboard to manually type the card number, as in its just a USB input to the computer. When a card is swiped the data is transmitted to the computer as if someone had typed their number on the keyboard. This value will then be sent to Base via the SDK to be parsed and processed.

Unencrypted Card Swiper

Instead of setting the card holders name, card number, and expiration date you just need to use the setCardTrack1Data() method. You can change the value "4111111111111111" in the test track data to be any of the test card numbers for testing.

BankCardTransaction o_bc_transaction = new BankCardTransaction();
o_bc_transaction.setType( BankCardTransaction.XS_BCT_TYPE_SALE );
o_bc_transaction.setAmount( 10.00 );
o_bc_transaction.setCardTrack1Data( "%B4111111111111111^Last/First ^2503201100001100000000676000000?;4111111111111111=250320110000676?" );

BaseCommerceClient o_client = new BaseCommerceClient( XS_USERNAME, XS_PASSWORD, XS_KEY );
o_client.setSandbox( true );

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.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_bc_transaction.isStatus(BankCardTransaction.XS_BCT_STATUS_CAPTURED ) ) {
    // Transaction successful
    System.out.println( o_bc_transaction.getTransactionId() );
}



Encrypted Card Swiper

To test with these you will need to have an encrypted card reader and want to add a single card you will be testing with to your sandbox account, which is shown here for adding a single card https://confluence.basecommerce.net/bctd/using-the-sdk/credit-card-processing.

Once you have added a card you will do almost the same as unencrypted except you will use the setEncryptedTrackData() method, passing the text from the encrypted card swiper to the function.

BankCardTransaction o_bc_transaction = new BankCardTransaction();
o_bc_transaction.setType( BankCardTransaction.XS_BCT_TYPE_SALE );
o_bc_transaction.setAmount( 10.00 );
o_bc_transaction.setEncryptedTrackData( "" );

BaseCommerceClient o_client = new BaseCommerceClient( XS_USERNAME, XS_PASSWORD, XS_KEY );
o_client.setSandbox( true );

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.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_bc_transaction.isStatus(BankCardTransaction.XS_BCT_STATUS_CAPTURED ) ) {
    // Transaction successful
    System.out.println( o_bc_transaction.getTransactionId() );
}