JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbrexpand[]=discounts to expand each discount. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. * @property \Stripe\Plan $plan

You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.

Plans define the base price, currency, and billing cycle for recurring purchases of products. Products help you track inventory or provisioning, and plans help you track pricing. Different physical goods or levels of service should be represented by products, and pricing options should be represented by plans. This approach lets you change prices without having to change your provisioning scheme.

For example, you might have a single "gold" product that has plans for $10/month, $100/year, €9/month, and €90/year.

Related guides: Set up a subscription and more about products and prices.

* @property \Stripe\Price $price

Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products. Products help you track inventory or provisioning, and prices help you track payment terms. Different physical goods or levels of service should be represented by products, and pricing options should be represented by prices. This approach lets you change prices without having to change your provisioning scheme.

For example, you might have a single "gold" product that has prices for $10/month, $100/year, and €9 once.

Related guides: Set up a subscription, create an invoice, and more about products and prices.

* @property null|int $quantity The quantity of the plan to which the customer should be subscribed. * @property string $subscription The subscription this subscription_item belongs to. * @property null|\Stripe\TaxRate[] $tax_rates The tax rates which apply to this subscription_item. When set, the default_tax_rates on the subscription do not apply to this subscription_item. */ class SubscriptionItem extends ApiResource { const OBJECT_NAME = 'subscription_item'; use ApiOperations\NestedResource; use ApiOperations\Update; /** * Adds a new item to an existing subscription. No existing items will be changed * or replaced. * * @param null|array $params * @param null|array|string $options * * @throws \Stripe\Exception\ApiErrorException if the request fails * * @return \Stripe\SubscriptionItem the created resource */ public static function create($params = null, $options = null) { self::_validateParams($params); $url = static::classUrl(); list($response, $opts) = static::_staticRequest('post', $url, $params, $options); $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); $obj->setLastResponse($response); return $obj; } /** * Deletes an item from the subscription. Removing a subscription item from a * subscription will not cancel the subscription. * * @param null|array $params * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * * @return \Stripe\SubscriptionItem the deleted resource */ public function delete($params = null, $opts = null) { self::_validateParams($params); $url = $this->instanceUrl(); list($response, $opts) = $this->_request('delete', $url, $params, $opts); $this->refreshFrom($response, $opts); return $this; } /** * Returns a list of your subscription items for a given subscription. * * @param null|array $params * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * * @return \Stripe\Collection<\Stripe\SubscriptionItem> of ApiResources */ public static function all($params = null, $opts = null) { $url = static::classUrl(); return static::_requestPage($url, \Stripe\Collection::class, $params, $opts); } /** * Retrieves the subscription item with the given ID. * * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * * @return \Stripe\SubscriptionItem */ public static function retrieve($id, $opts = null) { $opts = \Stripe\Util\RequestOptions::parse($opts); $instance = new static($id, $opts); $instance->refresh(); return $instance; } /** * Updates the plan or quantity of an item on a current subscription. * * @param string $id the ID of the resource to update * @param null|array $params * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * * @return \Stripe\SubscriptionItem the updated resource */ public static function update($id, $params = null, $opts = null) { self::_validateParams($params); $url = static::resourceUrl($id); list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); $obj->setLastResponse($response); return $obj; } const PATH_USAGE_RECORDS = '/usage_records'; /** * @param string $id the ID of the subscription item on which to create the usage record * @param null|array $params * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * * @return \Stripe\UsageRecord */ public static function createUsageRecord($id, $params = null, $opts = null) { return self::_createNestedResource($id, static::PATH_USAGE_RECORDS, $params, $opts); } const PATH_USAGE_RECORD_SUMMARIES = '/usage_record_summaries'; /** * @param string $id the ID of the subscription item on which to retrieve the usage record summaries * @param null|array $params * @param null|array|string $opts * * @throws \Stripe\Exception\ApiErrorException if the request fails * * @return \Stripe\Collection<\Stripe\UsageRecordSummary> the list of usage record summaries */ public static function allUsageRecordSummaries($id, $params = null, $opts = null) { return self::_allNestedResources($id, static::PATH_USAGE_RECORD_SUMMARIES, $params, $opts); } }