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
PromotionCode.php
105 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | namespace ProfilePressVendor\Stripe; |
| 5 | |
| 6 | /** |
| 7 | * A Promotion Code represents a customer-redeemable code for a <a href="https://stripe.com/docs/api#coupons">coupon</a>. It can be used to |
| 8 | * create multiple codes for a single coupon. |
| 9 | * |
| 10 | * @property string $id Unique identifier for the object. |
| 11 | * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 12 | * @property bool $active Whether the promotion code is currently active. A promotion code is only active if the coupon is also valid. |
| 13 | * @property string $code The customer-facing code. Regardless of case, this code must be unique across all active promotion codes for each customer. Valid characters are lower case letters (a-z), upper case letters (A-Z), and digits (0-9). |
| 14 | * @property \Stripe\Coupon $coupon A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer. Coupons may be applied to <a href="https://stripe.com/docs/api#subscriptions">subscriptions</a>, <a href="https://stripe.com/docs/api#invoices">invoices</a>, <a href="https://stripe.com/docs/api/checkout/sessions">checkout sessions</a>, <a href="https://stripe.com/docs/api#quotes">quotes</a>, and more. Coupons do not work with conventional one-off <a href="https://stripe.com/docs/api#create_charge">charges</a> or <a href="https://stripe.com/docs/api/payment_intents">payment intents</a>. |
| 15 | * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. |
| 16 | * @property null|string|\Stripe\Customer $customer The customer that this promotion code can be used by. |
| 17 | * @property null|int $expires_at Date at which the promotion code can no longer be redeemed. |
| 18 | * @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. |
| 19 | * @property null|int $max_redemptions Maximum number of times this promotion code can be redeemed. |
| 20 | * @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. |
| 21 | * @property \Stripe\StripeObject $restrictions |
| 22 | * @property int $times_redeemed Number of times this promotion code has been used. |
| 23 | */ |
| 24 | class PromotionCode extends ApiResource |
| 25 | { |
| 26 | const OBJECT_NAME = 'promotion_code'; |
| 27 | use ApiOperations\Update; |
| 28 | /** |
| 29 | * A promotion code points to a coupon. You can optionally restrict the code to a |
| 30 | * specific customer, redemption limit, and expiration date. |
| 31 | * |
| 32 | * @param null|array $params |
| 33 | * @param null|array|string $options |
| 34 | * |
| 35 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 36 | * |
| 37 | * @return \Stripe\PromotionCode the created resource |
| 38 | */ |
| 39 | public static function create($params = null, $options = null) |
| 40 | { |
| 41 | self::_validateParams($params); |
| 42 | $url = static::classUrl(); |
| 43 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 44 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 45 | $obj->setLastResponse($response); |
| 46 | return $obj; |
| 47 | } |
| 48 | /** |
| 49 | * Returns a list of your promotion codes. |
| 50 | * |
| 51 | * @param null|array $params |
| 52 | * @param null|array|string $opts |
| 53 | * |
| 54 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 55 | * |
| 56 | * @return \Stripe\Collection<\Stripe\PromotionCode> of ApiResources |
| 57 | */ |
| 58 | public static function all($params = null, $opts = null) |
| 59 | { |
| 60 | $url = static::classUrl(); |
| 61 | return static::_requestPage($url, \ProfilePressVendor\Stripe\Collection::class, $params, $opts); |
| 62 | } |
| 63 | /** |
| 64 | * Retrieves the promotion code with the given ID. In order to retrieve a promotion |
| 65 | * code by the customer-facing <code>code</code> use <a |
| 66 | * href="/docs/api/promotion_codes/list">list</a> with the desired |
| 67 | * <code>code</code>. |
| 68 | * |
| 69 | * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key |
| 70 | * @param null|array|string $opts |
| 71 | * |
| 72 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 73 | * |
| 74 | * @return \Stripe\PromotionCode |
| 75 | */ |
| 76 | public static function retrieve($id, $opts = null) |
| 77 | { |
| 78 | $opts = \ProfilePressVendor\Stripe\Util\RequestOptions::parse($opts); |
| 79 | $instance = new static($id, $opts); |
| 80 | $instance->refresh(); |
| 81 | return $instance; |
| 82 | } |
| 83 | /** |
| 84 | * Updates the specified promotion code by setting the values of the parameters |
| 85 | * passed. Most fields are, by design, not editable. |
| 86 | * |
| 87 | * @param string $id the ID of the resource to update |
| 88 | * @param null|array $params |
| 89 | * @param null|array|string $opts |
| 90 | * |
| 91 | * @throws \Stripe\Exception\ApiErrorException if the request fails |
| 92 | * |
| 93 | * @return \Stripe\PromotionCode the updated resource |
| 94 | */ |
| 95 | public static function update($id, $params = null, $opts = null) |
| 96 | { |
| 97 | self::_validateParams($params); |
| 98 | $url = static::resourceUrl($id); |
| 99 | list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); |
| 100 | $obj = \ProfilePressVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 101 | $obj->setLastResponse($response); |
| 102 | return $obj; |
| 103 | } |
| 104 | } |
| 105 |