M2_Stripe_Subscription

The Membership 2 M2 Stripe Subscription class.

Defined (1)

The class is defined in the following location(s).

/lib/stripe-php/lib/Stripe/Subscription.php  
  1. class M2_Stripe_Subscription extends M2_Stripe_ApiResource 
  2. /** 
  3. * @return string The API URL for this Stripe subscription. 
  4. */ 
  5. public function instanceUrl() 
  6. $id = $this['id']; 
  7. $customer = $this['customer']; 
  8. $class = get_class($this); 
  9. if (!$id) { 
  10. throw new M2_Stripe_InvalidRequestError( 
  11. "Could not determine which URL to request: " . 
  12. "class instance has invalid ID: $id",  
  13. null 
  14. ); 
  15. $id = M2_Stripe_ApiRequestor::utf8($id); 
  16. $customer = M2_Stripe_ApiRequestor::utf8($customer); 
  17.  
  18. $base = self::classUrl('M2_Stripe_Customer'); 
  19. $customerExtn = urlencode($customer); 
  20. $extn = urlencode($id); 
  21. return "$base/$customerExtn/subscriptions/$extn"; 
  22.  
  23. /** 
  24. * @param array|null $params 
  25. * @return Stripe_Subscription The deleted subscription. 
  26. */ 
  27. public function cancel($params=null) 
  28. $class = get_class(); 
  29. return self::_scopedDelete($class, $params); 
  30.  
  31. /** 
  32. * @return Stripe_Subscription The saved subscription. 
  33. */ 
  34. public function save() 
  35. $class = get_class(); 
  36. return self::_scopedSave($class); 
  37.  
  38. /** 
  39. * @return Stripe_Subscription The updated subscription. 
  40. */ 
  41. public function deleteDiscount() 
  42. $requestor = new M2_Stripe_ApiRequestor($this->_apiKey); 
  43. $url = $this->instanceUrl() . '/discount'; 
  44. list($response, $apiKey) = $requestor->request('delete', $url); 
  45. $this->refreshFrom(array('discount' => null), $apiKey, true);