1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-30 10:42:41 +01:00
phorge-phorge/externals/balanced-php/example/debit-example.php
epriestley 23786784ef Add Balanced Payments API
Summary: Adds the Balanced PHP API to externals/. Ref T2787.

Test Plan: Used in next diff.

Reviewers: btrahan, chad

Reviewed By: chad

CC: aran, aurelijus

Maniphest Tasks: T2787

Differential Revision: https://secure.phabricator.com/D5764
2013-04-25 09:47:30 -07:00

42 lines
No EOL
1.1 KiB
PHP

<?php
require('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();
print "create a card\n";
$card = $marketplace->cards->create(array(
"card_number" => "5105105105105100",
"expiration_month" => "12",
"expiration_year" => "2015"
));
print "our card: " . $card->uri . "\n";
print "create a **buyer** account with that card\n";
$buyer = $marketplace->createBuyer(null, $card->uri);
print "our buyer account: " . $buyer->uri . "\n";
print "debit our buyer, let's say $15\n";
try {
$debit = $buyer->debit(1500);
print "our buyer debit: " . $debit->uri . "\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) {
print "oh no, the buyer has no debitable funding sources!\n";
}
print "and there you have it 8)\n";
?>