ApiOperations
2 months ago
Apps
2 months ago
Billing
2 months ago
BillingPortal
2 months ago
Checkout
2 months ago
Climate
2 months ago
Entitlements
2 months ago
EventData
2 months ago
Events
2 months ago
Exception
2 months ago
FinancialConnections
2 months ago
Forwarding
2 months ago
HttpClient
2 months ago
Identity
2 months ago
Issuing
2 months ago
Radar
2 months ago
Reporting
2 months ago
Service
2 months ago
Sigma
2 months ago
Tax
2 months ago
Terminal
2 months ago
TestHelpers
2 months ago
Treasury
2 months ago
Util
2 months ago
V2
2 months ago
Account.php
2 months ago
AccountLink.php
2 months ago
AccountSession.php
2 months ago
ApiRequestor.php
2 months ago
ApiResource.php
2 months ago
ApiResponse.php
2 months ago
ApplePayDomain.php
2 months ago
Application.php
2 months ago
ApplicationFee.php
2 months ago
ApplicationFeeRefund.php
2 months ago
Balance.php
2 months ago
BalanceTransaction.php
2 months ago
BankAccount.php
2 months ago
BaseStripeClient.php
2 months ago
BaseStripeClientInterface.php
2 months ago
Capability.php
2 months ago
Card.php
2 months ago
CashBalance.php
2 months ago
Charge.php
2 months ago
Collection.php
2 months ago
ConfirmationToken.php
2 months ago
ConnectCollectionTransfer.php
2 months ago
CountrySpec.php
2 months ago
Coupon.php
2 months ago
CreditNote.php
2 months ago
CreditNoteLineItem.php
2 months ago
Customer.php
2 months ago
CustomerBalanceTransaction.php
2 months ago
CustomerCashBalanceTransaction.php
2 months ago
CustomerSession.php
2 months ago
Discount.php
2 months ago
Dispute.php
2 months ago
EphemeralKey.php
2 months ago
ErrorObject.php
2 months ago
Event.php
2 months ago
ExchangeRate.php
2 months ago
File.php
2 months ago
FileLink.php
2 months ago
FundingInstructions.php
2 months ago
Invoice.php
2 months ago
InvoiceItem.php
2 months ago
InvoiceLineItem.php
2 months ago
InvoiceRenderingTemplate.php
2 months ago
LineItem.php
2 months ago
LoginLink.php
2 months ago
Mandate.php
2 months ago
OAuth.php
2 months ago
OAuthErrorObject.php
2 months ago
PaymentIntent.php
2 months ago
PaymentLink.php
2 months ago
PaymentMethod.php
2 months ago
PaymentMethodConfiguration.php
2 months ago
PaymentMethodDomain.php
2 months ago
Payout.php
2 months ago
Person.php
2 months ago
Plan.php
2 months ago
Price.php
2 months ago
Product.php
2 months ago
ProductFeature.php
2 months ago
PromotionCode.php
2 months ago
Quote.php
2 months ago
Reason.php
2 months ago
RecipientTransfer.php
2 months ago
Refund.php
2 months ago
RelatedObject.php
2 months ago
RequestTelemetry.php
2 months ago
ReserveTransaction.php
2 months ago
Review.php
2 months ago
SearchResult.php
2 months ago
SetupAttempt.php
2 months ago
SetupIntent.php
2 months ago
ShippingRate.php
2 months ago
SingletonApiResource.php
2 months ago
Source.php
2 months ago
SourceMandateNotification.php
2 months ago
SourceTransaction.php
2 months ago
Stripe.php
2 months ago
StripeClient.php
2 months ago
StripeClientInterface.php
2 months ago
StripeObject.php
2 months ago
StripeStreamingClientInterface.php
2 months ago
Subscription.php
2 months ago
SubscriptionItem.php
2 months ago
SubscriptionSchedule.php
2 months ago
TaxCode.php
2 months ago
TaxDeductedAtSource.php
2 months ago
TaxId.php
2 months ago
TaxRate.php
2 months ago
ThinEvent.php
2 months ago
Token.php
2 months ago
Topup.php
2 months ago
Transfer.php
2 months ago
TransferReversal.php
2 months ago
UsageRecord.php
2 months ago
UsageRecordSummary.php
2 months ago
Webhook.php
2 months ago
WebhookEndpoint.php
2 months ago
WebhookSignature.php
2 months ago
Plan.php
151 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | namespace ProfilePressVendor\Stripe; |
| 5 | |
| 6 | /** |
| 7 | * You can now model subscriptions more flexibly using the <a href="https://stripe.com/docs/api#prices">Prices API</a>. It replaces the Plans API and is backwards compatible to simplify your migration. |
| 8 | * |
| 9 | * Plans define the base price, currency, and billing cycle for recurring purchases of products. |
| 10 | * <a href="https://stripe.com/docs/api#products">Products</a> 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. |
| 11 | * |
| 12 | * For example, you might have a single "gold" product that has plans for $10/month, $100/year, €9/month, and €90/year. |
| 13 | * |
| 14 | * Related guides: <a href="https://stripe.com/docs/billing/subscriptions/set-up-subscription">Set up a subscription</a> and more about <a href="https://stripe.com/docs/products-prices/overview">products and prices</a>. |
| 15 | * |
| 16 | * @property string $id Unique identifier for the object. |
| 17 | * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 18 | * @property bool $active Whether the plan can be used for new purchases. |
| 19 | * @property null|string $aggregate_usage Specifies a usage aggregation strategy for plans of <code>usage_type=metered</code>. Allowed values are <code>sum</code> for summing up all usage during a period, <code>last_during_period</code> for using the last usage record reported within a period, <code>last_ever</code> for using the last usage record ever (across period bounds) or <code>max</code> which uses the usage record with the maximum reported usage during a period. Defaults to <code>sum</code>. |
| 20 | * @property null|int $amount The unit amount in cents (or local equivalent) to be charged, represented as a whole integer if possible. Only set if <code>billing_scheme=per_unit</code>. |
| 21 | * @property null|string $amount_decimal The unit amount in cents (or local equivalent) to be charged, represented as a decimal string with at most 12 decimal places. Only set if <code>billing_scheme=per_unit</code>. |
| 22 | * @property string $billing_scheme Describes how to compute the price per period. Either <code>per_unit</code> or <code>tiered</code>. <code>per_unit</code> indicates that the fixed amount (specified in <code>amount</code>) will be charged per unit in <code>quantity</code> (for plans with <code>usage_type=licensed</code>), or per unit of total usage (for plans with <code>usage_type=metered</code>). <code>tiered</code> indicates that the unit pricing will be computed using a tiering strategy as defined using the <code>tiers</code> and <code>tiers_mode</code> attributes. |
| 23 | * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. |
| 24 | * @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>. |
| 25 | * @property string $interval The frequency at which a subscription is billed. One of <code>day</code>, <code>week</code>, <code>month</code> or <code>year</code>. |
| 26 | * @property int $interval_count The number of intervals (specified in the <code>interval</code> attribute) between subscription billings. For example, <code>interval=month</code> and <code>interval_count=3</code> bills every 3 months. |
| 27 | * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode. |
| 28 | * @property null|\Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format. |
| 29 | * @property null|string $meter The meter tracking the usage of a metered price |
| 30 | * @property null|string $nickname A brief description of the plan, hidden from customers. |
| 31 | * @property null|string|\Stripe\Product $product The product whose pricing this plan determines. |
| 32 | * @property null|\Stripe\StripeObject[] $tiers Each element represents a pricing tier. This parameter requires <code>billing_scheme</code> to be set to <code>tiered</code>. See also the documentation for <code>billing_scheme</code>. |
| 33 | * @property null|string $tiers_mode Defines if the tiering price should be <code>graduated</code> or <code>volume</code> based. In <code>volume</code>-based tiering, the maximum quantity within a period determines the per unit price. In <code>graduated</code> tiering, pricing can change as the quantity grows. |
| 34 | * @property null|\Stripe\StripeObject $transform_usage Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with <code>tiers</code>. |
| 35 | * @property null|int $trial_period_days Default number of trial days when subscribing a customer to this plan using <a href="https://stripe.com/docs/api#create_subscription-trial_from_plan"><code>trial_from_plan=true</code></a>. |
| 36 | * @property string $usage_type Configures how the quantity per period should be determined. Can be either <code>metered</code> or <code>licensed</code>. <code>licensed</code> automatically bills the <code>quantity</code> set when adding it to a subscription. <code>metered</code> aggregates the total usage based on usage records. Defaults to <code>licensed</code>. |
| 37 | */ |
| 38 | class Plan extends ApiResource |
| 39 | { |
| 40 | const OBJECT_NAME = 'plan'; |
| 41 | use ApiOperations\Update; |
| 42 | const AGGREGATE_USAGE_LAST_DURING_PERIOD = 'last_during_period'; |
| 43 | const AGGREGATE_USAGE_LAST_EVER = 'last_ever'; |
| 44 | const AGGREGATE_USAGE_MAX = 'max'; |
| 45 | const AGGREGATE_USAGE_SUM = 'sum'; |
| 46 | const BILLING_SCHEME_PER_UNIT = 'per_unit'; |
| 47 | const BILLING_SCHEME_TIERED = 'tiered'; |
| 48 | const INTERVAL_DAY = 'day'; |
| 49 | const INTERVAL_MONTH = 'month'; |
| 50 | const INTERVAL_WEEK = 'week'; |
| 51 | const INTERVAL_YEAR = 'year'; |
| 52 | const TIERS_MODE_GRADUATED = 'graduated'; |
| 53 | const TIERS_MODE_VOLUME = 'volume'; |
| 54 | const USAGE_TYPE_LICENSED = 'licensed'; |
| 55 | const USAGE_TYPE_METERED = 'metered'; |
| 56 | /** |
| 57 | * You can now model subscriptions more flexibly using the <a href="#prices">Prices |
| 58 | * API</a>. It replaces the Plans API and is backwards compatible to simplify your |
| 59 | * migration. |
| 60 | * |
| 61 | * @param null|array $params |
| 62 | * @param null|array|string $options |
| 63 | * |
| 64 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 65 | * |
| 66 | * @return \Stripe\Plan the created resource |
| 67 | */ |
| 68 | public static function create($params = null, $options = null) |
| 69 | { |
| 70 | self::_validateParams($params); |
| 71 | $url = static::classUrl(); |
| 72 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 73 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 74 | $obj->setLastResponse($response); |
| 75 | return $obj; |
| 76 | } |
| 77 | /** |
| 78 | * Deleting plans means new subscribers can’t be added. Existing subscribers aren’t |
| 79 | * affected. |
| 80 | * |
| 81 | * @param null|array $params |
| 82 | * @param null|array|string $opts |
| 83 | * |
| 84 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 85 | * |
| 86 | * @return \Stripe\Plan the deleted resource |
| 87 | */ |
| 88 | public function delete($params = null, $opts = null) |
| 89 | { |
| 90 | self::_validateParams($params); |
| 91 | $url = $this->instanceUrl(); |
| 92 | list($response, $opts) = $this->_request('delete', $url, $params, $opts); |
| 93 | $this->refreshFrom($response, $opts); |
| 94 | return $this; |
| 95 | } |
| 96 | /** |
| 97 | * Returns a list of your plans. |
| 98 | * |
| 99 | * @param null|array $params |
| 100 | * @param null|array|string $opts |
| 101 | * |
| 102 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 103 | * |
| 104 | * @return \Stripe\Collection<\Stripe\Plan> of ApiResources |
| 105 | */ |
| 106 | public static function all($params = null, $opts = null) |
| 107 | { |
| 108 | $url = static::classUrl(); |
| 109 | return static::_requestPage($url, \ProfilePressVendor\Stripe\Collection::class, $params, $opts); |
| 110 | } |
| 111 | /** |
| 112 | * Retrieves the plan with the given ID. |
| 113 | * |
| 114 | * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key |
| 115 | * @param null|array|string $opts |
| 116 | * |
| 117 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 118 | * |
| 119 | * @return \Stripe\Plan |
| 120 | */ |
| 121 | public static function retrieve($id, $opts = null) |
| 122 | { |
| 123 | $opts = \ProfilePressVendor\Stripe\Util\RequestOptions::parse($opts); |
| 124 | $instance = new static($id, $opts); |
| 125 | $instance->refresh(); |
| 126 | return $instance; |
| 127 | } |
| 128 | /** |
| 129 | * Updates the specified plan by setting the values of the parameters passed. Any |
| 130 | * parameters not provided are left unchanged. By design, you cannot change a |
| 131 | * plan’s ID, amount, currency, or billing cycle. |
| 132 | * |
| 133 | * @param string $id the ID of the resource to update |
| 134 | * @param null|array $params |
| 135 | * @param null|array|string $opts |
| 136 | * |
| 137 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 138 | * |
| 139 | * @return \Stripe\Plan the updated resource |
| 140 | */ |
| 141 | public static function update($id, $params = null, $opts = null) |
| 142 | { |
| 143 | self::_validateParams($params); |
| 144 | $url = static::resourceUrl($id); |
| 145 | list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); |
| 146 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 147 | $obj->setLastResponse($response); |
| 148 | return $obj; |
| 149 | } |
| 150 | } |
| 151 |