foreach ($externalAccounts as $extAcct) { print "\tExternal Account: (" . $extAcct->external_account_id . ") " . $extAcct->external_account_bank . " - " . $extAcct->external_account_name . PHP_EOL; printObj($extAcct, 2); // Just like with payment profiles we can set this as the default external account for subsequent commands $oaConn->setExternalAccountId($extAcct->external_account_id); // To modify the external account retrieving the whole account is required. $externalAccount = $oaConn->getExternalAccount($extAcct->external_account_id); if (isset($externalAccount->external_account_id)) { print "Retrieved External Account: '" . $externalAccount->external_account_id . "' name is: '" . $externalAccount->external_account_holder . "'" . PHP_EOL; echo "Modifying External Account..." . PHP_EOL; // Let's reverse the name of the account holder every time this demo is run $nameBefore = $externalAccount->external_account_holder; print "Changing name to: '" . strrev($nameBefore) . PHP_EOL; $externalAccount->external_account_holder = strrev($nameBefore); printObj($externalAccount, 3); $response = $oaConn->saveExternalAccount($externalAccount); if (isset($response->external_account_id)) { print "Updated External Account: was-'" . $nameBefore . "' is now-'" . $response->external_account_holder . "'" . PHP_EOL; } } } // Retrieve all currently active paymentSchedules associated to this external account. // Useful to view / modify / discontinue / disable payments echo "\tGetting Payment Schedules..." . PHP_EOL; #$paymentSchedules = $oaConn->getPaymentSchedulesSummary( $extAcct->external_account_id); $paymentSchedules = $oaConn->getPaymentSchedulesSummary(); foreach ($paymentSchedules as $paySched) { print "\tPayment Schedule: " . $paySched->payment_schedule_id . PHP_EOL; printObj($paySched, 2); // // Modify the Payment Schedule and Save it back print "Modifying Payment Schedule: " . $paySched->payment_schedule_id . 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; } if ($connected) { print "Disconnecting "; $res = $oaConn->disconnect(); printObj($res); } function printObj($obj, $depth = 0) {
//external_account_billing_country = //external_account_business = //external_account_verification_status = //external_account_status = // Create a new object by getting a blank External Account; will likely turn this into a new call $newExternalAccount = $oaConn->getExternalAccount(''); $newExternalAccount->external_account_payment_profile_id = $paymentProfile->payment_profile_id; $newExternalAccount->external_account_name = "Jane Eyre's Savings Account at Jane Eyre's Bank"; $newExternalAccount->external_account_type = "savings"; $newExternalAccount->external_account_bank = "Jane Eyre's Bank"; $newExternalAccount->external_account_holder = "Jane Eyre"; $newExternalAccount->external_account_dfi_id = '101000187'; $newExternalAccount->external_account_number = rand(1000000, 9999999); print "Saving External Account..." . PHP_EOL; printObj($newExternalAccount, 1); $externalAccount = $oaConn->saveExternalAccount($newExternalAccount); if (isset($externalAccount->external_account_id)) { // The reponse from saveExternalAccount was successful; // we retrieve it here separately just to demonstrate it worked. print "Retrieving external account to confirm save..." . PHP_EOL; $response = $oaConn->getExternalAccount($externalAccount->external_account_id); printObj($response, 1); print "Succesfully retrieved External Account:" . PHP_EOL; } else { print "Failed to create External Account:" . PHP_EOL; printobj($response, 1); } if ($connected) { print "Disconnecting "; $res = $oaConn->disconnect(); printObj($res);