10
10
* Stripe Create Plan Request
11
11
*
12
12
* @see \Omnipay\Stripe\Gateway
13
- * @link https://stripe.com/docs/api#create_plan
13
+ * @link https://stripe.com/docs/api/plans/create
14
14
*/
15
15
class CreatePlanRequest extends AbstractRequest
16
16
{
@@ -79,27 +79,30 @@ public function getIntervalCount()
79
79
80
80
/**
81
81
* Set the plan name
82
+ * @deprecated use setNickname() instead
82
83
*
83
84
* @param $value
84
85
* @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
85
86
*/
86
87
public function setName ($ value )
87
88
{
88
- return $ this ->setParameter ( ' name ' , $ value );
89
+ return $ this ->setNickname ( $ value );
89
90
}
90
91
91
92
/**
92
93
* Get the plan name
94
+ * @deprecated use getNickname() instead
93
95
*
94
96
* @return string
95
97
*/
96
98
public function getName ()
97
99
{
98
- return $ this ->getParameter ( ' name ' );
100
+ return $ this ->getNickname ( );
99
101
}
100
102
101
103
/**
102
104
* Set the plan statement descriptor
105
+ * @deprecated Not used anymore
103
106
*
104
107
* @param $planStatementDescriptor
105
108
* @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
@@ -111,6 +114,7 @@ public function setStatementDescriptor($planStatementDescriptor)
111
114
112
115
/**
113
116
* Get the plan statement descriptor
117
+ * @deprecated Not used anymore
114
118
*
115
119
* @return string
116
120
*/
@@ -119,6 +123,192 @@ public function getStatementDescriptor()
119
123
return $ this ->getParameter ('statement_descriptor ' );
120
124
}
121
125
126
+ /**
127
+ * Set the plan product
128
+ *
129
+ * @param $value
130
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
131
+ */
132
+ public function setProduct ($ value )
133
+ {
134
+ return $ this ->setParameter ('product ' , $ value );
135
+ }
136
+
137
+ /**
138
+ * Get the plan product
139
+ *
140
+ * @return string|array
141
+ */
142
+ public function getProduct ()
143
+ {
144
+ return $ this ->getParameter ('product ' );
145
+ }
146
+
147
+ /**
148
+ * Set the plan amount
149
+ * @param $value
150
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
151
+ */
152
+ public function setAmount ($ value )
153
+ {
154
+ return $ this ->setParameter ('amount ' , (integer )$ value );
155
+ }
156
+
157
+ /**
158
+ * Get the plan amount
159
+ *
160
+ * @return int
161
+ */
162
+ public function getAmount ()
163
+ {
164
+ return $ this ->getParameter ('amount ' );
165
+ }
166
+
167
+ /**
168
+ * Set the plan tiers
169
+ * @param $value
170
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
171
+ */
172
+ public function setTiers ($ value )
173
+ {
174
+ return $ this ->setParameter ('tiers ' , $ value );
175
+ }
176
+
177
+ /**
178
+ * Get the plan tiers
179
+ *
180
+ * @return int
181
+ */
182
+ public function getTiers ()
183
+ {
184
+ return $ this ->getParameter ('tiers ' );
185
+ }
186
+
187
+ /**
188
+ * Set the plan tiers mode
189
+ * @param $value
190
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
191
+ */
192
+ public function setTiersMode ($ value )
193
+ {
194
+ return $ this ->setParameter ('tiers_mode ' , $ value );
195
+ }
196
+
197
+ /**
198
+ * Get the plan tiers mode
199
+ *
200
+ * @return int
201
+ */
202
+ public function getTiersMode ()
203
+ {
204
+ return $ this ->getParameter ('tiers_mode ' );
205
+ }
206
+
207
+ /**
208
+ * Set the plan nickname
209
+ *
210
+ * @param $value
211
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
212
+ */
213
+ public function setNickname ($ value )
214
+ {
215
+ return $ this ->setParameter ('nickname ' , $ value );
216
+ }
217
+
218
+ /**
219
+ * Get the plan nickname
220
+ *
221
+ * @return string|array
222
+ */
223
+ public function getNickname ()
224
+ {
225
+ return $ this ->getParameter ('nickname ' );
226
+ }
227
+
228
+ /**
229
+ * Set the plan metadata
230
+ *
231
+ * @param $value
232
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
233
+ */
234
+ public function setMetadata ($ value )
235
+ {
236
+ return $ this ->setParameter ('metadata ' , $ value );
237
+ }
238
+
239
+ /**
240
+ * Get the plan metadata
241
+ *
242
+ * @return string|array
243
+ */
244
+ public function getMetadata ()
245
+ {
246
+ return $ this ->getParameter ('metadata ' );
247
+ }
248
+
249
+ /**
250
+ * Set the plan active
251
+ *
252
+ * @param $value
253
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
254
+ */
255
+ public function setActive ($ value )
256
+ {
257
+ return $ this ->setParameter ('active ' , $ value );
258
+ }
259
+
260
+ /**
261
+ * Get the plan active
262
+ *
263
+ * @return string|array
264
+ */
265
+ public function getActive ()
266
+ {
267
+ return $ this ->getParameter ('active ' );
268
+ }
269
+
270
+ /**
271
+ * Set the plan billingScheme
272
+ *
273
+ * @param $value
274
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
275
+ */
276
+ public function setBillingScheme ($ value )
277
+ {
278
+ return $ this ->setParameter ('billing_scheme ' , $ value );
279
+ }
280
+
281
+ /**
282
+ * Get the plan billingScheme
283
+ *
284
+ * @return string|array
285
+ */
286
+ public function getBillingScheme ()
287
+ {
288
+ return $ this ->getParameter ('billing_scheme ' );
289
+ }
290
+
291
+ /**
292
+ * Set the plan aggregate usage
293
+ *
294
+ * @param $planAggregateUsage
295
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
296
+ */
297
+ public function setAggregateUsage ($ planAggregateUsage )
298
+ {
299
+ return $ this ->setParameter ('aggregate_usage ' , $ planAggregateUsage );
300
+ }
301
+
302
+ /**
303
+ * Get the plan aggregate usage
304
+ *
305
+ * @return string
306
+ */
307
+ public function getAggregateUsage ()
308
+ {
309
+ return $ this ->getParameter ('aggregate_usage ' );
310
+ }
311
+
122
312
/**
123
313
* Set the plan trial period days
124
314
*
@@ -140,31 +330,114 @@ public function getTrialPeriodDays()
140
330
return $ this ->getParameter ('trial_period_days ' );
141
331
}
142
332
333
+ /**
334
+ * Set the plan transform usage
335
+ *
336
+ * @param $value
337
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
338
+ */
339
+ public function setTransformUsage ($ value )
340
+ {
341
+ return $ this ->setParameter ('transform_usage ' , $ value );
342
+ }
343
+
344
+ /**
345
+ * Get the plan transform usage
346
+ *
347
+ * @return int
348
+ */
349
+ public function getTransformUsage ()
350
+ {
351
+ return $ this ->getParameter ('transform_usage ' );
352
+ }
353
+
354
+ /**
355
+ * Set the plan usage type
356
+ *
357
+ * @param $value
358
+ * @return \Omnipay\Common\Message\AbstractRequest|CreatePlanRequest
359
+ */
360
+ public function setUsageType ($ value )
361
+ {
362
+ return $ this ->setParameter ('usage_type ' , $ value );
363
+ }
364
+
365
+ /**
366
+ * Get the plan usage type
367
+ *
368
+ * @return int
369
+ */
370
+ public function getUsageType ()
371
+ {
372
+ return $ this ->getParameter ('usage_type ' );
373
+ }
374
+
143
375
public function getData ()
144
376
{
145
- $ this ->validate ('id ' , 'amount ' , 'currency ' , 'interval ' , 'name ' );
377
+ $ this ->validate ('currency ' , 'interval ' , 'product ' );
378
+
379
+ if (null == $ this ->getBillingScheme () || 'per_unit ' == $ this ->getBillingScheme ()) {
380
+ $ this ->validate ('amount ' );
381
+ } elseif ('tiered ' == $ this ->getBillingScheme ()) {
382
+ $ this ->validate ('tiers ' , 'tiers_mode ' );
383
+ }
146
384
147
385
$ data = array (
148
- 'id ' => $ this ->getId (),
149
- 'amount ' => $ this ->getAmountInteger (),
150
386
'currency ' => $ this ->getCurrency (),
151
387
'interval ' => $ this ->getInterval (),
152
- 'name ' => $ this ->getName ()
388
+ 'product ' => $ this ->getProduct ()
153
389
);
154
390
155
- $ intervalCount = $ this ->getIntervalCount ();
156
- if ($ intervalCount != null ) {
157
- $ data ['interval_count ' ] = $ intervalCount ;
391
+ if (null != $ this ->getBillingScheme ()) {
392
+ $ data ['billing_scheme ' ] = $ this ->getBillingScheme ();
393
+ }
394
+
395
+ if (null != $ this ->getId ()) {
396
+ $ data ['id ' ] = $ this ->getId ();
397
+ }
398
+
399
+ if (null != $ this ->getAmount ()) {
400
+ $ data ['amount ' ] = $ this ->getAmount ();
401
+ }
402
+
403
+ if (null != $ this ->getNickName ()) {
404
+ $ data ['nickname ' ] = $ this ->getNickName ();
405
+ }
406
+
407
+ if (null != $ this ->getMetadata ()) {
408
+ $ data ['metadata ' ] = $ this ->getMetadata ();
409
+ }
410
+
411
+ if (null != $ this ->getActive ()) {
412
+ $ data ['active ' ] = $ this ->getActive ();
413
+ }
414
+
415
+ if (null != $ this ->getIntervalCount ()) {
416
+ $ data ['interval_count ' ] = $ this ->getIntervalCount ();
417
+ }
418
+
419
+ if (null != $ this ->getAggregateUsage ()) {
420
+ $ data ['aggregate_usage ' ] = $ this ->getAggregateUsage ();
421
+ }
422
+
423
+ if (null != $ this ->getTrialPeriodDays ()) {
424
+ $ data ['trial_period_days ' ] = $ this ->getTrialPeriodDays ();
425
+ }
426
+
427
+ if (null != $ this ->getTransformUsage ()) {
428
+ $ data ['transform_usage ' ] = $ this ->getTransformUsage ();
429
+ }
430
+
431
+ if (null != $ this ->getUsageType ()) {
432
+ $ data ['usage_type ' ] = $ this ->getUsageType ();
158
433
}
159
434
160
- $ statementDescriptor = $ this ->getStatementDescriptor ();
161
- if ($ statementDescriptor != null ) {
162
- $ data ['statement_descriptor ' ] = $ statementDescriptor ;
435
+ if (null != $ this ->getTiers ()) {
436
+ $ data ['tiers ' ] = $ this ->getTiers ();
163
437
}
164
438
165
- $ trialPeriodDays = $ this ->getTrialPeriodDays ();
166
- if ($ trialPeriodDays != null ) {
167
- $ data ['trial_period_days ' ] = $ trialPeriodDays ;
439
+ if (null != $ this ->getTiersMode ()) {
440
+ $ data ['tiers_mode ' ] = $ this ->getTiersMode ();
168
441
}
169
442
170
443
return $ data ;
0 commit comments