Beispiel #1
0
function create_buyer($email_address, $card_uri)
{
    $marketplace = Balanced\Marketplace::mine();
    try {
        # new buyer
        $buyer = $marketplace->createBuyer($email_address, $card_uri);
    } catch (Balanced\Errors\DuplicateAccountEmailAddress $e) {
        # oops, account for $email_address already exists so just add the card
        $buyer = Balanced\Account::get($e->extras->account_uri);
        $buyer->addCard($card_uri);
    }
    return $buyer;
}
Beispiel #2
0
function create_buyer($email_address, $card_uri)
{
    $marketplace = Balanced\Marketplace::mine();
    try {
        # new buyer
        $buyer = $marketplace->createBuyer($email_address, $card_uri);
    } catch (Balanced\Exceptions\HTTPError $e) {
        if ($e->category_code == 'duplicate-email-address') {
            # oops, account for $email_address already exists so just add the card
            $buyer = $marketplace->accounts->query()->filter(Balanced\Account::$f->email_address->eq($email_address))->one();
            $buyer->addCard($card_uri);
        } else {
            throw $e;
        }
    }
    return $buyer;
}
 /**
  * @phutil-external-symbol class Balanced\Card
  * @phutil-external-symbol class Balanced\Settings
  * @phutil-external-symbol class Balanced\Marketplace
  * @phutil-external-symbol class RESTful\Exceptions\HTTPError
  */
 public function createPaymentMethodFromRequest(AphrontRequest $request, PhortunePaymentMethod $method, array $token)
 {
     $errors = array();
     $root = dirname(phutil_get_library_root('phabricator'));
     require_once $root . '/externals/httpful/bootstrap.php';
     require_once $root . '/externals/restful/bootstrap.php';
     require_once $root . '/externals/balanced-php/bootstrap.php';
     $account_phid = $method->getAccountPHID();
     $author_phid = $method->getAuthorPHID();
     $description = $account_phid . ':' . $author_phid;
     try {
         Balanced\Settings::$api_key = $this->getSecretKey();
         $card = Balanced\Card::get($token['balancedMarketplaceURI']);
         $buyer = Balanced\Marketplace::mine()->createBuyer(null, $card->uri, array('description' => $description));
     } catch (RESTful\Exceptions\HTTPError $error) {
         // NOTE: This exception doesn't print anything meaningful if it escapes
         // to top level. Replace it with something slightly readable.
         throw new Exception($error->response->body->description);
     }
     $method->setBrand($card->brand)->setLastFourDigits($card->last_four)->setExpires($card->expiration_year, $card->expiration_month)->setMetadata(array('type' => 'balanced.account', 'balanced.accountURI' => $buyer->uri, 'balanced.cardURI' => $card->uri));
     return $errors;
 }
<?php

$bank_account = Balanced\Marketplace::mine()->bank_accounts->create(array("account_number" => "0987654321", "name" => "Henry Ford", "routing_number" => "321174851", "type" => "checking"));
$bank_account->associateToCustomer($merchant);
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV";
$card = Balanced\Marketplace::mine()->cards->create(array("cvv" => "123", "expiration_month" => "12", "expiration_year" => "3000", "number" => "6500000000000002"));
<?php

$card = Balanced\Marketplace::mine()->cards->create(array("expiration_month" => "12", "expiration_year" => "2020", "number" => "5105105105105100", "security_code" => "123"));
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV";
$marketplace = Balanced\Marketplace::mine();
$marketplace->reversals->query()->all();
<?php

Balanced\Marketplace::mine()->owner_customer->bank_accounts->query()->first()->credits->create(array("amount" => "2000000", "description" => "Credit from Balanced escrow"));
Beispiel #9
0
 public function getUserAccount()
 {
     Yii::import('application.extensions.vendor.autoload', true);
     Httpful\Bootstrap::init();
     Balanced\Bootstrap::init();
     Balanced\Settings::$api_key = Yii::app()->params['balancedAPISecret'];
     $user = $this->getUser();
     if (!isset($user->AccountURI) || $user->AccountURI == null) {
         $account = Balanced\Marketplace::mine()->createAccount($user->Email);
         $user->AccountURI = $account->uri;
         $user->save(false);
     } else {
         $account = Balanced\Account::get($user->AccountURI);
     }
     return $account;
 }
<?php

$bank_account = Balanced\Marketplace::mine()->bank_accounts->create(array("account_number" => "9900000001", "name" => "Johann Bernoulli", "routing_number" => "121000358", "type" => "checking"));
Beispiel #11
0
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY";
$card = Balanced\Marketplace::mine()->cards->create(array("expiration_month" => "05", "expiration_year" => "2020", "name" => "Johannes Bach", "number" => "4342561111111118"));
<?php

$marketplace_bank_account = Balanced\Marketplace::mine()->owner_customer->bank_accounts->query()->first();
$order->creditTo($marketplace_bank_account, "2000");