// A default class that uses an INI file is provided.
// The default directory is the API installation directory.
// The default filename is ./conf/connection.ini (which ought to be chmod 400 and owned by the application daemon user)
// We override that by submitting ".." as the configruation directory (a filename could also be provided if needed).
echo "Creating a new OAConnection Object" . PHP_EOL;
$oaConn = new OAConnection(new OAClientConfigIni('../..'));
// Here's an example showing an INI Config file stored in the /etc/myapp/oaconf/local_connection.ini file
//$oaConn = new OAConnection( new OAClientConfigIni('/etc/myapp', '/conf/local_connection.ini') );
// Now that we've got the connection, connect to the server and get an existing Payment Profile and update it
echo "Connecting to server..." . PHP_EOL;
$connected = '';
$attempts = 3;
try {
    while (!$connected and $attempts > 0) {
        echo "Connecting: {$attempts} remaining" . PHP_EOL;
        $oaConn->connect();
        $connected = $oaConn->isConnected();
        if ($connected) {
            echo "Successfully connected!" . PHP_EOL;
        }
        $attempts = $attempts - 1;
    }
    if (!$connected) {
        exit("Failed to establish a connection with the OpenACH server.");
    }
    // Load payment profile using either an external_account_id or a payment_profile_id
    // Make sure you pick an ID that actually exists in your account!
    // NOTE:  To find one, log into your OpenACH account, and find a payment profile by clicking on:
    //   Your originator -> Your Bank -> Your Origination Account -> Payment Profiles
    // A very common use case is for end users to have a 1:1 correlation with payment profiles
    #echo "Retrieving Payment Profile ID from a custom defined app identifier" . PHP_EOL;