1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00
phorge-phorge/externals/balanced-php/src/Balanced/Card.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

61 lines
1.5 KiB
PHP

<?php
namespace Balanced;
use Balanced\Resource;
use \RESTful\URISpec;
/**
* Represents an account card.
*
* You can create these via Balanced\Marketplace::cards::create or
* Balanced\Marketplace::createCard. Associate them with a buyer or merchant
* one creation via Marketplace::createBuyer or
* Balanced\Marketplace::createMerchant and with an existing buyer or merchant
* use Balanced\Account::addCard.
*
* <code>
* $marketplace = \Balanced\Marketplace::mine();
*
* $card = $marketplace->cards->create(array(
* 'name' => 'name',
* 'account_number' => '11223344',
* 'bank_code' => '1313123'
* ));
*
* $account = $marketplace
* ->accounts
* ->query()
* ->filter(Account::f->email_address->eq('buyer@example.com'))
* ->one();
* $account->addCard($card->uri);
* </code>
*/
class Card extends Resource
{
protected static $_uri_spec = null;
public static function init()
{
self::$_uri_spec = new URISpec('cards', 'id', '/v1');
self::$_registry->add(get_called_class());
}
public function debit(
$amount,
$appears_on_statement_as = null,
$description = null,
$meta = null,
$source = null)
{
if ($this->account == null) {
throw new \UnexpectedValueException('Card is not associated with an account.');
}
return $this->account->debit(
$amount,
$appears_on_statement_as,
$description,
$meta,
$this->uri);
}
}