Update Stripe PHP API
Summary: Ref T2787. This brings us up to date. Test Plan: `git clone` Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T2787 Differential Revision: https://secure.phabricator.com/D9916
This commit is contained in:
57
externals/stripe-php/lib/Stripe/Subscription.php
vendored
Normal file
57
externals/stripe-php/lib/Stripe/Subscription.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
class Stripe_Subscription extends Stripe_ApiResource
|
||||
{
|
||||
/**
|
||||
* @return string The API URL for this Stripe subscription.
|
||||
*/
|
||||
public function instanceUrl()
|
||||
{
|
||||
$id = $this['id'];
|
||||
$customer = $this['customer'];
|
||||
if (!$id) {
|
||||
throw new Stripe_InvalidRequestError(
|
||||
"Could not determine which URL to request: " .
|
||||
"class instance has invalid ID: $id",
|
||||
null
|
||||
);
|
||||
}
|
||||
$id = Stripe_ApiRequestor::utf8($id);
|
||||
$customer = Stripe_ApiRequestor::utf8($customer);
|
||||
|
||||
$base = self::classUrl('Stripe_Customer');
|
||||
$customerExtn = urlencode($customer);
|
||||
$extn = urlencode($id);
|
||||
return "$base/$customerExtn/subscriptions/$extn";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $params
|
||||
* @return Stripe_Subscription The deleted subscription.
|
||||
*/
|
||||
public function cancel($params=null)
|
||||
{
|
||||
$class = get_class();
|
||||
return self::_scopedDelete($class, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Stripe_Subscription The saved subscription.
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$class = get_class();
|
||||
return self::_scopedSave($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Stripe_Subscription The updated subscription.
|
||||
*/
|
||||
public function deleteDiscount()
|
||||
{
|
||||
$requestor = new Stripe_ApiRequestor($this->_apiKey);
|
||||
$url = $this->instanceUrl() . '/discount';
|
||||
list($response, $apiKey) = $requestor->request('delete', $url);
|
||||
$this->refreshFrom(array('discount' => null), $apiKey, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user