99 * Stripe Cancel Subscription Request.
1010 *
1111 * @see \Omnipay\Stripe\Gateway
12- * @link https://stripe.com/docs/api/#cancel_subscription
12+ * @link https://stripe.com/docs/api/subscriptions/cancel
1313 */
1414class CancelSubscriptionRequest extends AbstractRequest
1515{
@@ -35,49 +35,28 @@ public function setSubscriptionReference($value)
3535 return $ this ->setParameter ('subscriptionReference ' , $ value );
3636 }
3737
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-
6038 public function getData ()
6139 {
62- $ this ->validate ('customerReference ' , ' subscriptionReference ' );
40+ $ this ->validate ('subscriptionReference ' );
6341
64- $ data = array ();
42+ if ($ this ->parameters ->has ('invoice_now ' )) {
43+ $ data ['invoice_now ' ] = $ this ->getParameter ('invoice_now ' ) ? 'true ' : 'false ' ;
44+ }
6545
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 ' ;
46+ if ($ this ->parameters ->has ('prorate ' )) {
47+ $ data ['prorate ' ] = $ this ->getParameter ('prorate ' ) ? 'true ' : 'false ' ;
7148 }
7249
73- return $ data ;
50+ return array () ;
7451 }
7552
7653 public function getEndpoint ()
7754 {
78- return $ this ->endpoint
79- .'/customers/ ' .$ this ->getCustomerReference ()
80- .'/subscriptions/ ' .$ this ->getSubscriptionReference ();
55+ return $ this ->getCustomerReference () ?
56+ $ this ->endpoint
57+ .'/customers/ ' .$ this ->getCustomerReference ()
58+ .'/subscriptions/ ' .$ this ->getSubscriptionReference () :
59+ $ this ->endpoint .'/subscriptions/ ' .$ this ->getSubscriptionReference ();
8160 }
8261
8362 public function getHttpMethod ()
0 commit comments