ApiOperations
1 year ago
Apps
1 year ago
Billing
1 year ago
BillingPortal
1 year ago
Checkout
1 year ago
Climate
1 year ago
Entitlements
1 year ago
EventData
1 year ago
Events
1 year ago
Exception
1 year ago
FinancialConnections
1 year ago
Forwarding
1 year ago
HttpClient
1 year ago
Identity
1 year ago
Issuing
1 year ago
Radar
1 year ago
Reporting
1 year ago
Service
1 year ago
Sigma
1 year ago
Tax
1 year ago
Terminal
1 year ago
TestHelpers
1 year ago
Treasury
1 year ago
Util
1 year ago
V2
1 year ago
Account.php
1 year ago
AccountLink.php
1 year ago
AccountSession.php
1 year ago
ApiRequestor.php
1 year ago
ApiResource.php
2 years ago
ApiResponse.php
2 years ago
ApplePayDomain.php
1 year ago
Application.php
2 years ago
ApplicationFee.php
1 year ago
ApplicationFeeRefund.php
2 years ago
Balance.php
1 year ago
BalanceTransaction.php
1 year ago
BankAccount.php
1 year ago
BaseStripeClient.php
1 year ago
BaseStripeClientInterface.php
1 year ago
Capability.php
1 year ago
Card.php
1 year ago
CashBalance.php
2 years ago
Charge.php
1 year ago
Collection.php
1 year ago
ConfirmationToken.php
1 year ago
ConnectCollectionTransfer.php
2 years ago
CountrySpec.php
1 year ago
Coupon.php
1 year ago
CreditNote.php
1 year ago
CreditNoteLineItem.php
1 year ago
Customer.php
1 year ago
CustomerBalanceTransaction.php
2 years ago
CustomerCashBalanceTransaction.php
2 years ago
CustomerSession.php
1 year ago
Discount.php
1 year ago
Dispute.php
1 year ago
EphemeralKey.php
1 year ago
ErrorObject.php
1 year ago
Event.php
1 year ago
ExchangeRate.php
1 year ago
File.php
1 year ago
FileLink.php
1 year ago
FundingInstructions.php
2 years ago
Invoice.php
1 year ago
InvoiceItem.php
1 year ago
InvoiceLineItem.php
1 year ago
InvoiceRenderingTemplate.php
1 year ago
LineItem.php
1 year ago
LoginLink.php
1 year ago
Mandate.php
1 year ago
OAuth.php
2 years ago
OAuthErrorObject.php
1 year ago
PaymentIntent.php
1 year ago
PaymentLink.php
1 year ago
PaymentMethod.php
1 year ago
PaymentMethodConfiguration.php
1 year ago
PaymentMethodDomain.php
1 year ago
Payout.php
1 year ago
Person.php
1 year ago
Plan.php
1 year ago
Price.php
1 year ago
Product.php
1 year ago
ProductFeature.php
1 year ago
PromotionCode.php
1 year ago
Quote.php
1 year ago
Reason.php
1 year ago
RecipientTransfer.php
2 years ago
Refund.php
1 year ago
RelatedObject.php
1 year ago
RequestTelemetry.php
2 years ago
ReserveTransaction.php
2 years ago
Review.php
1 year ago
SearchResult.php
1 year ago
SetupAttempt.php
1 year ago
SetupIntent.php
1 year ago
ShippingRate.php
1 year ago
SingletonApiResource.php
2 years ago
Source.php
1 year ago
SourceMandateNotification.php
2 years ago
SourceTransaction.php
2 years ago
Stripe.php
1 year ago
StripeClient.php
1 year ago
StripeClientInterface.php
2 years ago
StripeObject.php
1 year ago
StripeStreamingClientInterface.php
2 years ago
Subscription.php
1 year ago
SubscriptionItem.php
1 year ago
SubscriptionSchedule.php
1 year ago
TaxCode.php
1 year ago
TaxDeductedAtSource.php
2 years ago
TaxId.php
1 year ago
TaxRate.php
1 year ago
ThinEvent.php
1 year ago
Token.php
1 year ago
Topup.php
1 year ago
Transfer.php
1 year ago
TransferReversal.php
1 year ago
UsageRecord.php
1 year ago
UsageRecordSummary.php
1 year ago
Webhook.php
1 year ago
WebhookEndpoint.php
1 year ago
WebhookSignature.php
2 years ago
Product.php
207 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | namespace WPForms\Vendor\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 = \WPForms\Vendor\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, \WPForms\Vendor\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 = \WPForms\Vendor\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 = \WPForms\Vendor\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, \WPForms\Vendor\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 |