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
Product.php
207 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | namespace ProfilePressVendor\Stripe; |
| 5 | |
| 6 | /** |
| 7 | * Products describe the specific goods or services you offer to your customers. |
| 8 | * For example, you might offer a Standard and Premium version of your goods or service; each version would be a separate Product. |
| 9 | * They can be used in conjunction with <a href="https://stripe.com/docs/api#prices">Prices</a> to configure pricing in Payment Links, Checkout, and Subscriptions. |
| 10 | * |
| 11 | * Related guides: <a href="https://stripe.com/docs/billing/subscriptions/set-up-subscription">Set up a subscription</a>, |
| 12 | * <a href="https://stripe.com/docs/payment-links">share a Payment Link</a>, |
| 13 | * <a href="https://stripe.com/docs/payments/accept-a-payment#create-product-prices-upfront">accept payments with Checkout</a>, |
| 14 | * 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 product is currently available for purchase. |
| 19 | * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. |
| 20 | * @property null|string|\Stripe\Price $default_price The ID of the <a href="https://stripe.com/docs/api/prices">Price</a> object that is the default price for this product. |
| 21 | * @property null|string $description The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. |
| 22 | * @property string[] $images A list of up to 8 URLs of images for this product, meant to be displayable to the customer. |
| 23 | * @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. |
| 24 | * @property \Stripe\StripeObject[] $marketing_features A list of up to 15 marketing features for this product. These are displayed in <a href="https://stripe.com/docs/payments/checkout/pricing-table">pricing tables</a>. |
| 25 | * @property \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. |
| 26 | * @property string $name The product's name, meant to be displayable to the customer. |
| 27 | * @property null|\Stripe\StripeObject $package_dimensions The dimensions of this product for shipping purposes. |
| 28 | * @property null|bool $shippable Whether this product is shipped (i.e., physical goods). |
| 29 | * @property null|string $statement_descriptor Extra information about a product which will appear on your customer's credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. Only used for subscription payments. |
| 30 | * @property null|string|\Stripe\TaxCode $tax_code A <a href="https://stripe.com/docs/tax/tax-categories">tax code</a> ID. |
| 31 | * @property string $type The type of the product. The product is either of type <code>good</code>, which is eligible for use with Orders and SKUs, or <code>service</code>, which is eligible for use with Subscriptions and Plans. |
| 32 | * @property null|string $unit_label A label that represents units of this product. When set, this will be included in customers' receipts, invoices, Checkout, and the customer portal. |
| 33 | * @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch. |
| 34 | * @property null|string $url A URL of a publicly-accessible webpage for this product. |
| 35 | */ |
| 36 | class Product extends ApiResource |
| 37 | { |
| 38 | const OBJECT_NAME = 'product'; |
| 39 | use ApiOperations\NestedResource; |
| 40 | use ApiOperations\Update; |
| 41 | const TYPE_GOOD = 'good'; |
| 42 | const TYPE_SERVICE = 'service'; |
| 43 | /** |
| 44 | * Creates a new product object. |
| 45 | * |
| 46 | * @param null|array $params |
| 47 | * @param null|array|string $options |
| 48 | * |
| 49 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 50 | * |
| 51 | * @return \Stripe\Product the created resource |
| 52 | */ |
| 53 | public static function create($params = null, $options = null) |
| 54 | { |
| 55 | self::_validateParams($params); |
| 56 | $url = static::classUrl(); |
| 57 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 58 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 59 | $obj->setLastResponse($response); |
| 60 | return $obj; |
| 61 | } |
| 62 | /** |
| 63 | * Delete a product. Deleting a product is only possible if it has no prices |
| 64 | * associated with it. Additionally, deleting a product with <code>type=good</code> |
| 65 | * is only possible if it has no SKUs associated with it. |
| 66 | * |
| 67 | * @param null|array $params |
| 68 | * @param null|array|string $opts |
| 69 | * |
| 70 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 71 | * |
| 72 | * @return \Stripe\Product the deleted resource |
| 73 | */ |
| 74 | public function delete($params = null, $opts = null) |
| 75 | { |
| 76 | self::_validateParams($params); |
| 77 | $url = $this->instanceUrl(); |
| 78 | list($response, $opts) = $this->_request('delete', $url, $params, $opts); |
| 79 | $this->refreshFrom($response, $opts); |
| 80 | return $this; |
| 81 | } |
| 82 | /** |
| 83 | * Returns a list of your products. The products are returned sorted by creation |
| 84 | * date, with the most recently created products appearing first. |
| 85 | * |
| 86 | * @param null|array $params |
| 87 | * @param null|array|string $opts |
| 88 | * |
| 89 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 90 | * |
| 91 | * @return \Stripe\Collection<\Stripe\Product> of ApiResources |
| 92 | */ |
| 93 | public static function all($params = null, $opts = null) |
| 94 | { |
| 95 | $url = static::classUrl(); |
| 96 | return static::_requestPage($url, \ProfilePressVendor\Stripe\Collection::class, $params, $opts); |
| 97 | } |
| 98 | /** |
| 99 | * Retrieves the details of an existing product. Supply the unique product ID from |
| 100 | * either a product creation request or the product list, and Stripe will return |
| 101 | * the corresponding product information. |
| 102 | * |
| 103 | * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key |
| 104 | * @param null|array|string $opts |
| 105 | * |
| 106 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 107 | * |
| 108 | * @return \Stripe\Product |
| 109 | */ |
| 110 | public static function retrieve($id, $opts = null) |
| 111 | { |
| 112 | $opts = \ProfilePressVendor\Stripe\Util\RequestOptions::parse($opts); |
| 113 | $instance = new static($id, $opts); |
| 114 | $instance->refresh(); |
| 115 | return $instance; |
| 116 | } |
| 117 | /** |
| 118 | * Updates the specific product by setting the values of the parameters passed. Any |
| 119 | * parameters not provided will be left unchanged. |
| 120 | * |
| 121 | * @param string $id the ID of the resource to update |
| 122 | * @param null|array $params |
| 123 | * @param null|array|string $opts |
| 124 | * |
| 125 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 126 | * |
| 127 | * @return \Stripe\Product the updated resource |
| 128 | */ |
| 129 | public static function update($id, $params = null, $opts = null) |
| 130 | { |
| 131 | self::_validateParams($params); |
| 132 | $url = static::resourceUrl($id); |
| 133 | list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); |
| 134 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 135 | $obj->setLastResponse($response); |
| 136 | return $obj; |
| 137 | } |
| 138 | /** |
| 139 | * @param null|array $params |
| 140 | * @param null|array|string $opts |
| 141 | * |
| 142 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 143 | * |
| 144 | * @return \Stripe\SearchResult<\Stripe\Product> the product search results |
| 145 | */ |
| 146 | public static function search($params = null, $opts = null) |
| 147 | { |
| 148 | $url = '/v1/products/search'; |
| 149 | return static::_requestPage($url, \ProfilePressVendor\Stripe\SearchResult::class, $params, $opts); |
| 150 | } |
| 151 | const PATH_FEATURES = '/features'; |
| 152 | /** |
| 153 | * @param string $id the ID of the product on which to retrieve the product features |
| 154 | * @param null|array $params |
| 155 | * @param null|array|string $opts |
| 156 | * |
| 157 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 158 | * |
| 159 | * @return \Stripe\Collection<\Stripe\ProductFeature> the list of product features |
| 160 | */ |
| 161 | public static function allFeatures($id, $params = null, $opts = null) |
| 162 | { |
| 163 | return self::_allNestedResources($id, static::PATH_FEATURES, $params, $opts); |
| 164 | } |
| 165 | /** |
| 166 | * @param string $id the ID of the product on which to create the product feature |
| 167 | * @param null|array $params |
| 168 | * @param null|array|string $opts |
| 169 | * |
| 170 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 171 | * |
| 172 | * @return \Stripe\ProductFeature |
| 173 | */ |
| 174 | public static function createFeature($id, $params = null, $opts = null) |
| 175 | { |
| 176 | return self::_createNestedResource($id, static::PATH_FEATURES, $params, $opts); |
| 177 | } |
| 178 | /** |
| 179 | * @param string $id the ID of the product to which the product feature belongs |
| 180 | * @param string $featureId the ID of the product feature to delete |
| 181 | * @param null|array $params |
| 182 | * @param null|array|string $opts |
| 183 | * |
| 184 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 185 | * |
| 186 | * @return \Stripe\ProductFeature |
| 187 | */ |
| 188 | public static function deleteFeature($id, $featureId, $params = null, $opts = null) |
| 189 | { |
| 190 | return self::_deleteNestedResource($id, static::PATH_FEATURES, $featureId, $params, $opts); |
| 191 | } |
| 192 | /** |
| 193 | * @param string $id the ID of the product to which the product feature belongs |
| 194 | * @param string $featureId the ID of the product feature to retrieve |
| 195 | * @param null|array $params |
| 196 | * @param null|array|string $opts |
| 197 | * |
| 198 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 199 | * |
| 200 | * @return \Stripe\ProductFeature |
| 201 | */ |
| 202 | public static function retrieveFeature($id, $featureId, $params = null, $opts = null) |
| 203 | { |
| 204 | return self::_retrieveNestedResource($id, static::PATH_FEATURES, $featureId, $params, $opts); |
| 205 | } |
| 206 | } |
| 207 |