mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 04:02:43 +01:00
23786784ef
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
75 lines
1.8 KiB
PHP
75 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Balanced;
|
|
|
|
use Balanced\Resource;
|
|
use \RESTful\URISpec;
|
|
|
|
/**
|
|
* Represents an account credit transaction.
|
|
*
|
|
* You create these using Balanced\Account::credit.
|
|
*
|
|
* <code>
|
|
* $marketplace = \Balanced\Marketplace::mine();
|
|
*
|
|
* $account = $marketplace
|
|
* ->accounts
|
|
* ->query()
|
|
* ->filter(Account::f->email_address->eq('merchant@example.com'))
|
|
* ->one();
|
|
*
|
|
* $credit = $account->credit(
|
|
* 100,
|
|
* 'how it '
|
|
* array(
|
|
* 'my_id': '112233'
|
|
* )
|
|
* );
|
|
* </code>
|
|
*/
|
|
class Credit extends Resource
|
|
{
|
|
protected static $_uri_spec = null;
|
|
|
|
public static function init()
|
|
{
|
|
self::$_uri_spec = new URISpec('credits', 'id', '/v1');
|
|
self::$_registry->add(get_called_class());
|
|
}
|
|
|
|
/**
|
|
* Credit an unstored bank account.
|
|
*
|
|
* @param int amount Amount to credit in USD pennies.
|
|
* @param string description Optional description of the credit.
|
|
* @param mixed bank_account Associative array describing a bank account to credit. The bank account will *not* be stored.
|
|
*
|
|
* @return \Balanced\Credit
|
|
*
|
|
* <code>
|
|
* $credit = \Balanced\Credit::bankAccount(
|
|
* 123,
|
|
* array(
|
|
* 'account_number' => '12341234',
|
|
* 'name' => 'Fit Finlay',
|
|
* 'bank_code' => '325182797',
|
|
* 'type' => 'checking',
|
|
* ),
|
|
* 'something descriptive');
|
|
* </code>
|
|
*/
|
|
public static function bankAccount(
|
|
$amount,
|
|
$bank_account,
|
|
$description = null)
|
|
{
|
|
$credit = new Credit(array(
|
|
'amount' => $amount,
|
|
'bank_account' => $bank_account,
|
|
'description' => $description
|
|
));
|
|
$credit->save();
|
|
return $credit;
|
|
}
|
|
}
|