ApiOperations
6 years ago
Checkout
6 years ago
Error
6 years ago
HttpClient
6 years ago
Issuing
6 years ago
Radar
6 years ago
Reporting
6 years ago
Sigma
6 years ago
Terminal
6 years ago
Util
6 years ago
Account.php
6 years ago
AccountLink.php
6 years ago
AlipayAccount.php
6 years ago
ApiRequestor.php
6 years ago
ApiResource.php
6 years ago
ApiResponse.php
6 years ago
ApplePayDomain.php
6 years ago
ApplicationFee.php
6 years ago
ApplicationFeeRefund.php
6 years ago
Balance.php
6 years ago
BalanceTransaction.php
6 years ago
BankAccount.php
6 years ago
BitcoinReceiver.php
6 years ago
BitcoinTransaction.php
6 years ago
Capability.php
6 years ago
Card.php
6 years ago
Charge.php
6 years ago
Collection.php
6 years ago
CountrySpec.php
6 years ago
Coupon.php
6 years ago
CreditNote.php
6 years ago
Customer.php
6 years ago
CustomerBalanceTransaction.php
6 years ago
Discount.php
6 years ago
Dispute.php
6 years ago
EphemeralKey.php
6 years ago
Event.php
6 years ago
ExchangeRate.php
6 years ago
File.php
6 years ago
FileLink.php
6 years ago
FileUpload.php
6 years ago
Invoice.php
6 years ago
InvoiceItem.php
6 years ago
InvoiceLineItem.php
6 years ago
IssuerFraudRecord.php
6 years ago
LoginLink.php
6 years ago
OAuth.php
6 years ago
Order.php
6 years ago
OrderItem.php
6 years ago
OrderReturn.php
6 years ago
PaymentIntent.php
6 years ago
PaymentMethod.php
6 years ago
Payout.php
6 years ago
Person.php
6 years ago
Plan.php
6 years ago
Product.php
6 years ago
Recipient.php
6 years ago
RecipientTransfer.php
6 years ago
Refund.php
6 years ago
RequestTelemetry.php
6 years ago
Review.php
6 years ago
SKU.php
6 years ago
SetupIntent.php
6 years ago
SingletonApiResource.php
6 years ago
Source.php
6 years ago
SourceTransaction.php
6 years ago
Stripe.php
6 years ago
StripeObject.php
6 years ago
Subscription.php
6 years ago
SubscriptionItem.php
6 years ago
SubscriptionSchedule.php
6 years ago
TaxId.php
6 years ago
TaxRate.php
6 years ago
ThreeDSecure.php
6 years ago
Token.php
6 years ago
Topup.php
6 years ago
Transfer.php
6 years ago
TransferReversal.php
6 years ago
UsageRecord.php
6 years ago
UsageRecordSummary.php
6 years ago
Webhook.php
6 years ago
WebhookEndpoint.php
6 years ago
WebhookSignature.php
6 years ago
Subscription.php
100 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Stripe; |
| 4 | |
| 5 | /** |
| 6 | * Class Subscription |
| 7 | * |
| 8 | * @property string $id |
| 9 | * @property string $object |
| 10 | * @property float $application_fee_percent |
| 11 | * @property string $billing |
| 12 | * @property int $billing_cycle_anchor |
| 13 | * @property mixed $billing_thresholds |
| 14 | * @property bool $cancel_at_period_end |
| 15 | * @property int $canceled_at |
| 16 | * @property string $collection_method |
| 17 | * @property int $created |
| 18 | * @property int $current_period_end |
| 19 | * @property int $current_period_start |
| 20 | * @property string $customer |
| 21 | * @property int $days_until_due |
| 22 | * @property string $default_payment_method |
| 23 | * @property string $default_source |
| 24 | * @property array $default_tax_rates |
| 25 | * @property Discount $discount |
| 26 | * @property int $ended_at |
| 27 | * @property Collection $items |
| 28 | * @property string $latest_invoice |
| 29 | * @property boolean $livemode |
| 30 | * @property StripeObject $metadata |
| 31 | * @property string $pending_setup_intent |
| 32 | * @property Plan $plan |
| 33 | * @property int $quantity |
| 34 | * @property SubscriptionSchedule $schedule |
| 35 | * @property int $start |
| 36 | * @property int $start_date |
| 37 | * @property string $status |
| 38 | * @property float $tax_percent |
| 39 | * @property int $trial_end |
| 40 | * @property int $trial_start |
| 41 | * |
| 42 | * @package Stripe |
| 43 | */ |
| 44 | class Subscription extends ApiResource |
| 45 | { |
| 46 | const OBJECT_NAME = "subscription"; |
| 47 | |
| 48 | use ApiOperations\All; |
| 49 | use ApiOperations\Create; |
| 50 | use ApiOperations\Delete { |
| 51 | delete as protected _delete; |
| 52 | } |
| 53 | use ApiOperations\Retrieve; |
| 54 | use ApiOperations\Update; |
| 55 | |
| 56 | /** |
| 57 | * These constants are possible representations of the status field. |
| 58 | * |
| 59 | * @link https://stripe.com/docs/api#subscription_object-status |
| 60 | */ |
| 61 | const STATUS_ACTIVE = 'active'; |
| 62 | const STATUS_CANCELED = 'canceled'; |
| 63 | const STATUS_PAST_DUE = 'past_due'; |
| 64 | const STATUS_TRIALING = 'trialing'; |
| 65 | const STATUS_UNPAID = 'unpaid'; |
| 66 | const STATUS_INCOMPLETE = 'incomplete'; |
| 67 | const STATUS_INCOMPLETE_EXPIRED = 'incomplete_expired'; |
| 68 | |
| 69 | public static function getSavedNestedResources() |
| 70 | { |
| 71 | static $savedNestedResources = null; |
| 72 | if ($savedNestedResources === null) { |
| 73 | $savedNestedResources = new Util\Set([ |
| 74 | 'source', |
| 75 | ]); |
| 76 | } |
| 77 | return $savedNestedResources; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @param array|null $params |
| 82 | * |
| 83 | * @return Subscription The deleted subscription. |
| 84 | */ |
| 85 | public function cancel($params = null, $opts = null) |
| 86 | { |
| 87 | return $this->_delete($params, $opts); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * @return Subscription The updated subscription. |
| 92 | */ |
| 93 | public function deleteDiscount() |
| 94 | { |
| 95 | $url = $this->instanceUrl() . '/discount'; |
| 96 | list($response, $opts) = $this->_request('delete', $url); |
| 97 | $this->refreshFrom(['discount' => null], $opts, true); |
| 98 | } |
| 99 | } |
| 100 |