Changeset View
Changeset View
Standalone View
Standalone View
externals/stripe-php/lib/Stripe/Customer.php
| <?php | <?php | ||||
| class Stripe_Customer extends Stripe_ApiResource | class Stripe_Customer extends Stripe_ApiResource | ||||
| { | { | ||||
| public static function constructFrom($values, $apiKey=null) | /** | ||||
| { | * @param string $id The ID of the customer to retrieve. | ||||
| $class = get_class(); | * @param string|null $apiKey | ||||
| return self::scopedConstructFrom($class, $values, $apiKey); | * | ||||
| } | * @return Stripe_Customer | ||||
| */ | |||||
| public static function retrieve($id, $apiKey=null) | public static function retrieve($id, $apiKey=null) | ||||
| { | { | ||||
| $class = get_class(); | $class = get_class(); | ||||
| return self::_scopedRetrieve($class, $id, $apiKey); | return self::_scopedRetrieve($class, $id, $apiKey); | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * @param string|null $apiKey | |||||
| * | |||||
| * @return array An array of Stripe_Customers. | |||||
| */ | |||||
| public static function all($params=null, $apiKey=null) | public static function all($params=null, $apiKey=null) | ||||
| { | { | ||||
| $class = get_class(); | $class = get_class(); | ||||
| return self::_scopedAll($class, $params, $apiKey); | return self::_scopedAll($class, $params, $apiKey); | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * @param string|null $apiKey | |||||
| * | |||||
| * @return Stripe_Customer The created customer. | |||||
| */ | |||||
| public static function create($params=null, $apiKey=null) | public static function create($params=null, $apiKey=null) | ||||
| { | { | ||||
| $class = get_class(); | $class = get_class(); | ||||
| return self::_scopedCreate($class, $params, $apiKey); | return self::_scopedCreate($class, $params, $apiKey); | ||||
| } | } | ||||
| /** | |||||
| * @returns Stripe_Customer The saved customer. | |||||
| */ | |||||
| public function save() | public function save() | ||||
| { | { | ||||
| $class = get_class(); | $class = get_class(); | ||||
| return self::_scopedSave($class); | return self::_scopedSave($class); | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns Stripe_Customer The deleted customer. | |||||
| */ | |||||
| public function delete($params=null) | public function delete($params=null) | ||||
| { | { | ||||
| $class = get_class(); | $class = get_class(); | ||||
| return self::_scopedDelete($class, $params); | return self::_scopedDelete($class, $params); | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns Stripe_InvoiceItem The resulting invoice item. | |||||
| */ | |||||
| public function addInvoiceItem($params=null) | public function addInvoiceItem($params=null) | ||||
| { | { | ||||
| if (!$params) | if (!$params) | ||||
| $params = array(); | $params = array(); | ||||
| $params['customer'] = $this->id; | $params['customer'] = $this->id; | ||||
| $ii = Stripe_InvoiceItem::create($params, $this->_apiKey); | $ii = Stripe_InvoiceItem::create($params, $this->_apiKey); | ||||
| return $ii; | return $ii; | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns array An array of the customer's Stripe_Invoices. | |||||
| */ | |||||
| public function invoices($params=null) | public function invoices($params=null) | ||||
| { | { | ||||
| if (!$params) | if (!$params) | ||||
| $params = array(); | $params = array(); | ||||
| $params['customer'] = $this->id; | $params['customer'] = $this->id; | ||||
| $invoices = Stripe_Invoice::all($params, $this->_apiKey); | $invoices = Stripe_Invoice::all($params, $this->_apiKey); | ||||
| return $invoices; | return $invoices; | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns array An array of the customer's Stripe_InvoiceItems. | |||||
| */ | |||||
| public function invoiceItems($params=null) | public function invoiceItems($params=null) | ||||
| { | { | ||||
| if (!$params) | if (!$params) | ||||
| $params = array(); | $params = array(); | ||||
| $params['customer'] = $this->id; | $params['customer'] = $this->id; | ||||
| $iis = Stripe_InvoiceItem::all($params, $this->_apiKey); | $iis = Stripe_InvoiceItem::all($params, $this->_apiKey); | ||||
| return $iis; | return $iis; | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns array An array of the customer's Stripe_Charges. | |||||
| */ | |||||
| public function charges($params=null) | public function charges($params=null) | ||||
| { | { | ||||
| if (!$params) | if (!$params) | ||||
| $params = array(); | $params = array(); | ||||
| $params['customer'] = $this->id; | $params['customer'] = $this->id; | ||||
| $charges = Stripe_Charge::all($params, $this->_apiKey); | $charges = Stripe_Charge::all($params, $this->_apiKey); | ||||
| return $charges; | return $charges; | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns Stripe_Subscription The updated subscription. | |||||
| */ | |||||
| public function updateSubscription($params=null) | public function updateSubscription($params=null) | ||||
| { | { | ||||
| $requestor = new Stripe_ApiRequestor($this->_apiKey); | $requestor = new Stripe_ApiRequestor($this->_apiKey); | ||||
| $url = $this->instanceUrl() . '/subscription'; | $url = $this->instanceUrl() . '/subscription'; | ||||
| list($response, $apiKey) = $requestor->request('post', $url, $params); | list($response, $apiKey) = $requestor->request('post', $url, $params); | ||||
| $this->refreshFrom(array('subscription' => $response), $apiKey, true); | $this->refreshFrom(array('subscription' => $response), $apiKey, true); | ||||
| return $this->subscription; | return $this->subscription; | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns Stripe_Subscription The cancelled subscription. | |||||
| */ | |||||
| public function cancelSubscription($params=null) | public function cancelSubscription($params=null) | ||||
| { | { | ||||
| $requestor = new Stripe_ApiRequestor($this->_apiKey); | $requestor = new Stripe_ApiRequestor($this->_apiKey); | ||||
| $url = $this->instanceUrl() . '/subscription'; | $url = $this->instanceUrl() . '/subscription'; | ||||
| list($response, $apiKey) = $requestor->request('delete', $url, $params); | list($response, $apiKey) = $requestor->request('delete', $url, $params); | ||||
| $this->refreshFrom(array('subscription' => $response), $apiKey, true); | $this->refreshFrom(array('subscription' => $response), $apiKey, true); | ||||
| return $this->subscription; | return $this->subscription; | ||||
| } | } | ||||
| /** | |||||
| * @param array|null $params | |||||
| * | |||||
| * @returns Stripe_Customer The updated customer. | |||||
| */ | |||||
| public function deleteDiscount() | |||||
| { | |||||
| $requestor = new Stripe_ApiRequestor($this->_apiKey); | |||||
| $url = $this->instanceUrl() . '/discount'; | |||||
| list($response, $apiKey) = $requestor->request('delete', $url); | |||||
| $this->refreshFrom(array('discount' => null), $apiKey, true); | |||||
| } | |||||
| } | } | ||||