Skip to main content

Use eChecks

Use eChecks

Last updated: 03-Mar-2025
Rate this article:

Overview

eChecks (electronic checks) are a secure, efficient, and cost-effective digital payment method that allows merchants to process payments directly from a customer's bank account. Using the Automated Clearing House (ACH) network, eChecks streamline transactions by replacing traditional paper checks with electronic processing. 

This method is ideal for recurring payments, large transactions, or industries where ACH payments are commonly used.

Supported currencies

eChecks support only USD transactions.

Workflow

  1. Collect the following information from your customers:
    • Account holder name
    • Bank Routing number
    • Account number
    • Account type 
      • Use value "S" for SAVINGS accounts and "C" for CHECKING accounts in API
  2. Create the order object. Use DIRECT_DEBIT_ACH as the type in the PaymentDetails object and pass the collected information through the PaymentMethod object.
  3. Place the order.

Request parameters

Parameters Type/Description
sessionID Required (string)
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes.
Order Required (Object)
Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details. See code sample for more details.

Request example

<?php
declare(strict_types=1);
class Configuration
{
    public const MERCHANT_CODE = 'MERCHANT';
    public const MERCHANT_KEY = 'SECRET_KEY';
    public const URL = 'https://api.2checkout.com/rpc/6.0';
    public const ACTION = 'placeOrder';
    //array or JSON
    public const PAYLOAD = <<<JSON
{
    "Currency": "USD",
    "Language": "EN",
    "Country": "us",
    "CustomerIP": "91.220.121.21",
    "Source": "sourceAPI.net",
    "LocalTime": "2022-01-13 09:41:59",
    "CustomerReference": 421820775,
    "Items": [
        {
            "Code": "TA-TuneUp-M-RENEW"
        }
    ],
    "BillingDetails": {
        "Address1": "Test Address",
        "City": "LA",
        "State": "California",
        "CountryCode": "US",
        "Email": "testcustomer@2Checkout.com",
        "FirstName": "Customer",
        "LastName": "2Checkout",
        "Zip": "12345"
      },
    "PaymentDetails": {
        "Type": "DIRECT_DEBIT_ACH",
        "Currency": "USD",
        "CustomerIP": "91.220.121.21",
        "PaymentMethod": {
            "AccountHolderName": "John Doe",
            "BankRoutingNumber": "222371863",
            "AccountNumber": "999999999",
            "AccountType": "C",
            "RecurringEnabled": true
        }
    }
}
JSON;
}
class Client
{
    private const LOGIN_METHOD = 'login';
    private $calls = 1;
    private $sessionId;
    private function generateAuth(): array
    {
        $merchantCode = Configuration::MERCHANT_CODE;
        $key = Configuration::MERCHANT_KEY;
        $date = gmdate('Y-m-d H:i:s');
        $string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
        $algo = 'sha256';
        $hash = hash_hmac($algo, $string, $key);
        return compact('merchantCode', 'date', 'hash', 'algo');
    }
    public function login(string $url)
    {
        $payload = $this->generateAuth();
        $response = $this->call($url, array_values($payload), self::LOGIN_METHOD);
        $this->sessionId = $response['result'];
    }
    public function call(
        string $url = Configuration::URL,
        $payload = Configuration::PAYLOAD,
        string $action = Configuration::ACTION
    ): ?array {
        if (empty($this->sessionId) && $action !== self::LOGIN_METHOD) {
            $this->login($url);
        }
        if (is_string($payload)) {
            $payload = json_decode($payload, true);
        }
        if (!empty($this->sessionId)) {
            $payload = [$this->sessionId, $payload];
        }
        $payload = array_filter($payload);
        $request = json_encode([
            'jsonrpc' => '2.0',
            'method'  => $action,
            'params'  => $payload,
            'id'      => $this->calls++,
        ]);
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($curl, CURLOPT_SSLVERSION, 0);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt(
            $curl,
            CURLOPT_HTTPHEADER,
            ['Content-Type: application/json', 'Accept: application/json', 'Cookie: XDEBUG_SESSION=PHPSTORM']
        );
        curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
        $response = curl_exec($curl);
        if (empty($response)) {
            die('Server unavailable');
        }
        echo $response . '</br>';
        return json_decode($response, true);;
    }
}
$client = new Client();
$result = $client->call();
var_dump($result);

Response Parameters

Parameter Type/Description
Order information Object
Object containing order information.
Rate this article:

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo