[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/balanced-php/src/Balanced/ -> Debit.php (source)

   1  <?php
   2  
   3  namespace Balanced;
   4  
   5  use Balanced\Resource;
   6  use \RESTful\URISpec;
   7  
   8  /**
   9   * Represents an account debit transaction.
  10   * 
  11   * You create these using Balanced\Account::debit.
  12   * 
  13   * <code>
  14   * $marketplace = \Balanced\Marketplace::mine();
  15   * 
  16   * $account = $marketplace
  17   *     ->accounts
  18   *     ->query()
  19   *     ->filter(Account::f->email_address->eq('[email protected]'))
  20   *     ->one();
  21   * 
  22   * $debit = $account->debit(
  23   *     100,
  24   *     'how it appears on the statement',
  25   *     'a description',
  26   *     array(
  27   *         'my_id': '443322'
  28   *         )
  29   *     );
  30   * </code>
  31   */
  32  class Debit extends Resource
  33  {
  34      protected static $_uri_spec = null;
  35  
  36      public static function init()
  37      {
  38          self::$_uri_spec = new URISpec('debits', 'id');
  39          self::$_registry->add(get_called_class());
  40      }
  41      
  42      /**
  43       * Create a refund for this debit. You can create multiple refunds for a
  44       * debit but the total amount of the refunds must be less than the debit
  45       * amount.  
  46       * 
  47       * @param int amount Optional amount of the refund in USD pennies. If unspecified then the full debit amount is used.    
  48       * @param string description Optional description of the refund.
  49       * @param array[string]string meta Optional metadata to associate with the refund.
  50       * 
  51       * @return \Balanced\Refund
  52       */
  53      public function refund(
  54          $amount = null,
  55          $description = null,
  56          $meta = null)
  57      {
  58          return $this->refunds->create(array(
  59              'amount' => $amount,
  60              'description' => $description,
  61              'meta' => $meta
  62              ));
  63      }
  64  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1