19
19
class StripeSubscription
20
20
{
21
21
/**
22
- * Secret key
22
+ * Secret key.
23
23
* @var string
24
24
*/
25
25
private $ secretKey ;
26
26
/**
27
- * Customer all data after create
27
+ * Customer all data after create.
28
28
* @var object
29
29
*/
30
30
private $ customer ;
31
31
32
+ /**
33
+ * All data which properties of create the subscription.
34
+ * @var array
35
+ */
32
36
private $ createSubscriptionData = [];
33
37
38
+ /**
39
+ * Plan which will be subcription.
40
+ * @var string
41
+ */
34
42
private $ plan ;
35
43
44
+ /**
45
+ * Add others properties of create the subscription.
46
+ * @var array
47
+ */
36
48
private $ extra = [];
37
- // trail day from plan
49
+
50
+ /**
51
+ * Trial default from plan.
52
+ * @var boolean
53
+ */
38
54
private $ trialPlan = false ;
39
55
56
+ /**
57
+ * How many trial day for subscription.
58
+ * This will be override the plan trial day.
59
+ * @var integer
60
+ */
40
61
private $ trial ;
62
+
63
+ /**
64
+ * Subcription with coupon.
65
+ * @var string
66
+ */
41
67
private $ coupon ;
42
68
43
69
public function __construct ()
@@ -47,7 +73,7 @@ public function __construct()
47
73
}
48
74
}
49
75
/**
50
- * Set secret key
76
+ * Set secret key.
51
77
* @param string $data
52
78
* @return $this
53
79
*/
@@ -59,18 +85,33 @@ public function setup($data)
59
85
return $ this ;
60
86
}
61
87
88
+ /**
89
+ * set customer id which create by customer alias.
90
+ * @param string $id customer id
91
+ * @return $this
92
+ */
62
93
public function customer ($ id )
63
94
{
64
95
$ this ->customer = $ id ;
65
96
return $ this ;
66
97
}
67
98
99
+ /**
100
+ * Plan id which generate by LaraStripePlan alias.
101
+ * @param string $id plan id
102
+ * @return $this
103
+ */
68
104
public function plan ($ id )
69
105
{
70
106
$ this ->plan = $ id ;
71
107
return $ this ;
72
108
}
73
109
110
+ /**
111
+ * stripe subscription others properties which not declare this package.
112
+ * @param array $data
113
+ * @return $this
114
+ */
74
115
public function extra ($ data = [])
75
116
{
76
117
if (is_array ($ data )) {
@@ -79,22 +120,41 @@ public function extra($data = [])
79
120
return $ this ;
80
121
}
81
122
123
+ /**
124
+ * Default trial time from plan.
125
+ * @return $this
126
+ */
82
127
public function trialPlan ()
83
128
{
84
129
$ this ->trialPlan = true ;
85
130
return $ this ;
86
131
}
87
132
133
+ /**
134
+ * Set subscription trial.
135
+ * override the plan trial day.
136
+ * @param integer $day
137
+ * @return $this
138
+ */
88
139
public function trial ($ day ) {
89
140
$ this ->trial = $ day ;
90
141
return $ this ;
91
142
}
92
143
144
+ /**
145
+ * Coupon apply
146
+ * @param string $code
147
+ * @return $this
148
+ */
93
149
public function coupon ($ code ) {
94
150
$ this ->coupon = $ code ;
95
151
return $ this ;
96
152
}
97
153
154
+ /**
155
+ * Create & retreive all data.
156
+ * @return object
157
+ */
98
158
public function get ()
99
159
{
100
160
$ this ->createSubscriptionData ['customer ' ] = $ this ->customer ;
@@ -119,6 +179,11 @@ public function get()
119
179
}
120
180
}
121
181
182
+ /**
183
+ * Retrieve a subscription with id
184
+ * @param string $id
185
+ * @return object
186
+ */
122
187
public function retrieve ($ id )
123
188
{
124
189
try {
@@ -130,6 +195,11 @@ public function retrieve($id)
130
195
}
131
196
}
132
197
198
+ /**
199
+ * Cancel a subscription.
200
+ * @param string $id
201
+ * @return object
202
+ */
133
203
public function cancel ($ id )
134
204
{
135
205
try {
0 commit comments