[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/stripe-php/lib/Stripe/ -> Customer.php (source)

   1  <?php
   2  
   3  class Stripe_Customer extends Stripe_ApiResource
   4  {
   5    /**
   6     * @param string $id The ID of the customer to retrieve.
   7     * @param string|null $apiKey
   8     *
   9     * @return Stripe_Customer
  10     */
  11    public static function retrieve($id, $apiKey=null)
  12    {
  13      $class = get_class();
  14      return self::_scopedRetrieve($class, $id, $apiKey);
  15    }
  16  
  17    /**
  18     * @param array|null $params
  19     * @param string|null $apiKey
  20     *
  21     * @return array An array of Stripe_Customers.
  22     */
  23    public static function all($params=null, $apiKey=null)
  24    {
  25      $class = get_class();
  26      return self::_scopedAll($class, $params, $apiKey);
  27    }
  28  
  29    /**
  30     * @param array|null $params
  31     * @param string|null $apiKey
  32     *
  33     * @return Stripe_Customer The created customer.
  34     */
  35    public static function create($params=null, $apiKey=null)
  36    {
  37      $class = get_class();
  38      return self::_scopedCreate($class, $params, $apiKey);
  39    }
  40  
  41    /**
  42     * @returns Stripe_Customer The saved customer.
  43     */
  44    public function save()
  45    {
  46      $class = get_class();
  47      return self::_scopedSave($class);
  48    }
  49  
  50    /**
  51     * @param array|null $params
  52     *
  53     * @returns Stripe_Customer The deleted customer.
  54     */
  55    public function delete($params=null)
  56    {
  57      $class = get_class();
  58      return self::_scopedDelete($class, $params);
  59    }
  60  
  61    /**
  62     * @param array|null $params
  63     *
  64     * @returns Stripe_InvoiceItem The resulting invoice item.
  65     */
  66    public function addInvoiceItem($params=null)
  67    {
  68      if (!$params)
  69        $params = array();
  70      $params['customer'] = $this->id;
  71      $ii = Stripe_InvoiceItem::create($params, $this->_apiKey);
  72      return $ii;
  73    }
  74  
  75    /**
  76     * @param array|null $params
  77     *
  78     * @returns array An array of the customer's Stripe_Invoices.
  79     */
  80    public function invoices($params=null)
  81    {
  82      if (!$params)
  83        $params = array();
  84      $params['customer'] = $this->id;
  85      $invoices = Stripe_Invoice::all($params, $this->_apiKey);
  86      return $invoices;
  87    }
  88  
  89    /**
  90     * @param array|null $params
  91     *
  92     * @returns array An array of the customer's Stripe_InvoiceItems.
  93     */
  94    public function invoiceItems($params=null)
  95    {
  96      if (!$params)
  97        $params = array();
  98      $params['customer'] = $this->id;
  99      $iis = Stripe_InvoiceItem::all($params, $this->_apiKey);
 100      return $iis;
 101    }
 102  
 103    /**
 104     * @param array|null $params
 105     *
 106     * @returns array An array of the customer's Stripe_Charges.
 107     */
 108    public function charges($params=null)
 109    {
 110      if (!$params)
 111        $params = array();
 112      $params['customer'] = $this->id;
 113      $charges = Stripe_Charge::all($params, $this->_apiKey);
 114      return $charges;
 115    }
 116  
 117    /**
 118     * @param array|null $params
 119     *
 120     * @returns Stripe_Subscription The updated subscription.
 121     */
 122    public function updateSubscription($params=null)
 123    {
 124      $requestor = new Stripe_ApiRequestor($this->_apiKey);
 125      $url = $this->instanceUrl() . '/subscription';
 126      list($response, $apiKey) = $requestor->request('post', $url, $params);
 127      $this->refreshFrom(array('subscription' => $response), $apiKey, true);
 128      return $this->subscription;
 129    }
 130  
 131    /**
 132     * @param array|null $params
 133     *
 134     * @returns Stripe_Subscription The cancelled subscription.
 135     */
 136    public function cancelSubscription($params=null)
 137    {
 138      $requestor = new Stripe_ApiRequestor($this->_apiKey);
 139      $url = $this->instanceUrl() . '/subscription';
 140      list($response, $apiKey) = $requestor->request('delete', $url, $params);
 141      $this->refreshFrom(array('subscription' => $response), $apiKey, true);
 142      return $this->subscription;
 143    }
 144  
 145    /**
 146     * @param array|null $params
 147     *
 148     * @returns Stripe_Customer The updated customer.
 149     */
 150    public function deleteDiscount()
 151    {
 152      $requestor = new Stripe_ApiRequestor($this->_apiKey);
 153      $url = $this->instanceUrl() . '/discount';
 154      list($response, $apiKey) = $requestor->request('delete', $url);
 155      $this->refreshFrom(array('discount' => null), $apiKey, true);
 156    }
 157  }


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