Example #1
0
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY";
$credit = Balanced\Credit::get("/credits/CR4RdgCoOqYhr4sjPdcDjf3T");
$credit->description = 'New description for credit';
$credit->meta = array("anykey" => "valuegoeshere", "facebook.id" => "1234567890");
$credit->save();
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV";
$credit = Balanced\Credit::get("/credits/CR4yt4sdkTWI1t3HVS16mNAV");
$credit->description = 'New description for credit';
$credit->meta = array("anykey" => "valuegoeshere", "facebook.id" => "1234567890");
$credit->save();
Example #3
0
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY";
$credit = Balanced\Credit::get("/credits/CR6zeufmfv0u1KHrUBCQtAgU");
$credit->reversals->create();
Example #4
0
print "ok, no more holds! let's capture it (for the full amount)\n";
$debit = $the_hold->capture();
print "hmm, ho much money do i have in escrow? it should equal the debit amount\n";
$marketplace = Balanced\Marketplace::mine();
if ($marketplace->in_escrow != 1500) {
    throw new Exception("1500 is not in escrow! This is wrong");
}
print "I have " . $marketplace->in_escrow . " in escrow!\n";
print "Cool. now let me refund the full amount";
$refund = $debit->refund();
print "ok, we have a merchant that's signing up, let's create an account for them first, let's create their bank account\n";
$bank_account = $marketplace->createBankAccount("Jack Q Merchant", "123123123", "123123123");
$identity = array("type" => "person", "name" => "Billy Jones", "street_address" => "801 High St", "postal_code" => "94301", "country" => "USA", "dob" => "1979-02", "phone_number" => "+16505551234");
$merchant = $marketplace->createMerchant('*****@*****.**', $identity, $bank_account->uri);
print "our buyer is interested in buying something for \$130\n";
$another_debit = $buyer->debit(13000, "MARKETPLACE.COM");
print "let's credit our merchant \$110\n";
$credit = $merchant->credit(11000, "Buyer purchase something on Marketplace.com");
print "let's assume the marketplace charges 15%, so it earned \$20\n";
$mp_credit = $marketplace->owner_account->credit(2000, "Commission from MARKETPLACE.COM");
print "ok, let's invalidate the card used so it cannot be used again\n";
$card->is_valid = false;
$card->save();
print "how do we look up an existing object from the URI?\n";
$the_buyer = Balanced\Account::get($buyer->uri);
print "we got the buyer " . $the_buyer->email_address . "\n";
$the_debit = Balanced\Debit::get($debit->uri);
print "we got the debit: " . $the_debit->uri . "\n";
$the_credit = Balanced\Credit::get($credit->uri);
print "we got the credit: " . $the_credit->uri . "\n";
print "and there you have it :)\n";
<?php

require __DIR__ . '/vendor/autoload.php';
Httpful\Bootstrap::init();
RESTful\Bootstrap::init();
Balanced\Bootstrap::init();
Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV";
$credit = Balanced\Credit::get("/credits/CR6nBcaGvGc4dtflEB1bjKBP");
$credit->reversals->create();
<?php

// $credit_href is the stored href for the Credit
// $order_href is the stored href for the Order
$credit = Balanced\Credit::get($credit_href);
$credit->reversals->create(array('order' => $order_href));