Adding additional field to X-cart 4.4.x ACH/electronic check payment method

By default, X-Cart 4.4.x does not provide some additional fields that would be very useful to fight fraud. This payment method is great for a secured x-cart store to collect payment information to be used offline instead of being used with a real time payment gateway. However, offline payment methods require a little extra homework from the store owners to ensure that an account it not being used fraudulently. The default fields for the ACH/Electronic Check payment method are “account owner”, “bank account number”, and “bank routing number.” Once an order is placed, this information is encrypted as part of the order details and is accessible through the x-cart store admin.

It is very possible to add additional fields for extra fraud fighting information. Here are the three additional fields that I have added to an x-cart store. “Bank Name”, “Bank City”, “Bank State”, and “Bank State” are the three fields that I had added to the payment method.

Changing the code

The good news is that minimal changes need to be made in order add these additional fields. The the check payment template will need to have the additional fields added and the func.orders.php files will also need the corresponding changes.

Depending on the checkout module being used, you may need to alter a different template. If using Fast Lane Checkout, you will need to modify /*skin directory*/customer/main/register_chinfo.tpl and add the following lines.

  <tr>
    <td class="data-name">Bank name:</td>
    <td class="data-required">*</td>
    <td><input type="text" id="check_bankname" name="check_bankname" 
       size="32" maxlength="50" value="" /></td>
  </tr>
  <tr>
    <td class="data-name">City:</td>
    <td class="data-required">*</td>
    <td><input type="text" id="check_bankcity" name="check_bankcity" 
       size="32" maxlength="32" value="" /></td>
  </tr>
  <tr>
    <td class="data-name">State:</td>
    <td class="data-required">*</td>
    <td><input type="text" id="check_bankstate" name="check_bankstate"
       size="32" maxlength="32" value="" /></td>
  </tr>

Locate line 3060 in /includes/func/func.order.php and modify to add the three new items.

    static $all_fields = array (
        'CC' => array (
            'card_name'       => "{CardOwner}",
            'card_type'       => "{CardType}",
            'card_number'     => "{CardNumber}",
            'card_valid_from' => "{ValidFrom}",
            'card_expire'     => "{ExpDate}",
            'card_issue_no'   => "{IssueNumber}",
        ),
        'CC_EXT' => array (
            'card_cvv2' => 'CVV2',
        ),
        'CH' => array (
            // ACH
            'check_name'         => "{AccountOwner}",
            'check_ban'          => "{BankAccount}",
            'check_brn'          => "{BankNumber}",
            'check_number'       => "{FractionNumber}",

            //custom: added bank name, city, state 
           'check_bankname' => "Bank Name", 
           'check_bankcity' => "Bank City", 
           'check_bankstate' => "Bank State",			

            // Direct Debit
            'debit_name'         => "{AccountOwner}",
            'debit_bank_account' => "{BankAccount}",
            'debit_bank_number'  => "{BankNumber}",
            'debit_bank_name'    => "{BankName}",
        )
    );

Now the payment details show the following:

Account owner *
Account number *
Bank routing number *
Bank name: *
City: *
State: *