Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates #1439

Merged
merged 3 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v219
v223
2 changes: 2 additions & 0 deletions lib/CreditNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property int $amount The integer amount in %s representing the total amount of the credit note, including tax.
* @property int $amount_shipping This is the sum of all the shipping amounts.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @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>.
* @property string|\Stripe\Customer $customer ID of the customer.
Expand All @@ -30,6 +31,7 @@
* @property string $pdf The link to download the PDF of the credit note.
* @property null|string $reason Reason for issuing this credit note, one of <code>duplicate</code>, <code>fraudulent</code>, <code>order_change</code>, or <code>product_unsatisfactory</code>
* @property null|string|\Stripe\Refund $refund Refund related to this credit note.
* @property null|\Stripe\StripeObject $shipping_cost The details of the cost of shipping, including the ShippingRate applied to the invoice.
* @property string $status Status of this credit note, one of <code>issued</code> or <code>void</code>. Learn more about <a href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
* @property int $subtotal The integer amount in %s representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
* @property null|int $subtotal_excluding_tax The integer amount in %s representing the amount of the credit note, excluding all tax and invoice level discounts.
Expand Down
1 change: 1 addition & 0 deletions lib/CustomerCashBalanceTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CustomerCashBalanceTransaction extends ApiResource

const TYPE_APPLIED_TO_PAYMENT = 'applied_to_payment';
const TYPE_FUNDED = 'funded';
const TYPE_FUNDING_REVERSED = 'funding_reversed';
const TYPE_REFUNDED_FROM_PAYMENT = 'refunded_from_payment';
const TYPE_RETURN_CANCELED = 'return_canceled';
const TYPE_RETURN_INITIATED = 'return_initiated';
Expand Down
2 changes: 2 additions & 0 deletions lib/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ class Event extends ApiResource
const CUSTOMER_SOURCE_UPDATED = 'customer.source.updated';
const CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created';
const CUSTOMER_SUBSCRIPTION_DELETED = 'customer.subscription.deleted';
const CUSTOMER_SUBSCRIPTION_PAUSED = 'customer.subscription.paused';
const CUSTOMER_SUBSCRIPTION_PENDING_UPDATE_APPLIED = 'customer.subscription.pending_update_applied';
const CUSTOMER_SUBSCRIPTION_PENDING_UPDATE_EXPIRED = 'customer.subscription.pending_update_expired';
const CUSTOMER_SUBSCRIPTION_RESUMED = 'customer.subscription.resumed';
const CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END = 'customer.subscription.trial_will_end';
const CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated';
const CUSTOMER_TAX_ID_CREATED = 'customer.tax_id.created';
Expand Down
3 changes: 3 additions & 0 deletions lib/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* @property int $amount_due Final amount due at this time for this invoice. If the invoice's total is smaller than the minimum charge amount, for example, or if there is account credit that can be applied to the invoice, the <code>amount_due</code> may be 0. If there is a positive <code>starting_balance</code> for the invoice (the customer owes money), the <code>amount_due</code> will also take that into account. The charge that gets generated for the invoice will be for the amount specified in <code>amount_due</code>.
* @property int $amount_paid The amount, in %s, that was paid.
* @property int $amount_remaining The difference between amount_due and amount_paid, in %s.
* @property int $amount_shipping This is the sum of all the shipping amounts.
* @property null|string|\Stripe\StripeObject $application ID of the Connect Application that created the invoice.
* @property null|int $application_fee_amount The fee in %s that will be applied to the invoice and transferred to the application owner's Stripe account when the invoice is paid.
* @property int $attempt_count Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
Expand Down Expand Up @@ -100,6 +101,8 @@
* @property null|string|\Stripe\Quote $quote The quote this invoice was generated from.
* @property null|string $receipt_number This is the transaction number that appears on email receipts sent for this invoice.
* @property null|\Stripe\StripeObject $rendering_options Options for invoice PDF rendering.
* @property null|\Stripe\StripeObject $shipping_cost The details of the cost of shipping, including the ShippingRate applied on the invoice.
* @property null|\Stripe\StripeObject $shipping_details Shipping details for the invoice. The Invoice PDF will use the <code>shipping_details</code> value if it is set, otherwise the PDF will render the shipping address from the customer.
* @property int $starting_balance Starting customer balance before the invoice is finalized. If the invoice has not been finalized yet, this will be the current customer balance. For revision invoices, this also includes any customer balance that was applied to the original invoice.
* @property null|string $statement_descriptor Extra information about an invoice for the customer's credit card statement.
* @property null|string $status The status of the invoice, one of <code>draft</code>, <code>open</code>, <code>paid</code>, <code>uncollectible</code>, or <code>void</code>. <a href="https://stripe.com/docs/billing/invoices/workflow#workflow-overview">Learn more</a>
Expand Down
1 change: 1 addition & 0 deletions lib/PaymentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @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>.
* @property \Stripe\StripeObject $custom_text
* @property string $customer_creation Configuration for Customer creation during checkout.
* @property null|\Stripe\StripeObject $invoice_creation Configuration for creating invoice for payment mode payment links.
* @property \Stripe\Collection<\Stripe\LineItem> $line_items The line items representing what is being sold.
* @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.
* @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.
Expand Down
21 changes: 21 additions & 0 deletions lib/Service/SubscriptionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ public function deleteDiscount($id, $params = null, $opts = null)
return $this->request('delete', $this->buildPath('/v1/subscriptions/%s/discount', $id), $params, $opts);
}

/**
* Initiates resumption of a paused subscription, optionally resetting the billing
* cycle anchor and creating prorations. If a resumption invoice is generated, it
* must be paid or marked uncollectible before the subscription will be unpaused.
* If payment succeeds the subscription will become <code>active</code>, and if
* payment fails the subscription will be <code>past_due</code>. The resumption
* invoice will void automatically if not paid by the expiration date.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Subscription
*/
public function resume($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/subscriptions/%s/resume', $id), $params, $opts);
}

/**
* Retrieves the subscription with the given ID.
*
Expand Down
17 changes: 1 addition & 16 deletions lib/StripeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,12 @@ class StripeClient extends BaseStripeClient
*/
private $coreServiceFactory;

/**
* @param $name
*
* @return null|Service\AbstractService|Service\AbstractServiceFactory
*/
public function __get($name)
{
return $this->getService($name);
}

/**
* @param $name
*
* @return null|Service\AbstractService|Service\AbstractServiceFactory
*/
public function getService($name)
{
if (null === $this->coreServiceFactory) {
$this->coreServiceFactory = new \Stripe\Service\CoreServiceFactory($this);
}

return $this->coreServiceFactory->getService($name);
return $this->coreServiceFactory->__get($name);
}
}
19 changes: 19 additions & 0 deletions lib/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* @property null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this subscription belongs to.
* @property null|\Stripe\StripeObject $transfer_data The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices.
* @property null|int $trial_end If the subscription has a trial, the end of that trial.
* @property null|\Stripe\StripeObject $trial_settings Settings related to subscription trials.
* @property null|int $trial_start If the subscription has a trial, the beginning of that trial.
*/
class Subscription extends ApiResource
Expand All @@ -77,6 +78,7 @@ class Subscription extends ApiResource
const STATUS_INCOMPLETE = 'incomplete';
const STATUS_INCOMPLETE_EXPIRED = 'incomplete_expired';
const STATUS_PAST_DUE = 'past_due';
const STATUS_PAUSED = 'paused';
const STATUS_TRIALING = 'trialing';
const STATUS_UNPAID = 'unpaid';

Expand Down Expand Up @@ -130,6 +132,23 @@ public function cancel($params = null, $opts = null)
return $this;
}

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Subscription the resumed subscription
*/
public function resume($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/resume';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}

/**
* @param null|array $params
* @param null|array|string $opts
Expand Down
10 changes: 10 additions & 0 deletions tests/Stripe/GeneratedExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,16 @@ public function testUpdateCapability()
static::assertInstanceOf(\Stripe\Capability::class, $result);
}

public function testResumeSubscription()
{
$this->expectsRequest('post', '/v1/subscriptions/sub_xxxxxxxxxxxxx/resume');
$result = $this->client->subscriptions->resume(
'sub_xxxxxxxxxxxxx',
['proration_date' => 1675400000, 'proration_behavior' => 'always_invoice']
);
static::assertInstanceOf(\Stripe\Subscription::class, $result);
}

public function testCreateLoginLink()
{
$this->expectsRequest(
Expand Down