3 class Stripe_Subscription
extends Stripe_ApiResource
6 * @return string The API URL for this Stripe subscription.
8 public function instanceUrl()
11 $customer = $this['customer'];
13 throw new Stripe_InvalidRequestError(
14 "Could not determine which URL to request: " .
15 "class instance has invalid ID: $id",
19 $id = Stripe_ApiRequestor
::utf8($id);
20 $customer = Stripe_ApiRequestor
::utf8($customer);
22 $base = self
::classUrl('Stripe_Customer');
23 $customerExtn = urlencode($customer);
24 $extn = urlencode($id);
25 return "$base/$customerExtn/subscriptions/$extn";
29 * @param array|null $params
30 * @return Stripe_Subscription The deleted subscription.
32 public function cancel($params=null)
35 return self
::_scopedDelete($class, $params);
39 * @return Stripe_Subscription The saved subscription.
41 public function save()
44 return self
::_scopedSave($class);
48 * @return Stripe_Subscription The updated subscription.
50 public function deleteDiscount()
52 $requestor = new Stripe_ApiRequestor($this->_apiKey
);
53 $url = $this->instanceUrl() . '/discount';
54 list($response, $apiKey) = $requestor->request('delete', $url);
55 $this->refreshFrom(array('discount' => null), $apiKey, true);