Exemple #1
0
 function testEvents()
 {
     $prev_num_events = Marketplace::mine()->events->total();
     $account = self::_createBuyer();
     $account->debit(123);
     $cur_num_events = Marketplace::mine()->events->total();
     $count = 0;
     while ($cur_num_events == $prev_num_events && $count < 10) {
         printf("waiting for events - %d, %d == %d\n", $count + 1, $cur_num_events, $prev_num_events);
         sleep(2);
         // 2 seconds
         $cur_num_events = Marketplace::mine()->events->total();
         $count += 1;
     }
     $this->assertTrue($cur_num_events > $prev_num_events);
 }
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY";
$marketplace = \Balanced\Marketplace::mine();
$bank_account = $marketplace->bank_accounts->create(array("account_number" => "9900000001", "account_type" => "checking", "name" => "Johann Bernoulli", "routing_number" => "121000358"));
$bank_account->save();
 /**
  * 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 findOrCreateCustomerByEmailAddress($email_address)
 {
     $marketplace = Marketplace::mine();
     $customer = $marketplace->customers->query()->filter(Customer::$f->email->eq($email_address))->first();
     if ($customer) {
         return $customer;
     }
     return $this->createCustomer($email_address);
 }
 public function getMarketPlaceBankAccount()
 {
     return \Balanced\Marketplace::mine()->owner_customer->bank_accounts->query()->first();
 }
Exemple #5
0
 /**
  * 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;
 }
Exemple #6
0
 function testMe()
 {
     $marketplace = Marketplace::mine();
     $merchant = Merchant::me();
     $this->assertEquals($marketplace->id, $merchant->marketplace->id);
 }