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