10
10
* Stripe Update Subscription Request
11
11
*
12
12
* @see \Omnipay\Stripe\Gateway
13
- * @link https://stripe.com/docs/api#update_subscription
13
+ * @link https://stripe.com/docs/api/subscriptions/update
14
14
*/
15
15
class UpdateSubscriptionRequest extends AbstractRequest
16
16
{
@@ -74,9 +74,22 @@ public function setSubscriptionReference($value)
74
74
return $ this ->setParameter ('subscriptionReference ' , $ value );
75
75
}
76
76
77
+ /**
78
+ * @return bool
79
+ */
80
+ public function getCancelAtPeriodEnd ()
81
+ {
82
+ return $ this ->getParameter ('cancel_at_period_end ' );
83
+ }
84
+
85
+ public function setCancelAtPeriodEnd ($ value )
86
+ {
87
+ return $ this ->setParameter ('cancel_at_period_end ' , $ value );
88
+ }
89
+
77
90
public function getData ()
78
91
{
79
- $ this ->validate ('customerReference ' , ' subscriptionReference ' , 'plan ' );
92
+ $ this ->validate ('subscriptionReference ' , 'plan ' );
80
93
81
94
$ data = array (
82
95
'plan ' => $ this ->getPlan ()
@@ -86,6 +99,10 @@ public function getData()
86
99
$ data ['tax_percent ' ] = (float )$ this ->getParameter ('tax_percent ' );
87
100
}
88
101
102
+ if ($ this ->parameters ->has ('cancel_at_period_end ' )) {
103
+ $ data ['cancel_at_period_end ' ] = $ this ->getCancelAtPeriodEnd () ? 'true ' : 'false ' ;
104
+ }
105
+
89
106
if ($ this ->getMetadata ()) {
90
107
$ data ['metadata ' ] = $ this ->getMetadata ();
91
108
}
@@ -95,7 +112,9 @@ public function getData()
95
112
96
113
public function getEndpoint ()
97
114
{
98
- return $ this ->endpoint .'/customers/ ' .$ this ->getCustomerReference ()
99
- .'/subscriptions/ ' .$ this ->getSubscriptionReference ();
115
+ return $ this ->getCustomerReference () ?
116
+ $ this ->endpoint .'/customers/ ' .$ this ->getCustomerReference ()
117
+ .'/subscriptions/ ' .$ this ->getSubscriptionReference () :
118
+ $ this ->endpoint .'/subscriptions/ ' .$ this ->getSubscriptionReference ();
100
119
}
101
120
}
0 commit comments