diff --git a/CHANGELOG.md b/CHANGELOG.md index 689e5d097..bb3cd1fd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,18 @@ # Changelog +## 10.5.0 - 2023-02-02 +* [#1439](https://github.com/stripe/stripe-php/pull/1439) API Updates + * Add support for `resume` method on resource `Subscription` + * Add support for `amount_shipping` and `shipping_cost` on `CreditNote` and `Invoice` + * Add support for `shipping_details` on `Invoice` + * Add support for `invoice_creation` on `PaymentLink` + * Add support for `trial_settings` on `Subscription` + * Add support for new value `paused` on enum `Subscription.status` + ## 10.5.0-beta.2 - 2023-01-26 * [#1429](https://github.com/stripe/stripe-php/pull/1429) API Updates for beta branch * Updated stable APIs to the latest version - * Add support for `list_transactions` method on resource `Tax.Transaction` + * Add support for `list_transactions` method on resource `Tax.Transaction` ## 10.5.0-beta.1 - 2023-01-19 * [#1427](https://github.com/stripe/stripe-php/pull/1427) API Updates for beta branch diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 73d5d6e51..4e134f2a9 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v221 \ No newline at end of file +v223 \ No newline at end of file diff --git a/init.php b/init.php index e01e6b0f4..17327513e 100644 --- a/init.php +++ b/init.php @@ -117,7 +117,9 @@ require __DIR__ . '/lib/FinancialConnections/Account.php'; require __DIR__ . '/lib/FinancialConnections/AccountOwner.php'; require __DIR__ . '/lib/FinancialConnections/AccountOwnership.php'; +require __DIR__ . '/lib/FinancialConnections/InferredBalance.php'; require __DIR__ . '/lib/FinancialConnections/Session.php'; +require __DIR__ . '/lib/FinancialConnections/Transaction.php'; require __DIR__ . '/lib/FundingInstructions.php'; require __DIR__ . '/lib/GiftCards/Card.php'; require __DIR__ . '/lib/GiftCards/Transaction.php'; @@ -223,6 +225,7 @@ require __DIR__ . '/lib/Service/FileLinkService.php'; require __DIR__ . '/lib/Service/FinancialConnections/AccountService.php'; require __DIR__ . '/lib/Service/FinancialConnections/SessionService.php'; +require __DIR__ . '/lib/Service/FinancialConnections/TransactionService.php'; require __DIR__ . '/lib/Service/GiftCards/CardService.php'; require __DIR__ . '/lib/Service/GiftCards/TransactionService.php'; require __DIR__ . '/lib/Service/Identity/VerificationReportService.php'; diff --git a/lib/CreditNote.php b/lib/CreditNote.php index b950087fa..65425e12a 100644 --- a/lib/CreditNote.php +++ b/lib/CreditNote.php @@ -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 ISO currency code, in lowercase. Must be a supported currency. * @property string|\Stripe\Customer $customer ID of the customer. @@ -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 duplicate, fraudulent, order_change, or product_unsatisfactory * @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 issued or void. Learn more about voiding credit notes. * @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. diff --git a/lib/CustomerCashBalanceTransaction.php b/lib/CustomerCashBalanceTransaction.php index 143875a4f..f492bb623 100644 --- a/lib/CustomerCashBalanceTransaction.php +++ b/lib/CustomerCashBalanceTransaction.php @@ -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'; diff --git a/lib/Event.php b/lib/Event.php index c24dedc3e..de59f23a7 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -110,8 +110,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'; @@ -125,6 +127,10 @@ class Event extends ApiResource const FINANCIAL_CONNECTIONS_ACCOUNT_DISCONNECTED = 'financial_connections.account.disconnected'; const FINANCIAL_CONNECTIONS_ACCOUNT_REACTIVATED = 'financial_connections.account.reactivated'; const FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_BALANCE = 'financial_connections.account.refreshed_balance'; + const FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_INFERRED_BALANCES = 'financial_connections.account.refreshed_inferred_balances'; + const FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_OWNERSHIP = 'financial_connections.account.refreshed_ownership'; + const FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_TRANSACTIONS = 'financial_connections.account.refreshed_transactions'; + const FINANCIAL_CONNECTIONS_SESSION_UPDATED = 'financial_connections.session.updated'; const IDENTITY_VERIFICATION_SESSION_CANCELED = 'identity.verification_session.canceled'; const IDENTITY_VERIFICATION_SESSION_CREATED = 'identity.verification_session.created'; const IDENTITY_VERIFICATION_SESSION_PROCESSING = 'identity.verification_session.processing'; diff --git a/lib/FinancialConnections/Account.php b/lib/FinancialConnections/Account.php index 0fc4e26d2..cac53e891 100644 --- a/lib/FinancialConnections/Account.php +++ b/lib/FinancialConnections/Account.php @@ -16,6 +16,7 @@ * @property string $category The type of the account. Account category is further divided in subcategory. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property null|string $display_name A human-readable name that has been assigned to this account, either by the account holder or by the institution. + * @property null|\Stripe\StripeObject $inferred_balances_refresh The state of the most recent attempt to refresh the account's inferred balance history. * @property string $institution_name The name of the institution that holds this account. * @property null|string $last4 The last 4 digits of the account number. If present, this will be 4 numeric characters. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. @@ -24,13 +25,16 @@ * @property null|string[] $permissions The list of permissions granted by this account. * @property string $status The status of the link to the account. * @property string $subcategory

If category is cash, one of:

- checking - savings - other

If category is credit, one of:

- mortgage - line_of_credit - credit_card - other

If category is investment or other, this will be other.

+ * @property null|string[] $subscriptions The list of data refresh subscriptions requested on this account. * @property string[] $supported_payment_method_types The PaymentMethod type(s) that can be created from this account. + * @property null|\Stripe\StripeObject $transaction_refresh The state of the most recent attempt to refresh the account transactions. */ class Account extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.account'; use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\NestedResource; use \Stripe\ApiOperations\Retrieve; const CATEGORY_CASH = 'cash'; @@ -101,4 +105,20 @@ public function refreshAccount($params = null, $opts = null) return $this; } + + const PATH_INFERRED_BALANCES = '/inferred_balances'; + + /** + * @param string $id the ID of the account on which to retrieve the financial connections account inferred balances + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FinancialConnections\FinancialConnectionsAccountInferredBalance> the list of financial connections account inferred balances + */ + public static function allInferredBalances($id, $params = null, $opts = null) + { + return self::_allNestedResources($id, static::PATH_INFERRED_BALANCES, $params, $opts); + } } diff --git a/lib/FinancialConnections/InferredBalance.php b/lib/FinancialConnections/InferredBalance.php new file mode 100644 index 000000000..3aaf6ba79 --- /dev/null +++ b/lib/FinancialConnections/InferredBalance.php @@ -0,0 +1,22 @@ +The balances owed to (or by) the account holder.

Each key is a three-letter ISO currency code, in lowercase.

Each value is a integer amount. A positive amount indicates money owed to the account holder. A negative amount indicates money owed by the account holder.

+ */ +class InferredBalance extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'financial_connections.account_inferred_balance'; + + use \Stripe\ApiOperations\All; +} diff --git a/lib/FinancialConnections/Session.php b/lib/FinancialConnections/Session.php index 8d55cd06e..b7fc15a48 100644 --- a/lib/FinancialConnections/Session.php +++ b/lib/FinancialConnections/Session.php @@ -15,8 +15,12 @@ * @property string $client_secret A value that will be passed to the client to launch the authentication flow. * @property \Stripe\StripeObject $filters * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property \Stripe\StripeObject $manual_entry * @property string[] $permissions Permissions requested for accounts collected during this session. + * @property null|string[] $prefetch Data features requested to be retrieved upon account creation. * @property string $return_url For webview integrations only. Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. + * @property string $status The current state of the session. + * @property \Stripe\StripeObject $status_details */ class Session extends \Stripe\ApiResource { @@ -24,4 +28,9 @@ class Session extends \Stripe\ApiResource use \Stripe\ApiOperations\Create; use \Stripe\ApiOperations\Retrieve; + + const STATUS_CANCELLED = 'cancelled'; + const STATUS_FAILED = 'failed'; + const STATUS_PENDING = 'pending'; + const STATUS_SUCCEEDED = 'succeeded'; } diff --git a/lib/FinancialConnections/Transaction.php b/lib/FinancialConnections/Transaction.php new file mode 100644 index 000000000..ca522ec6f --- /dev/null +++ b/lib/FinancialConnections/Transaction.php @@ -0,0 +1,33 @@ +ISO currency code, in lowercase. Must be a supported currency. + * @property string $description The description of this transaction. + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property string $status The status of the transaction. + * @property \Stripe\StripeObject $status_transitions + * @property int $transacted_at Time at which the transaction was transacted. Measured in seconds since the Unix epoch. + * @property string $transaction_refresh The transaction_refresh object that last updated or created this transaction. + * @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch. + */ +class Transaction extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'financial_connections.transaction'; + + use \Stripe\ApiOperations\All; + + const STATUS_PENDING = 'pending'; + const STATUS_POSTED = 'posted'; + const STATUS_VOID = 'void'; +} diff --git a/lib/Invoice.php b/lib/Invoice.php index 9ce7d818a..510cd440c 100644 --- a/lib/Invoice.php +++ b/lib/Invoice.php @@ -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 amount_due may be 0. If there is a positive starting_balance for the invoice (the customer owes money), the amount_due will also take that into account. The charge that gets generated for the invoice will be for the amount specified in amount_due. * @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 null|\Stripe\StripeObject $applies_to @@ -101,6 +102,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 shipping_details 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 draft, open, paid, uncollectible, or void. Learn more diff --git a/lib/PaymentLink.php b/lib/PaymentLink.php index 5c3462e69..eeeecc4ff 100644 --- a/lib/PaymentLink.php +++ b/lib/PaymentLink.php @@ -30,6 +30,7 @@ * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @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 true if the object exists in live mode or the value false if the object exists in test mode. * @property \Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. diff --git a/lib/Service/FinancialConnections/AccountService.php b/lib/Service/FinancialConnections/AccountService.php index 213d17271..734b4ce0c 100644 --- a/lib/Service/FinancialConnections/AccountService.php +++ b/lib/Service/FinancialConnections/AccountService.php @@ -21,6 +21,23 @@ public function all($params = null, $opts = null) return $this->requestCollection('get', '/v1/financial_connections/accounts', $params, $opts); } + /** + * Lists the recorded inferred balances for a Financial Connections + * Account. + * + * @param string $parentId + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FinancialConnections\InferredBalance> + */ + public function allInferredBalances($parentId, $params = null, $opts = null) + { + return $this->requestCollection('get', $this->buildPath('/v1/financial_connections/accounts/%s/inferred_balances', $parentId), $params, $opts); + } + /** * Lists all owners for a given Account. * diff --git a/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php b/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php index 7dd826341..5c24c3236 100644 --- a/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php +++ b/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php @@ -9,6 +9,7 @@ * * @property AccountService $accounts * @property SessionService $sessions + * @property TransactionService $transactions */ class FinancialConnectionsServiceFactory extends \Stripe\Service\AbstractServiceFactory { @@ -18,6 +19,7 @@ class FinancialConnectionsServiceFactory extends \Stripe\Service\AbstractService private static $classMap = [ 'accounts' => AccountService::class, 'sessions' => SessionService::class, + 'transactions' => TransactionService::class, ]; protected function getServiceClass($name) diff --git a/lib/Service/FinancialConnections/TransactionService.php b/lib/Service/FinancialConnections/TransactionService.php new file mode 100644 index 000000000..ee010ef07 --- /dev/null +++ b/lib/Service/FinancialConnections/TransactionService.php @@ -0,0 +1,23 @@ +Transaction objects. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FinancialConnections\Transaction> + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/financial_connections/transactions', $params, $opts); + } +} diff --git a/lib/Service/SubscriptionService.php b/lib/Service/SubscriptionService.php index f81310c11..dcbc8e648 100644 --- a/lib/Service/SubscriptionService.php +++ b/lib/Service/SubscriptionService.php @@ -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 active, and if + * payment fails the subscription will be past_due. 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. * diff --git a/lib/Subscription.php b/lib/Subscription.php index f3653d1a5..b77ec555e 100644 --- a/lib/Subscription.php +++ b/lib/Subscription.php @@ -53,6 +53,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 @@ -79,6 +80,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'; @@ -132,6 +134,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 diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php index b997eb82f..2e63d3c46 100644 --- a/lib/Util/ObjectTypes.php +++ b/lib/Util/ObjectTypes.php @@ -49,7 +49,9 @@ class ObjectTypes \Stripe\FinancialConnections\Account::OBJECT_NAME => \Stripe\FinancialConnections\Account::class, \Stripe\FinancialConnections\AccountOwner::OBJECT_NAME => \Stripe\FinancialConnections\AccountOwner::class, \Stripe\FinancialConnections\AccountOwnership::OBJECT_NAME => \Stripe\FinancialConnections\AccountOwnership::class, + \Stripe\FinancialConnections\InferredBalance::OBJECT_NAME => \Stripe\FinancialConnections\InferredBalance::class, \Stripe\FinancialConnections\Session::OBJECT_NAME => \Stripe\FinancialConnections\Session::class, + \Stripe\FinancialConnections\Transaction::OBJECT_NAME => \Stripe\FinancialConnections\Transaction::class, \Stripe\FundingInstructions::OBJECT_NAME => \Stripe\FundingInstructions::class, \Stripe\GiftCards\Card::OBJECT_NAME => \Stripe\GiftCards\Card::class, \Stripe\GiftCards\Transaction::OBJECT_NAME => \Stripe\GiftCards\Transaction::class, diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index 994d3c2bb..f07962da9 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -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(