File tree 2 files changed +36
-0
lines changed 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -26,19 +26,50 @@ public function getSubscriptionReference()
26
26
/**
27
27
* Set the set subscription reference.
28
28
*
29
+ * @param string $value
30
+ *
29
31
* @return CancelSubscriptionRequest provides a fluent interface.
30
32
*/
31
33
public function setSubscriptionReference ($ value )
32
34
{
33
35
return $ this ->setParameter ('subscriptionReference ' , $ value );
34
36
}
35
37
38
+ /**
39
+ * Set whether or not to cancel the subscription at period end.
40
+ *
41
+ * @param bool $value
42
+ *
43
+ * @return CancelSubscriptionRequest provides a fluent interface.
44
+ */
45
+ public function setAtPeriodEnd ($ value )
46
+ {
47
+ return $ this ->setParameter ('atPeriodEnd ' , $ value );
48
+ }
49
+
50
+ /**
51
+ * Get whether or not to cancel the subscription at period end.
52
+ *
53
+ * @return bool
54
+ */
55
+ public function getAtPeriodEnd ()
56
+ {
57
+ return $ this ->getParameter ('atPeriodEnd ' );
58
+ }
59
+
36
60
public function getData ()
37
61
{
38
62
$ this ->validate ('customerReference ' , 'subscriptionReference ' );
39
63
40
64
$ data = array ();
41
65
66
+ // NOTE: Boolean must be passed as string
67
+ // Otherwise it will be converted to numeric 0 or 1
68
+ // Causing an error with the API
69
+ if ($ this ->getAtPeriodEnd ()) {
70
+ $ data ['at_period_end ' ] = 'true ' ;
71
+ }
72
+
42
73
return $ data ;
43
74
}
44
75
Original file line number Diff line number Diff line change @@ -11,11 +11,16 @@ public function setUp()
11
11
$ this ->request = new CancelSubscriptionRequest ($ this ->getHttpClient (), $ this ->getHttpRequest ());
12
12
$ this ->request ->setCustomerReference ('cus_7lfqk3Om3t4xSU ' );
13
13
$ this ->request ->setSubscriptionReference ('sub_7mU0FokE8GQZFW ' );
14
+ $ this ->request ->setAtPeriodEnd (true );
14
15
}
15
16
16
17
public function testEndpoint ()
17
18
{
18
19
$ this ->assertSame ('https://api.stripe.com/v1/customers/cus_7lfqk3Om3t4xSU/subscriptions/sub_7mU0FokE8GQZFW ' , $ this ->request ->getEndpoint ());
20
+ $ this ->assertSame (true , $ this ->request ->getAtPeriodEnd ());
21
+
22
+ $ data = $ this ->request ->getData ();
23
+ $ this ->assertSame ('true ' , $ data ['at_period_end ' ]);
19
24
}
20
25
21
26
public function testSendSuccess ()
You can’t perform that action at this time.
0 commit comments