/** * @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; }
public function actionDeleteCards() { Yii::import('application.extensions.vendor.autoload', true); Httpful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = Yii::app()->params['balancedAPISecret']; if (isset($_POST['data'])) { $dataString = $_POST['data']; $data = json_decode($dataString); $user_ID = $this->getUser()->User_ID; foreach ($data as $card) { $cardModel = CreditCard::model()->findByPk($card); if ($cardModel->User_ID == $user_ID) { $cardModel->Active = 0; $cardModel->save(); $balancedCard = Balanced\Card::get($cardModel->URI); $balancedCard->is_valid = false; $balancedCard->save(); } } } }
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV"; $card = Balanced\Card::get("/cards/CC4auQXiAWMBxJcEUIMYeZFj"); $card->card_holds->create(array("amount" => "5000", "description" => "Some descriptive text for the debit in the dashboard"));
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV"; $card = Balanced\Card::get("/cards/CC4mYF7dj7X6OA2K5F0Qyb4N");
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-25ZY8HQwZPuQtDecrxb671LilUya5t5G0"; $card = Balanced\Card::get("/cards/CC3iCCIHprJu5HPyP7vmE92B"); $card->credits->create(array("amount" => "5000", "description" => "Some descriptive text for the debit in the dashboard"));
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY"; $card = Balanced\Card::get("/cards/CC3vhL91rWtwtHcOBl0ITshG"); $card->card_holds->create(array("amount" => 5000, "description" => "Some descriptive text for the debit in the dashboard"));
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-2jJSjIixy2qkOMmIONPtXnawOUftBDRSK"; $card = Balanced\Card::get("/cards/CC7nMc4BAti7DgvWmpGV5e6N"); $card->credits->create(array("amount" => "5000", "description" => "Some descriptive text for the debit in the dashboard"));
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY"; $card = Balanced\Card::get("/cards/CC4zyuNpxY0A0eAf87SeULCR");
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY"; $order = Balanced\Order::get("/orders/OR3vURGwVtqDnnkRS9fgH41G"); $card = Balanced\Card::get("/cards/CC4HDcgvzIltvwv6GSjBVbji"); $order->creditTo($card, 5000);
<?php $card = Balanced\Card::get($cardHref); $card->associateToCustomer($customerHref);
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-aUV295IugdhWSNx2JFckYBCSvfY2ibgq"; $order = Balanced\Order::get("/orders/OR5QcYnwysJXQswImokq6ZSx"); $card = Balanced\Card::get("/cards/CC5OD6648yiKfSzfj6z6MdXr"); $order->debitFrom($card, "5000");
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-2eKlj1ZDfAcZSARMf3NMhBHywDej0avSY"; $card = Balanced\Card::get("/cards/CC5RRvpnZIg0PWdSphR8xxPa"); $card->debits->create(array("amount" => "5000", "appears_on_statement_as" => "Statement text", "description" => "Some descriptive text for the debit in the dashboard"));
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV"; $card = Balanced\Card::get("/cards/CC4tvKLTKXcBJAgkGvPEW58N"); $card->debits->create(array("amount" => "5000", "appears_on_statement_as" => "Statement text", "description" => "Some descriptive text for the debit in the dashboard"));
<?php require __DIR__ . '/vendor/autoload.php'; Httpful\Bootstrap::init(); RESTful\Bootstrap::init(); Balanced\Bootstrap::init(); Balanced\Settings::$api_key = "ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV"; $card = Balanced\Card::get("/cards/CC4XMSQg2OY6rrcrkeEGtLcZ"); $card->debits->create(array("amount" => "5000", "appears_on_statement_as" => "Statement text", "description" => "Some descriptive text for the debit in the dashboard"));