<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV";
Balanced\Customer::get("/customers/CU4GAx8tZTDNIgAmwfV35e53");
require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
// Create a new marketplace
$key = new Balanced\APIKey();
$key->save();
Balanced\Settings::$api_key = $key->secret;
$marketplace = new Balanced\Marketplace();
$marketplace->save();
// Create a bank account
$bank_account = new \Balanced\BankAccount(array("account_number" => "9900000001", "name" => "Johann Bernoulli", "routing_number" => "121000358", "type" => "checking"));
$bank_account->save();
print "The BankAccount: " . $bank_account->uri;
// Create a Customer
$customer = new \Balanced\Customer(array("name" => "William Henry Cavendish III", "email" => "*****@*****.**"));
$customer->save();
// Add the bank account to the Customer
$customer->addBankAccount($bank_account);
print "You can't debit from a bank account until you verify it\n";
try {
    $customer->debit(100);
} catch (Exception $e) {
    printf("Debit failed, %s\n", $e->description);
}
// Initiate a bank account verification
$verification = $bank_account->verify();
// Verify the bank account
try {
    $verification->confirm(1, 2);
} catch (Balanced\Errors\BankAccountVerificationFailure $e) {
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV";
$merchant = Balanced\Customer::get("/customers/CU4MnFEab304anOtUtEu5hkN");
$order = $merchant->orders->create();
示例#4
0
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY";
Balanced\Customer::get("/customers/CU5aACCvYYfV6mcWJL4TEcK1");
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
$API_KEY_SECRET = '5f4db668a5ec11e1b908026ba7e239a9';
Balanced\Settings::$api_key = $API_KEY_SECRET;
$marketplace = Balanced\Marketplace::mine();
// Create a Card
print "Create a card\n";
$card = $marketplace->cards->create(array("card_number" => "5105105105105100", "expiration_month" => "12", "expiration_year" => "2015"));
print "The card: " . $card->uri . "\n";
// Create a Customer
$customer = new \Balanced\Customer(array("name" => "William Henry Cavendish III", "email" => "*****@*****.**"));
$customer->save();
print "The customer: " . $customer->uri . "\n";
// Add the Card to the Customer
print "Add the Card to the Customer\n";
$customer->addCard($card->uri);
// Debit the Customer
print "Debit the customer \$15\n";
try {
    $debit = $customer->debit(1500);
    print "The debit: " . $debit->uri . "\n";
    print "Debited Customer " . $customer->uri . " for " . $debit->amount . " cents.\n";
} catch (Balanced\Errors\Declined $e) {
    print "Oh no, the processor declined the debit!\n";
} catch (Balanced\Errors\NoFundingSource $e) {
    print "Oh no, the buyer has not active funding sources!\n";
} catch (Balanced\Errors\CannotDebit $e) {
 public function createCustomer($options)
 {
     $customer = new \Balanced\Customer($options);
     $customer->save();
     return $customer;
 }
print "The customer: " . $customer->uri . "\n";
// Add Card to Customer
$customer->addCard($card->uri);
// Hold some funds
print "Create a Hold for some funds, \$15\n";
$hold = $marketplace->holds->create(array("amount" => 1500, "description" => "Some descriptive text for the debit in the dashboard", "source_uri" => $card->uri));
// Capture the hold
print "Capture the Hold (for the full amount)\n";
$debit = $hold->capture();
// Check escrow for new funds from debit
$marketplace = Balanced\Marketplace::mine();
if ($marketplace->in_escrow != 1500) {
    throw new Exception("1500 is not in escrow! This is wrong");
}
print "Escrow amount: " . $marketplace->in_escrow . " \n";
print "Refund the full amount\n";
$refund = $debit->refund();
// Create a bank account
$bank_account = new \Balanced\BankAccount(array("account_number" => "9900000001", "name" => "Johann Bernoulli", "routing_number" => "121000358", "type" => "checking"));
$bank_account->save();
// Create a Customer who is the seller
$seller = new \Balanced\Customer(array("name" => "Billy Jones", "email" => "*****@*****.**", "street_address" => "801 High St", "postal_code" => "94301", "country" => "USA", "dob" => "1979-02"));
$seller->save();
// Add bank account to seller
$seller->addBankAccount($bank_account->uri);
print "Debit the customer for \$130\n";
$debit = $customer->debit(13000, "MARKETPLACE.COM");
print "Credit the seller \$110\n";
$credit = $seller->credit(11000, "Buyer purchased something on Marketplace.com");
print "The marketplace charges 15%, so it earned \$20\n";
$mp_credit = $marketplace->owner_customer->credit(2000, "Commission from MARKETPLACE.COM");
示例#8
0
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY";
$merchant = Balanced\Customer::get("/customers/CU5AxbQrjAcjsbquafnvwaas");
$order = $merchant->orders->create();
示例#9
0
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY";
$customer = Balanced\Customer::get("/customers/CU3o1ZAd8Gtxz6ZTIFK9YmsM");
$accounts = $customer->accounts->query()->all();