/** * Initializes resources (i.e. registers them with Resource::_registry). Note * that if you add a Resource then you must initialize it here. * * @internal */ private static function initializeResources() { if (self::$initialized) { return; } \Balanced\Errors\Error::init(); \Balanced\Resource::init(); \Balanced\APIKey::init(); \Balanced\Marketplace::init(); \Balanced\Account::init(); \Balanced\Credit::init(); \Balanced\Debit::init(); \Balanced\Refund::init(); \Balanced\Card::init(); \Balanced\BankAccount::init(); \Balanced\Hold::init(); \Balanced\Merchant::init(); self::$initialized = true; }
/** * Find or create a role-less account by email address. You can later turn * this into a buyer by adding a funding source (e.g a card) or a merchant * using \Balanced\Account->promoteToMerchant. * * @param string email_address Email address. There can only be one account with this email address. * * @return \Balanced\Account */ function findOrCreateAccountByEmailAddress($email_address) { $marketplace = Marketplace::mine(); try { $account = $this->accounts->create(array('email_address' => $email_address)); } catch (Errors\DuplicateAccountEmailAddress $e) { $account = Account::get($e->extras->account_uri); } return $account; }
function testGetBuyer() { $buyer1 = self::_createBuyer(); $buyer2 = Account::get($buyer1->uri); $this->assertEquals($buyer1->id, $buyer2->id); }
function testHold() { $collection = $this->getMock('\\RESTful\\Collection', array('create'), array('\\Balanced\\Hold', 'some/uri', null)); $collection->expects($this->once())->method('create')->with(array('amount' => 1243, 'description' => 'something crispy', 'source_uri' => '/some/card/uri', 'meta' => array('test#' => 'test_d'))); $account = new Account(array('holds' => $collection)); $account->hold(1243, 'something crispy', '/some/card/uri', array('test#' => 'test_d')); }