M2_Stripe_Customer

The Membership 2 M2 Stripe Customer class.

Defined (1)

The class is defined in the following location(s).

/lib/stripe-php/lib/Stripe/Customer.php  
  1. class M2_Stripe_Customer extends M2_Stripe_ApiResource 
  2. /** 
  3. * @param string $id The ID of the customer to retrieve. 
  4. * @param string|null $apiKey 
  5. * @return Stripe_Customer 
  6. */ 
  7. public static function retrieve($id, $apiKey=null) 
  8. $class = get_class(); 
  9. return self::_scopedRetrieve($class, $id, $apiKey); 
  10.  
  11. /** 
  12. * @param array|null $params 
  13. * @param string|null $apiKey 
  14. * @return array An array of Stripe_Customers. 
  15. */ 
  16. public static function all($params=null, $apiKey=null) 
  17. $class = get_class(); 
  18. return self::_scopedAll($class, $params, $apiKey); 
  19.  
  20. /** 
  21. * @param array|null $params 
  22. * @param string|null $apiKey 
  23. * @return Stripe_Customer The created customer. 
  24. */ 
  25. public static function create($params=null, $apiKey=null) 
  26. $class = get_class(); 
  27. return self::_scopedCreate($class, $params, $apiKey); 
  28.  
  29. /** 
  30. * @returns Stripe_Customer The saved customer. 
  31. */ 
  32. public function save() 
  33. $class = get_class(); 
  34. return self::_scopedSave($class); 
  35.  
  36. /** 
  37. * @param array|null $params 
  38. * @returns Stripe_Customer The deleted customer. 
  39. */ 
  40. public function delete($params=null) 
  41. $class = get_class(); 
  42. return self::_scopedDelete($class, $params); 
  43.  
  44. /** 
  45. * @param array|null $params 
  46. * @returns Stripe_InvoiceItem The resulting invoice item. 
  47. */ 
  48. public function addInvoiceItem($params=null) 
  49. if (!$params) 
  50. $params = array(); 
  51. $params['customer'] = $this->id; 
  52. $ii = M2_Stripe_InvoiceItem::create($params, $this->_apiKey); 
  53. return $ii; 
  54.  
  55. /** 
  56. * @param array|null $params 
  57. * @returns array An array of the customer's Stripe_Invoices. 
  58. */ 
  59. public function invoices($params=null) 
  60. if (!$params) 
  61. $params = array(); 
  62. $params['customer'] = $this->id; 
  63. $invoices = M2_Stripe_Invoice::all($params, $this->_apiKey); 
  64. return $invoices; 
  65.  
  66. /** 
  67. * @param array|null $params 
  68. * @returns array An array of the customer's Stripe_InvoiceItems. 
  69. */ 
  70. public function invoiceItems($params=null) 
  71. if (!$params) 
  72. $params = array(); 
  73. $params['customer'] = $this->id; 
  74. $iis = M2_Stripe_InvoiceItem::all($params, $this->_apiKey); 
  75. return $iis; 
  76.  
  77. /** 
  78. * @param array|null $params 
  79. * @returns array An array of the customer's Stripe_Charges. 
  80. */ 
  81. public function charges($params=null) 
  82. if (!$params) 
  83. $params = array(); 
  84. $params['customer'] = $this->id; 
  85. $charges = M2_Stripe_Charge::all($params, $this->_apiKey); 
  86. return $charges; 
  87.  
  88. /** 
  89. * @param array|null $params 
  90. * @returns Stripe_Subscription The updated subscription. 
  91. */ 
  92. public function updateSubscription($params=null) 
  93. $requestor = new M2_Stripe_ApiRequestor($this->_apiKey); 
  94. $url = $this->instanceUrl() . '/subscription'; 
  95. list($response, $apiKey) = $requestor->request('post', $url, $params); 
  96. $this->refreshFrom(array('subscription' => $response), $apiKey, true); 
  97. return $this->subscription; 
  98.  
  99. /** 
  100. * @param array|null $params 
  101. * @returns Stripe_Subscription The cancelled subscription. 
  102. */ 
  103. public function cancelSubscription($params=null) 
  104. $requestor = new M2_Stripe_ApiRequestor($this->_apiKey); 
  105. $url = $this->instanceUrl() . '/subscription'; 
  106. list($response, $apiKey) = $requestor->request('delete', $url, $params); 
  107. $this->refreshFrom(array('subscription' => $response), $apiKey, true); 
  108. return $this->subscription; 
  109.  
  110. /** 
  111. * @param array|null $params 
  112. * @returns Stripe_Customer The updated customer. 
  113. */ 
  114. public function deleteDiscount() 
  115. $requestor = new M2_Stripe_ApiRequestor($this->_apiKey); 
  116. $url = $this->instanceUrl() . '/discount'; 
  117. list($response, $apiKey) = $requestor->request('delete', $url); 
  118. $this->refreshFrom(array('discount' => null), $apiKey, true);