Page tree

Versions Compared

Key

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

...

If you would like to utilize the same card information/vault record under multiple merchants you will want to add the vault record under one merchant, get back the token, then add a second card using the second merchant's SDK credentials but set the same token on that vault record before adding it (opposed to letting Base Commerce auto generate a token for you) Then when you are processing transactions using vault records by giving us a token to us, we use the vault record that is under each merchant. Code sample is below.

*Please note, that for VISA cards, a $0.00 authorization will be run on the card before allowing to add the card to the vault due to VISA rules and regulations.

...

Code Block
BankAccountTransaction o_ach_transaction = new BankAccountTransaction();
o_ach_transaction.setType(BankAccountTransaction.XS_BAT_TYPE_DEBIT);
o_ach_transaction.setMethod(BankAccountTransaction.XS_BAT_METHOD_CCD);
o_ach_transaction.setAmount(5.25);
o_ach_transaction.setToken("7388430d262469efac9563027bb239edbf3c167a4a958ab128a53f9af3b185f7");
BaseCommerceClient o_client = new BaseCommerceClient(XS_USERNAME, XS_PASSWORD, XS_KEY);
o_client.setSandbox(true);
o_ach_transaction = o_client.processBankAccountTransaction(o_ach_transaction);
if (o_ach_transaction.isStatus(BankAccountTransaction.XS_BAT_STATUS_FAILED)) {
    // Transaction failed, look at messages for reasons why
    System.out.println(o_ach_transaction.getMessages());
} else if (o_ach_transaction.isStatus(BankAccountTransaction.XS_BAT_STATUS_CREATED)) {
    // Transaction successful
    System.out.println(o_ach_transaction.getBankAccountTransactionId());
}



Adding the same Bank Account vault record information under 2 different merchants.

Code Block
String s_account_number = "123456789";
String s_routing_number = "011001962";
String s_name = "Test account";

BankAccount o_bank_account = new BankAccount();
o_bank_account.setName( s_name );
o_bank_account.setAccountNumber( s_account_number );
o_bank_account.setRoutingNumber( s_routing_number );
o_bank_account.setType(BankAccount.XS_BA_TYPE_CHECKING);

String s_token = "";

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

if (o_bank_account.isStatus( BankAccount.XS_BA_STATUS_FAILED ) ) {
    // Bank Account add failed, look at messages for reasons why
    System.out.println( o_bank_account.getMessages() );
} else if ( o_bank_account.isStatus( BankAccount.XS_BA_STATUS_ACTIVE ) ) {
    // Bank Account add Successful and record the token so you can use it later to add the second vault record
    s_token = o_bank_account.getToken();

    //create a second BankAccount to add to the vault
    BankAccount o_bank_account_2 = new BankAccount();
    o_bank_account_2.setName( s_name );
    o_bank_account_2.setAccountNumber( s_account_number );
    o_bank_account_2.setRoutingNumber( s_routing_number );
    o_bank_account_2.setType(BankAccount.XS_BA_TYPE_CHECKING);
    //set token to be same as first one
    o_bank_account_2.setToken( s_token );

    //need to initialize client using the second merchants SDK credentials
    BaseCommerceClient o_client_2 = new BaseCommerceClient(XS_USERNAME_2, XS_PASSWORD_2, XS_KEY_2);
    o_client_2.setSandbox(true);
    o_bank_account_2 = o_client_2.addBankAccount( o_bank_account_2 );

    if (o_bank_account_2.isStatus( BankAccount.XS_BA_STATUS_FAILED ) ) {
        // Bank Account add failed, look at messages for reasons why
        System.out.println( o_bank_account_2.getMessages() );
    } else if ( o_bank_account_2.isStatus( BankAccount.XS_BA_STATUS_ACTIVE ) ) {
        //its active under the second merchant now
    }

}


Now that the vault record is under both merchants, you can process a BankAccountTransaction call using that same token. The transaction will be processed under the merchant whose SDK credentials were used.