public function dwolla_getFundingSources($cid) { $token = $this->returnFieldFromTable("company_dwollatoken", "companies", "id='{$cid}'"); if (!$token) { return null; } $Dwolla = new DwollaRestClient(); $Dwolla->setToken($token); return $Dwolla->fundingSources(); }
private function dwollaMain() { // Do we have an authorized Dwolla Account? If no, then display a hero-like unit with two options. Create Account or Authorize Your Account if (!$this->company->company_dwollatoken) { return $this->dwollaAuthorizeOrCreate(); } $myid = $this->company->id; $Dwolla = new DwollaRestClient($this->getSetting('dwolla_app_key'), $this->getSetting('dwolla_app_secret'), $this->getSetting('atikit_url') . "dwauth/{$myid}/"); $Dwolla->setToken($this->company->company_dwollatoken); // Create a list of Funding Sources and an Add Button $fundingSources = $Dwolla->fundingSources(); $rows = []; foreach ($fundingSources as $source) { $color = $source['Verified'] ? "green" : "red"; $verified = $source['Verified'] ? "Yes" : "No"; $row = [$source['Name'], $source['Type'], $verified, $color]; $rows[] = $row; } $headers = ['Source Name', 'Type', 'Verified']; $table = table::init()->headers($headers)->rows($rows)->render(); $add = button::init()->text("Add Bank Account")->isModalLauncher()->addStyle('btn-info')->icon('plus')->url('#addAccount')->render(); $saveAccount = button::init()->text("Save Account")->addStyle('mpost')->icon('ok')->addStyle('btn-success')->postVar('addAccount')->formid('addAccountForm')->render(); $this->exportModal(modal::init()->id('addAccount')->header("Add Bank Account to Dwolla")->content($this->addBankAccountForm())->footer($saveAccount)->render()); $table .= base::alert('info', "Removing Accounts", "If you wish to remove your bank account from Dwolla, you must login to dwolla.com and remove."); return widget::init()->header('Funding Sources')->content($table)->span(8)->rightHeader($add)->isTable()->render(); }