/** * 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; }
/** * 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\Resource::init(); \Balanced\APIKey::init(); \Balanced\Marketplace::init(); \Balanced\Credit::init(); \Balanced\Debit::init(); \Balanced\Refund::init(); \Balanced\Reversal::init(); \Balanced\Card::init(); \Balanced\BankAccount::init(); \Balanced\BankAccountVerification::init(); \Balanced\CardHold::init(); \Balanced\Callback::init(); \Balanced\Event::init(); \Balanced\Customer::init(); \Balanced\Order::init(); \Balanced\Dispute::init(); self::$initialized = true; }
function testGetBankAccounById() { $bank_account = self::_createBankAccount(); $bank_account_2 = BankAccount::get($bank_account->id); $this->assertEquals($bank_account_2->id, $bank_account->id); }
/** * Create a merchant account. * * Unlike buyers the identity of a merchant must be established before * the account can function as a merchant (i.e. be credited). A merchant * can be either a person or a business. Either way that information is * represented as an associative array and passed as the merchant parameter * when creating the merchant account. * * For a person the array looks like this: * * <code> * array( * 'type' => 'person', * 'name' => 'William James', * 'tax_id' => '393-48-3992', * 'street_address' => '167 West 74th Street', * 'postal_code' => '10023', * 'dob' => '1842-01-01', * 'phone_number' => '+16505551234', * 'country_code' => 'USA' * ) * </code> * * For a business the array looks like this: * * <code> * array( * 'type' => 'business', * 'name' => 'Levain Bakery', * 'tax_id' => '253912384', * 'street_address' => '167 West 74th Street', * 'postal_code' => '10023', * 'phone_number' => '+16505551234', * 'country_code' => 'USA', * 'person' => array( * 'name' => 'William James', * 'tax_id' => '393483992', * 'street_address' => '167 West 74th Street', * 'postal_code' => '10023', * 'dob' => '1842-01-01', * 'phone_number' => '+16505551234', * 'country_code' => 'USA', * ) * ) * </code> * * In some cases the identity of the merchant, person or business, cannot * be verified in which case a \Balanced\Exceptions\HTTPError is thrown: * * <code> * $identity = array( * 'type' => 'business', * 'name' => 'Levain Bakery', * 'tax_id' => '253912384', * 'street_address' => '167 West 74th Street', * 'postal_code' => '10023', * 'phone_number' => '+16505551234', * 'country_code' => 'USA', * 'person' => array( * 'name' => 'William James', * 'tax_id' => '393483992', * 'street_address' => '167 West 74th Street', * 'postal_code' => '10023', * 'dob' => '1842-01-01', * 'phone_number' => '+16505551234', * 'country_code' => 'USA', * ), * ); * * try { * $merchant = \Balanced\Marketplace::mine()->createMerchant( * '*****@*****.**', * $identity, * ); * catch (\Balanced\Exceptions\HTTPError $e) { * if ($e->code != 300) { * throw $e; * } * print e->response->header['Location'] // this is where merchant must signup * } * </code> * * Once the merchant has completed signup you can use the resulting URI to * create an account for them on your marketplace: * * <code> * $merchant = self::$marketplace->createMerchant( * '*****@*****.**', * null, * null, * $merchant_uri * ); * </coe> * * @param string email_address Optional email address. There can only be one account with this email address. * @param array[string]mixed merchant Associative array describing the merchants identity. * @param string $bank_account_uri Optional URI referencing a bank account to associate with this account. * @param string $merchant_uri URI of a merchant created via the redirection sign-up flow. * @param string $name Optional name of the merchant. * @param array[string]string meta Optional metadata to associate with the account. * * @return \Balanced\Account */ public function createMerchant($email_address = null, $merchant = null, $bank_account_href = null, $name = null, $meta = null) { $params = array('email_address' => $email_address, 'name' => $name, 'meta' => $meta); if ($merchant) { $params = array_merge($params, $merchant); } $customer = $this->customers->create(); if ($bank_account_href) { $bank_account = BankAccount::get($bank_account_href); $bank_account->associateToCustomer($customer); } return $customer; }
/** * @param $uri * @return \Balanced\BankAccount */ public function getBankAccount($uri) { return \Balanced\BankAccount::get($uri); }
function testCreditAccountless() { $collection = $this->getMock('\\RESTful\\Collection', array('create'), array('\\Balanced\\Credit', 'some/uri', null)); $collection->expects($this->once())->method('create')->with(array('amount' => 101, 'description' => 'something super sweet')); $bank_account = new BankAccount(array('uri' => '/some/other/uri', 'account' => null, 'credits' => $collection)); $bank_account->credit(101, 'something super sweet'); }