print "Failed to retrieve Payment Profile" . PHP_EOL;
    } else {
        print "Retrived Payment Profile ..." . PHP_EOL;
        printObj($paymentProfile, 1);
        print "Updating External Accounts ..." . PHP_EOL;
        // Now that we have the PaymentProfile we can set the API Payment Profile ID so it can be used by default on other calls
        echo "Setting the default Payment Profile ID for the connection" . PHP_EOL;
        $oaConn->setPaymentProfileId($paymentProfile->payment_profile_id, OAConnection::IDTYPE_API);
        // External accounts represent the user's bank accounts
        // Retrieve the external accounts on this profile
        echo "\tGetting External Accounts..." . PHP_EOL;
        $externalAccounts = $oaConn->getExternalAccountsSummary();
        foreach ($externalAccounts as $extAcct) {
            print "\tExternal Account: (" . $extAcct->external_account_id . ") " . $extAcct->external_account_bank . " - " . $extAcct->external_account_name . PHP_EOL;
            printObj($extAcct, 2);
            $oaConn->setExternalAccountId($extAcct->external_account_id);
            echo "Modifying External Account..." . PHP_EOL;
            // To modify the external account retrieving the whole account is required.
            $externalAccount = $oaConn->getExternalAccount($extAcct->external_account_id);
            // Let's reverse the name of the account holder every time this demo is run
            $nameBefore = $externalAccount->external_account_holder;
            $externalAccount->external_account_holder = strrev($externalAccount->external_account_holder);
            $updatedExternalAccount = $oaConn->saveExternalAccount($externalAccount);
            if (isset($updatedExternalAccount->external_account_id)) {
                print "Updated External Account: was-'" . $nameBefore . "' is now-'" . $updatedExternalAccount->external_account_holder . "'" . PHP_EOL;
            }
        }
    }
} catch (Exception $e) {
    echo $e->getMessage() . PHP_EOL;
}