Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / externals / stripe-php / lib / Stripe / Subscription.php
blobd7a4cc02d6dd504eebfd4f2ec601d2b8dc077186
1 <?php
3 class Stripe_Subscription extends Stripe_ApiResource
5 /**
6 * @return string The API URL for this Stripe subscription.
7 */
8 public function instanceUrl()
10 $id = $this['id'];
11 $customer = $this['customer'];
12 if (!$id) {
13 throw new Stripe_InvalidRequestError(
14 "Could not determine which URL to request: " .
15 "class instance has invalid ID: $id",
16 null
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";
28 /**
29 * @param array|null $params
30 * @return Stripe_Subscription The deleted subscription.
32 public function cancel($params=null)
34 $class = get_class();
35 return self::_scopedDelete($class, $params);
38 /**
39 * @return Stripe_Subscription The saved subscription.
41 public function save()
43 $class = get_class();
44 return self::_scopedSave($class);
47 /**
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);