Skip to content

Commit f900ec6

Browse files
committed
add phpdoc
1 parent a88597c commit f900ec6

File tree

2 files changed

+73
-24
lines changed

2 files changed

+73
-24
lines changed

src/Lib/StripeCustomer.php

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,24 @@ public function __construct()
4545

4646

4747
/**
48-
* set customer source (card) , email
49-
* https://stripe.com/docs/api/customers/create
50-
*
51-
* @param array $datas
48+
* Set customer name.
49+
*
50+
* @param string $data customer name
5251
* @return $this
5352
*/
54-
public function createl($datas)
55-
{
56-
foreach ($datas as $key => $data) {
57-
$this->createCustomerData[$key] = $data;
58-
}
53+
public function name($data) {
54+
$this->name = $data;
55+
return $this;
56+
}
5957

58+
/**
59+
* Set customer email.
60+
*
61+
* @param string $data customer email
62+
* @return $this
63+
*/
64+
public function email($data) {
65+
$this->email = $data;
6066
return $this;
6167
}
6268

@@ -72,16 +78,6 @@ public function metadata($data)
7278
return $this;
7379
}
7480

75-
public function name($data) {
76-
$this->name = $data;
77-
return $this;
78-
}
79-
80-
public function email($data) {
81-
$this->email = $data;
82-
return $this;
83-
}
84-
8581
/**
8682
* Create customer and return customer data
8783
*
@@ -111,9 +107,9 @@ public function create()
111107
}
112108

113109
/**
114-
* Retrive customer with $cusIdid.
110+
* Retrive customer with $id.
115111
*
116-
* @param string $id
112+
* @param string $id
117113
* @return object
118114
*/
119115
public function retrieve($id)
@@ -127,6 +123,12 @@ public function retrieve($id)
127123

128124
}
129125

126+
/**
127+
* Delete customer with $id
128+
*
129+
* @param string|integer $id
130+
* @return object
131+
*/
130132
public function delete($id) {
131133
try {
132134
$customer = $this->stripe->customers->delete($id);
@@ -136,6 +138,11 @@ public function delete($id) {
136138
}
137139
}
138140

141+
/**
142+
* Retrieve all customers.
143+
*
144+
* @return array
145+
*/
139146
public function lists() {
140147
try {
141148
$customers = $this->stripe->customers->all();
@@ -145,6 +152,12 @@ public function lists() {
145152
}
146153
}
147154

155+
/**
156+
* Retrieve customer all cards.
157+
*
158+
* @param string|integer $id customer id.
159+
* @return array
160+
*/
148161
public function cards($id)
149162
{
150163
try {
@@ -167,6 +180,13 @@ public function cards($id)
167180
}
168181
}
169182

183+
/**
184+
* Add new card for customer with customer id.
185+
*
186+
* @param string|integer $cusId
187+
* @param string $cardToken genearte by stripe.js ui side.
188+
* @param integer $max how many card can add for a customer.
189+
*/
170190
public function addCard($cusId, $cardToken, $max = 3)
171191
{
172192
try {
@@ -184,11 +204,17 @@ public function addCard($cusId, $cardToken, $max = 3)
184204
}
185205
}
186206

187-
public function deleteCard($cusId, $cardToken)
207+
/**
208+
* Delete a card
209+
*
210+
* @param string|integer $cusId
211+
* @param string $cardId card id
212+
*/
213+
public function deleteCard($cusId, $cardId)
188214
{
189215
try {
190216
if (count($this->cards($cusId)) > 1) {
191-
$customerSource = $this->stripe->customers->deleteSource($cusId, $cardToken);
217+
$customerSource = $this->stripe->customers->deleteSource($cusId, $cardId);
192218
return $customerSource;
193219
}
194220

src/Lib/StripeProducts.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@ public function __construct()
1717
$this->stripe = new StripeClient($this->secretKey);
1818
}
1919

20+
/**
21+
* Set the product name.
22+
*
23+
* @param string $name product name.
24+
* @return $this
25+
*/
2026
public function name($name)
2127
{
2228
$this->productName = $name;
2329
return $this;
2430
}
2531

26-
public function create()
32+
/**
33+
* Create a new product.
34+
*
35+
* @return object
36+
*/
37+
public function create()
2738
{
2839
$productData = [
2940
'name' => $this->productName
@@ -37,6 +48,12 @@ public function create()
3748
}
3849
}
3950

51+
/**
52+
* Retrieve a product with $id
53+
*
54+
* @param string|integer $id
55+
* @return object
56+
*/
4057
public function retrieve($id)
4158
{
4259
try {
@@ -47,6 +64,12 @@ public function retrieve($id)
4764
}
4865
}
4966

67+
/**
68+
* Delete a product with $id
69+
*
70+
* @param string|integer $id
71+
* @return object
72+
*/
5073
public function delete($id)
5174
{
5275
try {

0 commit comments

Comments
 (0)