diff --git a/init.php b/init.php index 74b48a654..7b34170ab 100644 --- a/init.php +++ b/init.php @@ -171,6 +171,17 @@ require __DIR__ . '/lib/Topup.php'; require __DIR__ . '/lib/Transfer.php'; require __DIR__ . '/lib/TransferReversal.php'; +require __DIR__ . '/lib/Treasury/CreditReversal.php'; +require __DIR__ . '/lib/Treasury/DebitReversal.php'; +require __DIR__ . '/lib/Treasury/FinancialAccount.php'; +require __DIR__ . '/lib/Treasury/FinancialAccountFeatures.php'; +require __DIR__ . '/lib/Treasury/InboundTransfer.php'; +require __DIR__ . '/lib/Treasury/OutboundPayment.php'; +require __DIR__ . '/lib/Treasury/OutboundTransfer.php'; +require __DIR__ . '/lib/Treasury/ReceivedCredit.php'; +require __DIR__ . '/lib/Treasury/ReceivedDebit.php'; +require __DIR__ . '/lib/Treasury/Transaction.php'; +require __DIR__ . '/lib/Treasury/TransactionEntry.php'; require __DIR__ . '/lib/UsageRecord.php'; require __DIR__ . '/lib/UsageRecordSummary.php'; require __DIR__ . '/lib/WebhookEndpoint.php'; @@ -243,9 +254,24 @@ require __DIR__ . '/lib/Service/TestHelpers/RefundService.php'; require __DIR__ . '/lib/Service/TestHelpers/Terminal/ReaderService.php'; require __DIR__ . '/lib/Service/TestHelpers/TestClockService.php'; +require __DIR__ . '/lib/Service/TestHelpers/Treasury/InboundTransferService.php'; +require __DIR__ . '/lib/Service/TestHelpers/Treasury/OutboundPaymentService.php'; +require __DIR__ . '/lib/Service/TestHelpers/Treasury/OutboundTransferService.php'; +require __DIR__ . '/lib/Service/TestHelpers/Treasury/ReceivedCreditService.php'; +require __DIR__ . '/lib/Service/TestHelpers/Treasury/ReceivedDebitService.php'; require __DIR__ . '/lib/Service/TokenService.php'; require __DIR__ . '/lib/Service/TopupService.php'; require __DIR__ . '/lib/Service/TransferService.php'; +require __DIR__ . '/lib/Service/Treasury/CreditReversalService.php'; +require __DIR__ . '/lib/Service/Treasury/DebitReversalService.php'; +require __DIR__ . '/lib/Service/Treasury/FinancialAccountService.php'; +require __DIR__ . '/lib/Service/Treasury/InboundTransferService.php'; +require __DIR__ . '/lib/Service/Treasury/OutboundPaymentService.php'; +require __DIR__ . '/lib/Service/Treasury/OutboundTransferService.php'; +require __DIR__ . '/lib/Service/Treasury/ReceivedCreditService.php'; +require __DIR__ . '/lib/Service/Treasury/ReceivedDebitService.php'; +require __DIR__ . '/lib/Service/Treasury/TransactionService.php'; +require __DIR__ . '/lib/Service/Treasury/TransactionEntryService.php'; require __DIR__ . '/lib/Service/WebhookEndpointService.php'; // Service factories @@ -259,7 +285,10 @@ require __DIR__ . '/lib/Service/Reporting/ReportingServiceFactory.php'; require __DIR__ . '/lib/Service/Sigma/SigmaServiceFactory.php'; require __DIR__ . '/lib/Service/Terminal/TerminalServiceFactory.php'; +require __DIR__ . '/lib/Service/TestHelpers/Terminal/TerminalServiceFactory.php'; require __DIR__ . '/lib/Service/TestHelpers/TestHelpersServiceFactory.php'; +require __DIR__ . '/lib/Service/TestHelpers/Treasury/TreasuryServiceFactory.php'; +require __DIR__ . '/lib/Service/Treasury/TreasuryServiceFactory.php'; // OAuth require __DIR__ . '/lib/OAuth.php'; diff --git a/lib/BillingPortal/Session.php b/lib/BillingPortal/Session.php index 5cec9a400..2f737c373 100644 --- a/lib/BillingPortal/Session.php +++ b/lib/BillingPortal/Session.php @@ -30,7 +30,7 @@ * @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 null|string $locale The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customer’s preferred_locales or browser’s locale is used. * @property null|string $on_behalf_of The account for which the session was created on behalf of. When specified, only subscriptions and invoices with this on_behalf_of account appear in the portal. For more information, see the docs. Use the Accounts API to modify the on_behalf_of account's branding settings, which the portal displays. - * @property string $return_url The URL to redirect customers to when they click on the portal's link to return to your website. + * @property null|string $return_url The URL to redirect customers to when they click on the portal's link to return to your website. * @property string $url The short-lived URL of the session that gives customers access to the customer portal. */ class Session extends \Stripe\ApiResource diff --git a/lib/Customer.php b/lib/Customer.php index 06b088ff9..8c17f702e 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -90,7 +90,7 @@ public function deleteDiscount($params = null, $opts = null) * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection<\Stripe\Customer> list of PaymentMethods + * @return \Stripe\Collection<\Stripe\PaymentMethod> list of PaymentMethods */ public static function allPaymentMethods($id, $params = null, $opts = null) { @@ -102,6 +102,25 @@ public static function allPaymentMethods($id, $params = null, $opts = null) return $obj; } + /** + * @param string $payment_method + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Customer the retrieved customer + */ + public function retrievePaymentMethod($payment_method, $params = null, $opts = null) + { + $url = $this->instanceUrl() . '/payment_methods/' . $payment_method; + list($response, $opts) = $this->_request('get', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Event.php b/lib/Event.php index 5724823ef..91a39dd6c 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -253,4 +253,33 @@ class Event extends ApiResource const TRANSFER_PAID = 'transfer.paid'; const TRANSFER_REVERSED = 'transfer.reversed'; const TRANSFER_UPDATED = 'transfer.updated'; + const TREASURY_CREDIT_REVERSAL_CREATED = 'treasury.credit_reversal.created'; + const TREASURY_CREDIT_REVERSAL_POSTED = 'treasury.credit_reversal.posted'; + const TREASURY_DEBIT_REVERSAL_COMPLETED = 'treasury.debit_reversal.completed'; + const TREASURY_DEBIT_REVERSAL_CREATED = 'treasury.debit_reversal.created'; + const TREASURY_DEBIT_REVERSAL_INITIAL_CREDIT_GRANTED = 'treasury.debit_reversal.initial_credit_granted'; + const TREASURY_FINANCIAL_ACCOUNT_CLOSED = 'treasury.financial_account.closed'; + const TREASURY_FINANCIAL_ACCOUNT_CREATED = 'treasury.financial_account.created'; + const TREASURY_FINANCIAL_ACCOUNT_FEATURES_STATUS_UPDATED = 'treasury.financial_account.features_status_updated'; + const TREASURY_INBOUND_TRANSFER_CANCELED = 'treasury.inbound_transfer.canceled'; + const TREASURY_INBOUND_TRANSFER_CREATED = 'treasury.inbound_transfer.created'; + const TREASURY_INBOUND_TRANSFER_FAILED = 'treasury.inbound_transfer.failed'; + const TREASURY_INBOUND_TRANSFER_SUCCEEDED = 'treasury.inbound_transfer.succeeded'; + const TREASURY_OUTBOUND_PAYMENT_CANCELED = 'treasury.outbound_payment.canceled'; + const TREASURY_OUTBOUND_PAYMENT_CREATED = 'treasury.outbound_payment.created'; + const TREASURY_OUTBOUND_PAYMENT_EXPECTED_ARRIVAL_DATE_UPDATED = 'treasury.outbound_payment.expected_arrival_date_updated'; + const TREASURY_OUTBOUND_PAYMENT_FAILED = 'treasury.outbound_payment.failed'; + const TREASURY_OUTBOUND_PAYMENT_POSTED = 'treasury.outbound_payment.posted'; + const TREASURY_OUTBOUND_PAYMENT_RETURNED = 'treasury.outbound_payment.returned'; + const TREASURY_OUTBOUND_TRANSFER_CANCELED = 'treasury.outbound_transfer.canceled'; + const TREASURY_OUTBOUND_TRANSFER_CREATED = 'treasury.outbound_transfer.created'; + const TREASURY_OUTBOUND_TRANSFER_EXPECTED_ARRIVAL_DATE_UPDATED = 'treasury.outbound_transfer.expected_arrival_date_updated'; + const TREASURY_OUTBOUND_TRANSFER_FAILED = 'treasury.outbound_transfer.failed'; + const TREASURY_OUTBOUND_TRANSFER_POSTED = 'treasury.outbound_transfer.posted'; + const TREASURY_OUTBOUND_TRANSFER_RETURNED = 'treasury.outbound_transfer.returned'; + const TREASURY_RECEIVED_CREDIT_CREATED = 'treasury.received_credit.created'; + const TREASURY_RECEIVED_CREDIT_FAILED = 'treasury.received_credit.failed'; + const TREASURY_RECEIVED_CREDIT_REVERSED = 'treasury.received_credit.reversed'; + const TREASURY_RECEIVED_CREDIT_SUCCEEDED = 'treasury.received_credit.succeeded'; + const TREASURY_RECEIVED_DEBIT_CREATED = 'treasury.received_debit.created'; } diff --git a/lib/FinancialConnections/Account.php b/lib/FinancialConnections/Account.php index 1261d3551..c8783840f 100644 --- a/lib/FinancialConnections/Account.php +++ b/lib/FinancialConnections/Account.php @@ -30,6 +30,7 @@ class Account extends \Stripe\ApiResource { const OBJECT_NAME = 'financial_connections.account'; + use \Stripe\ApiOperations\All; use \Stripe\ApiOperations\Retrieve; const CATEGORY_CASH = 'cash'; @@ -65,6 +66,25 @@ public function disconnect($params = null, $opts = null) return $this; } + /** + * @param null|array $params + * @param null|array|string $opts + * @param mixed $id + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FinancialConnections\AccountOwner> list of BankConnectionsResourceOwners + */ + public static function allOwners($id, $params = null, $opts = null) + { + $url = static::resourceUrl($id) . '/owners'; + list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/lib/Issuing/Authorization.php b/lib/Issuing/Authorization.php index 7e597df52..7e6ff679b 100644 --- a/lib/Issuing/Authorization.php +++ b/lib/Issuing/Authorization.php @@ -34,6 +34,7 @@ * @property \Stripe\StripeObject[] $request_history History of every time pending_request was approved/denied, either by you directly or by Stripe (e.g. based on your spending_controls). If the merchant changes the authorization by performing an incremental authorization, you can look at this field to see the previous requests for the authorization. * @property string $status The current status of the authorization in its lifecycle. * @property \Stripe\Issuing\Transaction[] $transactions List of transactions associated with this authorization. + * @property null|\Stripe\StripeObject $treasury Treasury details related to this authorization if it was created on a FinancialAccount. * @property \Stripe\StripeObject $verification_data * @property null|string $wallet The digital wallet used for this authorization. One of apple_pay, google_pay, or samsung_pay. */ diff --git a/lib/Issuing/Card.php b/lib/Issuing/Card.php index 31deaf3f0..b38297880 100644 --- a/lib/Issuing/Card.php +++ b/lib/Issuing/Card.php @@ -18,6 +18,7 @@ * @property string $cvc The card's CVC. For security reasons, this is only available for virtual cards, and will be omitted unless you explicitly request it with the expand parameter. Additionally, it's only available via the "Retrieve a card" endpoint, not via "List all cards" or any other endpoint. * @property int $exp_month The expiration month of the card. * @property int $exp_year The expiration year of the card. + * @property null|string $financial_account The financial account this card is attached to. * @property string $last4 The last 4 digits of the card number. * @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/Issuing/Dispute.php b/lib/Issuing/Dispute.php index 1eeb17eea..b04886d50 100644 --- a/lib/Issuing/Dispute.php +++ b/lib/Issuing/Dispute.php @@ -24,6 +24,7 @@ * @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. * @property string $status Current status of the dispute. * @property string|\Stripe\Issuing\Transaction $transaction The transaction being disputed. + * @property null|\Stripe\StripeObject $treasury Treasury details related to this dispute if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts */ class Dispute extends \Stripe\ApiResource { diff --git a/lib/Issuing/Transaction.php b/lib/Issuing/Transaction.php index 90a38edd7..4586b2fa1 100644 --- a/lib/Issuing/Transaction.php +++ b/lib/Issuing/Transaction.php @@ -31,6 +31,7 @@ * @property \Stripe\StripeObject $merchant_data * @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. * @property null|\Stripe\StripeObject $purchase_details Additional purchase information that is optionally provided by the merchant. + * @property null|\Stripe\StripeObject $treasury Treasury details related to this transaction if it was created on a [FinancialAccount](/docs/api/treasury/financial_accounts * @property string $type The nature of the transaction. * @property null|string $wallet The digital wallet used for this transaction. One of apple_pay, google_pay, or samsung_pay. */ diff --git a/lib/Order.php b/lib/Order.php index 58c71a94e..4e786ea58 100644 --- a/lib/Order.php +++ b/lib/Order.php @@ -18,6 +18,7 @@ * @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the Order, if any. * @property \Stripe\StripeObject $automatic_tax * @property null|\Stripe\StripeObject $billing_details Customer billing details associated with the order. + * @property null|string $client_secret

The client secret of this Order. Used for client-side retrieval using a publishable key.

The client secret can be used to complete a payment for an Order from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

Refer to our docs for creating and processing an order to learn about how client_secret should be handled.

* @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 null|string|\Stripe\Customer $customer The customer which this orders belongs to. @@ -73,7 +74,7 @@ public function cancel($params = null, $opts = null) * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection<\Stripe\Order> list of LineItems + * @return \Stripe\Collection<\Stripe\LineItem> list of LineItems */ public static function allLineItems($id, $params = null, $opts = null) { diff --git a/lib/PaymentLink.php b/lib/PaymentLink.php index a4f77056f..742e0e802 100644 --- a/lib/PaymentLink.php +++ b/lib/PaymentLink.php @@ -70,7 +70,7 @@ class PaymentLink extends ApiResource * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection<\Stripe\PaymentLink> list of LineItems + * @return \Stripe\Collection<\Stripe\LineItem> list of LineItems */ public static function allLineItems($id, $params = null, $opts = null) { diff --git a/lib/Quote.php b/lib/Quote.php index b3fcb3493..ba309fec9 100644 --- a/lib/Quote.php +++ b/lib/Quote.php @@ -138,7 +138,7 @@ public function finalizeQuote($params = null, $opts = null) * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection<\Stripe\Quote> list of LineItems + * @return \Stripe\Collection<\Stripe\LineItem> list of LineItems */ public static function allComputedUpfrontLineItems($id, $params = null, $opts = null) { @@ -157,7 +157,7 @@ public static function allComputedUpfrontLineItems($id, $params = null, $opts = * * @throws \Stripe\Exception\ApiErrorException if the request fails * - * @return \Stripe\Collection<\Stripe\Quote> list of LineItems + * @return \Stripe\Collection<\Stripe\LineItem> list of LineItems */ public static function allLineItems($id, $params = null, $opts = null) { diff --git a/lib/Service/CoreServiceFactory.php b/lib/Service/CoreServiceFactory.php index 9ebc06096..570d3b842 100644 --- a/lib/Service/CoreServiceFactory.php +++ b/lib/Service/CoreServiceFactory.php @@ -63,6 +63,7 @@ * @property TokenService $tokens * @property TopupService $topups * @property TransferService $transfers + * @property Treasury\TreasuryServiceFactory $treasury * @property WebhookEndpointService $webhookEndpoints */ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory @@ -127,6 +128,7 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory 'tokens' => TokenService::class, 'topups' => TopupService::class, 'transfers' => TransferService::class, + 'treasury' => Treasury\TreasuryServiceFactory::class, 'webhookEndpoints' => WebhookEndpointService::class, ]; diff --git a/lib/Service/CustomerService.php b/lib/Service/CustomerService.php index aa3d891b3..2051ad4c9 100644 --- a/lib/Service/CustomerService.php +++ b/lib/Service/CustomerService.php @@ -292,6 +292,23 @@ public function retrieveCashBalance($parentId, $params = null, $opts = null) return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts); } + /** + * Retrieves a PaymentMethod object. + * + * @param string $parentId + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Customer + */ + public function retrievePaymentMethod($parentId, $id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/customers/%s/payment_methods/%s', $parentId, $id), $params, $opts); + } + /** * Retrieve a specified source for a given customer. * diff --git a/lib/Service/FinancialConnections/AccountService.php b/lib/Service/FinancialConnections/AccountService.php index 1c96b1244..8292631df 100644 --- a/lib/Service/FinancialConnections/AccountService.php +++ b/lib/Service/FinancialConnections/AccountService.php @@ -6,6 +6,37 @@ class AccountService extends \Stripe\Service\AbstractService { + /** + * Returns a list of Financial Connections Account 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\Account> + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/financial_connections/accounts', $params, $opts); + } + + /** + * Lists all owners for a given Account. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\FinancialConnections\Account> + */ + public function allOwners($id, $params = null, $opts = null) + { + return $this->requestCollection('get', $this->buildPath('/v1/financial_connections/accounts/%s/owners', $id), $params, $opts); + } + /** * Disables your access to a Financial Connections Account. You will * no longer be able to access data associated with the account (e.g. balances, diff --git a/lib/Service/TestHelpers/TestHelpersServiceFactory.php b/lib/Service/TestHelpers/TestHelpersServiceFactory.php index aaf827514..cb437dea0 100644 --- a/lib/Service/TestHelpers/TestHelpersServiceFactory.php +++ b/lib/Service/TestHelpers/TestHelpersServiceFactory.php @@ -10,6 +10,7 @@ * @property RefundService $refunds * @property Terminal\TerminalServiceFactory $terminal * @property TestClockService $testClocks + * @property Treasury\TreasuryServiceFactory $treasury */ class TestHelpersServiceFactory extends \Stripe\Service\AbstractServiceFactory { @@ -20,6 +21,7 @@ class TestHelpersServiceFactory extends \Stripe\Service\AbstractServiceFactory 'refunds' => RefundService::class, 'terminal' => Terminal\TerminalServiceFactory::class, 'testClocks' => TestClockService::class, + 'treasury' => Treasury\TreasuryServiceFactory::class, ]; protected function getServiceClass($name) diff --git a/lib/Service/TestHelpers/Treasury/InboundTransferService.php b/lib/Service/TestHelpers/Treasury/InboundTransferService.php new file mode 100644 index 000000000..1c8247625 --- /dev/null +++ b/lib/Service/TestHelpers/Treasury/InboundTransferService.php @@ -0,0 +1,62 @@ +failed + * status. The InboundTransfer must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer + */ + public function fail($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/inbound_transfers/%s/fail', $id), $params, $opts); + } + + /** + * Marks the test mode InboundTransfer object as returned and links the + * InboundTransfer to a ReceivedDebit. The InboundTransfer must already be in the + * succeeded state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer + */ + public function returnInboundTransfer($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/inbound_transfers/%s/return', $id), $params, $opts); + } + + /** + * Transitions a test mode created InboundTransfer to the succeeded + * status. The InboundTransfer must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer + */ + public function succeed($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/inbound_transfers/%s/succeed', $id), $params, $opts); + } +} diff --git a/lib/Service/TestHelpers/Treasury/OutboundPaymentService.php b/lib/Service/TestHelpers/Treasury/OutboundPaymentService.php new file mode 100644 index 000000000..4981e6852 --- /dev/null +++ b/lib/Service/TestHelpers/Treasury/OutboundPaymentService.php @@ -0,0 +1,62 @@ +failed + * status. The OutboundPayment must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment + */ + public function fail($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/outbound_payments/%s/fail', $id), $params, $opts); + } + + /** + * Transitions a test mode created OutboundPayment to the posted + * status. The OutboundPayment must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment + */ + public function post($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/outbound_payments/%s/post', $id), $params, $opts); + } + + /** + * Transitions a test mode created OutboundPayment to the returned + * status. The OutboundPayment must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment + */ + public function returnOutboundPayment($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/outbound_payments/%s/return', $id), $params, $opts); + } +} diff --git a/lib/Service/TestHelpers/Treasury/OutboundTransferService.php b/lib/Service/TestHelpers/Treasury/OutboundTransferService.php new file mode 100644 index 000000000..4b26bedf2 --- /dev/null +++ b/lib/Service/TestHelpers/Treasury/OutboundTransferService.php @@ -0,0 +1,62 @@ +failed + * status. The OutboundTransfer must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer + */ + public function fail($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/outbound_transfers/%s/fail', $id), $params, $opts); + } + + /** + * Transitions a test mode created OutboundTransfer to the posted + * status. The OutboundTransfer must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer + */ + public function post($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/outbound_transfers/%s/post', $id), $params, $opts); + } + + /** + * Transitions a test mode created OutboundTransfer to the returned + * status. The OutboundTransfer must already be in the processing + * state. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer + */ + public function returnOutboundTransfer($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/test_helpers/treasury/outbound_transfers/%s/return', $id), $params, $opts); + } +} diff --git a/lib/Service/TestHelpers/Treasury/ReceivedCreditService.php b/lib/Service/TestHelpers/Treasury/ReceivedCreditService.php new file mode 100644 index 000000000..a90031a32 --- /dev/null +++ b/lib/Service/TestHelpers/Treasury/ReceivedCreditService.php @@ -0,0 +1,25 @@ +request('post', '/v1/test_helpers/treasury/received_credits', $params, $opts); + } +} diff --git a/lib/Service/TestHelpers/Treasury/ReceivedDebitService.php b/lib/Service/TestHelpers/Treasury/ReceivedDebitService.php new file mode 100644 index 000000000..17f4c8276 --- /dev/null +++ b/lib/Service/TestHelpers/Treasury/ReceivedDebitService.php @@ -0,0 +1,25 @@ +request('post', '/v1/test_helpers/treasury/received_debits', $params, $opts); + } +} diff --git a/lib/Service/TestHelpers/Treasury/TreasuryServiceFactory.php b/lib/Service/TestHelpers/Treasury/TreasuryServiceFactory.php new file mode 100644 index 000000000..8329a53ef --- /dev/null +++ b/lib/Service/TestHelpers/Treasury/TreasuryServiceFactory.php @@ -0,0 +1,33 @@ + + */ + private static $classMap = [ + 'inboundTransfers' => InboundTransferService::class, + 'outboundPayments' => OutboundPaymentService::class, + 'outboundTransfers' => OutboundTransferService::class, + 'receivedCredits' => ReceivedCreditService::class, + 'receivedDebits' => ReceivedDebitService::class, + ]; + + protected function getServiceClass($name) + { + return \array_key_exists($name, self::$classMap) ? self::$classMap[$name] : null; + } +} diff --git a/lib/Service/Treasury/CreditReversalService.php b/lib/Service/Treasury/CreditReversalService.php new file mode 100644 index 000000000..60bf900a9 --- /dev/null +++ b/lib/Service/Treasury/CreditReversalService.php @@ -0,0 +1,56 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/credit_reversals', $params, $opts); + } + + /** + * Reverses a ReceivedCredit and creates a CreditReversal object. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\CreditReversal + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/treasury/credit_reversals', $params, $opts); + } + + /** + * Retrieves the details of an existing CreditReversal by passing the unique + * CreditReversal ID from either the CreditReversal creation request or + * CreditReversal list. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\CreditReversal + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/credit_reversals/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/DebitReversalService.php b/lib/Service/Treasury/DebitReversalService.php new file mode 100644 index 000000000..8887ee145 --- /dev/null +++ b/lib/Service/Treasury/DebitReversalService.php @@ -0,0 +1,54 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/debit_reversals', $params, $opts); + } + + /** + * Reverses a ReceivedDebit and creates a DebitReversal object. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\DebitReversal + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/treasury/debit_reversals', $params, $opts); + } + + /** + * Retrieves a DebitReversal object. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\DebitReversal + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/debit_reversals/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/FinancialAccountService.php b/lib/Service/Treasury/FinancialAccountService.php new file mode 100644 index 000000000..f273bd9c1 --- /dev/null +++ b/lib/Service/Treasury/FinancialAccountService.php @@ -0,0 +1,103 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/financial_accounts', $params, $opts); + } + + /** + * Creates a new FinancialAccount. For now, each connected account can only have + * one FinancialAccount. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/treasury/financial_accounts', $params, $opts); + } + + /** + * Retrieves the details of a FinancialAccount. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/financial_accounts/%s', $id), $params, $opts); + } + + /** + * Retrieves Features information associated with the FinancialAccount. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount + */ + public function retrieveFeatures($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/financial_accounts/%s/features', $id), $params, $opts); + } + + /** + * Updates the details of a FinancialAccount. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount + */ + public function update($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/treasury/financial_accounts/%s', $id), $params, $opts); + } + + /** + * Updates the Features associated with a FinancialAccount. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount + */ + public function updateFeatures($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/treasury/financial_accounts/%s/features', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/InboundTransferService.php b/lib/Service/Treasury/InboundTransferService.php new file mode 100644 index 000000000..49ea32ba9 --- /dev/null +++ b/lib/Service/Treasury/InboundTransferService.php @@ -0,0 +1,70 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/inbound_transfers', $params, $opts); + } + + /** + * Cancels an InboundTransfer. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer + */ + public function cancel($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/treasury/inbound_transfers/%s/cancel', $id), $params, $opts); + } + + /** + * Creates an InboundTransfer. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/treasury/inbound_transfers', $params, $opts); + } + + /** + * Retrieves the details of an existing InboundTransfer. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/inbound_transfers/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/OutboundPaymentService.php b/lib/Service/Treasury/OutboundPaymentService.php new file mode 100644 index 000000000..e6108e0c1 --- /dev/null +++ b/lib/Service/Treasury/OutboundPaymentService.php @@ -0,0 +1,72 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/outbound_payments', $params, $opts); + } + + /** + * Cancel an OutboundPayment. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment + */ + public function cancel($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/treasury/outbound_payments/%s/cancel', $id), $params, $opts); + } + + /** + * Creates an OutboundPayment. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/treasury/outbound_payments', $params, $opts); + } + + /** + * Retrieves the details of an existing OutboundPayment by passing the unique + * OutboundPayment ID from either the OutboundPayment creation request or + * OutboundPayment list. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/outbound_payments/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/OutboundTransferService.php b/lib/Service/Treasury/OutboundTransferService.php new file mode 100644 index 000000000..f61318657 --- /dev/null +++ b/lib/Service/Treasury/OutboundTransferService.php @@ -0,0 +1,72 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/outbound_transfers', $params, $opts); + } + + /** + * An OutboundTransfer can be canceled if the funds have not yet been paid out. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer + */ + public function cancel($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/treasury/outbound_transfers/%s/cancel', $id), $params, $opts); + } + + /** + * Creates an OutboundTransfer. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/treasury/outbound_transfers', $params, $opts); + } + + /** + * Retrieves the details of an existing OutboundTransfer by passing the unique + * OutboundTransfer ID from either the OutboundTransfer creation request or + * OutboundTransfer list. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/outbound_transfers/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/ReceivedCreditService.php b/lib/Service/Treasury/ReceivedCreditService.php new file mode 100644 index 000000000..1355deb50 --- /dev/null +++ b/lib/Service/Treasury/ReceivedCreditService.php @@ -0,0 +1,40 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/received_credits', $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedCredit by passing the unique + * ReceivedCredit ID from the ReceivedCredit list. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\ReceivedCredit + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/received_credits/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/ReceivedDebitService.php b/lib/Service/Treasury/ReceivedDebitService.php new file mode 100644 index 000000000..dfe3786b0 --- /dev/null +++ b/lib/Service/Treasury/ReceivedDebitService.php @@ -0,0 +1,40 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/received_debits', $params, $opts); + } + + /** + * Retrieves the details of an existing ReceivedDebit by passing the unique + * ReceivedDebit ID from the ReceivedDebit list. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\ReceivedDebit + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/received_debits/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/TransactionEntryService.php b/lib/Service/Treasury/TransactionEntryService.php new file mode 100644 index 000000000..3943de1c6 --- /dev/null +++ b/lib/Service/Treasury/TransactionEntryService.php @@ -0,0 +1,39 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/transaction_entries', $params, $opts); + } + + /** + * Retrieves a TransactionEntry object. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\TransactionEntry + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/transaction_entries/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/TransactionService.php b/lib/Service/Treasury/TransactionService.php new file mode 100644 index 000000000..232b2b1c2 --- /dev/null +++ b/lib/Service/Treasury/TransactionService.php @@ -0,0 +1,39 @@ + + */ + public function all($params = null, $opts = null) + { + return $this->requestCollection('get', '/v1/treasury/transactions', $params, $opts); + } + + /** + * Retrieves the details of an existing Transaction. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\Transaction + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/treasury/transactions/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/Treasury/TreasuryServiceFactory.php b/lib/Service/Treasury/TreasuryServiceFactory.php new file mode 100644 index 000000000..a2a2622ba --- /dev/null +++ b/lib/Service/Treasury/TreasuryServiceFactory.php @@ -0,0 +1,43 @@ + + */ + private static $classMap = [ + 'creditReversals' => CreditReversalService::class, + 'debitReversals' => DebitReversalService::class, + 'financialAccounts' => FinancialAccountService::class, + 'inboundTransfers' => InboundTransferService::class, + 'outboundPayments' => OutboundPaymentService::class, + 'outboundTransfers' => OutboundTransferService::class, + 'receivedCredits' => ReceivedCreditService::class, + 'receivedDebits' => ReceivedDebitService::class, + 'transactionEntries' => TransactionEntryService::class, + 'transactions' => TransactionService::class, + ]; + + protected function getServiceClass($name) + { + return \array_key_exists($name, self::$classMap) ? self::$classMap[$name] : null; + } +} diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index 9a47a1fa4..00ad56ed1 100644 --- a/lib/SetupIntent.php +++ b/lib/SetupIntent.php @@ -43,11 +43,13 @@ * @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 null|string|\Stripe\StripeObject $application ID of the Connect application that created the SetupIntent. + * @property bool $attach_to_self

If present, the SetupIntent's payment method will be attached to the in-context Stripe Account.

It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer.

* @property null|string $cancellation_reason Reason for cancellation of this SetupIntent, one of abandoned, requested_by_customer, or duplicate. * @property null|string $client_secret

The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.

The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property null|string|\Stripe\Customer $customer

ID of the Customer this SetupIntent belongs to, if one exists.

If present, the SetupIntent's payment method will be attached to the Customer on successful setup. Payment methods attached to other Customers cannot be used with this SetupIntent.

* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string[] $flow_directions

Indicates the directions of money movement for which this payment method is intended to be used.

Include inbound if you intend to use the payment method as the origin to pull funds from. Include outbound if you intend to use the payment method as the destination to send funds to. You can include both if you intend to use the payment method for both purposes.

* @property null|\Stripe\ErrorObject $last_setup_error The error encountered in the previous SetupIntent confirmation. * @property null|string|\Stripe\SetupAttempt $latest_attempt The most recent SetupAttempt for this SetupIntent. * @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. diff --git a/lib/StripeClient.php b/lib/StripeClient.php index f8a983352..d0e74c641 100644 --- a/lib/StripeClient.php +++ b/lib/StripeClient.php @@ -63,6 +63,7 @@ * @property \Stripe\Service\TokenService $tokens * @property \Stripe\Service\TopupService $topups * @property \Stripe\Service\TransferService $transfers + * @property \Stripe\Service\Treasury\TreasuryServiceFactory $treasury * @property \Stripe\Service\WebhookEndpointService $webhookEndpoints */ class StripeClient extends BaseStripeClient diff --git a/lib/Treasury/CreditReversal.php b/lib/Treasury/CreditReversal.php new file mode 100644 index 000000000..9405e528a --- /dev/null +++ b/lib/Treasury/CreditReversal.php @@ -0,0 +1,41 @@ +ReceivedCredits + * depending on their network and source flow. Reversing a ReceivedCredit leads to + * the creation of a new object known as a CreditReversal. + * + * @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 Amount (in cents) transferred. + * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. + * @property string $financial_account The FinancialAccount to reverse funds from. + * @property null|string $hosted_regulatory_receipt_url A hosted transaction receipt URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. + * @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. + * @property string $network The rails used to reverse the funds. + * @property string $received_credit The ReceivedCredit being reversed. + * @property string $status Status of the CreditReversal + * @property \Stripe\StripeObject $status_transitions + * @property null|string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + */ +class CreditReversal extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.credit_reversal'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; + + const NETWORK_ACH = 'ach'; + const NETWORK_STRIPE = 'stripe'; + + const STATUS_CANCELED = 'canceled'; + const STATUS_POSTED = 'posted'; + const STATUS_PROCESSING = 'processing'; +} diff --git a/lib/Treasury/DebitReversal.php b/lib/Treasury/DebitReversal.php new file mode 100644 index 000000000..94ae234b1 --- /dev/null +++ b/lib/Treasury/DebitReversal.php @@ -0,0 +1,42 @@ +ReceivedDebits depending + * on their network and source flow. Reversing a ReceivedDebit leads to the + * creation of a new object known as a DebitReversal. + * + * @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 Amount (in cents) transferred. + * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. + * @property null|string $financial_account The FinancialAccount to reverse funds from. + * @property null|string $hosted_regulatory_receipt_url A hosted transaction receipt URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. + * @property null|\Stripe\StripeObject $linked_flows Other flows linked to a DebitReversal. + * @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. + * @property string $network The rails used to reverse the funds. + * @property string $received_debit The ReceivedDebit being reversed. + * @property string $status Status of the DebitReversal + * @property \Stripe\StripeObject $status_transitions + * @property null|string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + */ +class DebitReversal extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.debit_reversal'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; + + const NETWORK_ACH = 'ach'; + const NETWORK_CARD = 'card'; + + const STATUS_FAILED = 'failed'; + const STATUS_PROCESSING = 'processing'; + const STATUS_SUCCEEDED = 'succeeded'; +} diff --git a/lib/Treasury/FinancialAccount.php b/lib/Treasury/FinancialAccount.php new file mode 100644 index 000000000..a5c63c884 --- /dev/null +++ b/lib/Treasury/FinancialAccount.php @@ -0,0 +1,75 @@ +ISO 3166-1 alpha-2). + * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. + * @property \Stripe\Treasury\FinancialAccountFeatures $features Encodes whether a FinancialAccount has access to a particular Feature, with a status enum and associated status_details. Stripe or the platform can control Features via the requested field. + * @property \Stripe\StripeObject[] $financial_addresses The set of credentials that resolve to a FinancialAccount. + * @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 null|\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. + * @property string[] $pending_features The array of paths to pending Features in the Features hash. + * @property null|\Stripe\StripeObject $platform_restrictions The set of functionalities that the platform can restrict on the FinancialAccount. + * @property string[] $restricted_features The array of paths to restricted Features in the Features hash. + * @property string $status The enum specifying what state the account is in. + * @property \Stripe\StripeObject $status_details + * @property string[] $supported_currencies The currencies the FinancialAccount can hold a balance in. Three-letter ISO currency code, in lowercase. + */ +class FinancialAccount extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.financial_account'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; + use \Stripe\ApiOperations\Update; + + const STATUS_CLOSED = 'closed'; + const STATUS_OPEN = 'open'; + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount the retrieved financial account + */ + public function retrieveFeatures($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/features'; + list($response, $opts) = $this->_request('get', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\FinancialAccount the updated financial account + */ + public function updateFeatures($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/features'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } +} diff --git a/lib/Treasury/FinancialAccountFeatures.php b/lib/Treasury/FinancialAccountFeatures.php new file mode 100644 index 000000000..ef343a7cb --- /dev/null +++ b/lib/Treasury/FinancialAccountFeatures.php @@ -0,0 +1,24 @@ +status enum and associated status_details. Stripe or + * the platform can control Features via the requested field. + * + * @property string $object String representing the object's type. Objects of the same type share the same value. + * @property \Stripe\StripeObject $card_issuing Toggle settings for enabling/disabling a feature + * @property \Stripe\StripeObject $deposit_insurance Toggle settings for enabling/disabling a feature + * @property \Stripe\StripeObject $financial_addresses Settings related to Financial Addresses features on a Financial Account + * @property \Stripe\StripeObject $inbound_transfers InboundTransfers contains inbound transfers features for a FinancialAccount. + * @property \Stripe\StripeObject $intra_stripe_flows Toggle settings for enabling/disabling a feature + * @property \Stripe\StripeObject $outbound_payments Settings related to Outbound Payments features on a Financial Account + * @property \Stripe\StripeObject $outbound_transfers OutboundTransfers contains outbound transfers features for a FinancialAccount. + */ +class FinancialAccountFeatures extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.financial_account_features'; +} diff --git a/lib/Treasury/InboundTransfer.php b/lib/Treasury/InboundTransfer.php new file mode 100644 index 000000000..0ad5bc35c --- /dev/null +++ b/lib/Treasury/InboundTransfer.php @@ -0,0 +1,63 @@ +FinancialAccount via a + * PaymentMethod that is owned by you. The funds will be transferred via an ACH + * debit. + * + * @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 Amount (in cents) transferred. + * @property bool $cancelable Returns true if the InboundTransfer is able to be canceled. + * @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 null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|\Stripe\StripeObject $failure_details Details about this InboundTransfer's failure. Only set when status is failed. + * @property string $financial_account The FinancialAccount that received the funds. + * @property null|string $hosted_regulatory_receipt_url A hosted transaction receipt URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. + * @property \Stripe\StripeObject $linked_flows + * @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. + * @property string $origin_payment_method The origin payment method to be debited for an InboundTransfer. + * @property null|\Stripe\StripeObject $origin_payment_method_details Details about the PaymentMethod for an InboundTransfer. + * @property null|bool $returned Returns true if the funds for an InboundTransfer were returned after the InboundTransfer went to the succeeded state. + * @property string $statement_descriptor Statement descriptor shown when funds are debited from the source. Not all payment networks support statement_descriptor. + * @property string $status Status of the InboundTransfer: processing, succeeded, failed, and canceled. An InboundTransfer is processing if it is created and pending. The status changes to succeeded once the funds have been "confirmed" and a transaction is created and posted. The status changes to failed if the transfer fails. + * @property \Stripe\StripeObject $status_transitions + * @property null|string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + */ +class InboundTransfer extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.inbound_transfer'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; + + const STATUS_CANCELED = 'canceled'; + const STATUS_FAILED = 'failed'; + const STATUS_PROCESSING = 'processing'; + const STATUS_SUCCEEDED = 'succeeded'; + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\InboundTransfer the canceled inbound transfer + */ + public function cancel($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/cancel'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } +} diff --git a/lib/Treasury/OutboundPayment.php b/lib/Treasury/OutboundPayment.php new file mode 100644 index 000000000..5a06d4a24 --- /dev/null +++ b/lib/Treasury/OutboundPayment.php @@ -0,0 +1,69 @@ +FinancialAccount. + * To send money to an account belonging to the same user, use an OutboundTransfer. + * + * Simulate OutboundPayment state changes with the + * /v1/test_helpers/treasury/outbound_payments endpoints. These + * methods can only be called on test mode objects. + * + * @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 Amount (in cents) transferred. + * @property bool $cancelable Returns true if the object can be canceled, and false otherwise. + * @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 null|string $customer ID of the customer to whom an OutboundPayment is sent. + * @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string $destination_payment_method The PaymentMethod via which an OutboundPayment is sent. This field can be empty if the OutboundPayment was created using destination_payment_method_data. + * @property null|\Stripe\StripeObject $destination_payment_method_details Details about the PaymentMethod for an OutboundPayment. + * @property null|\Stripe\StripeObject $end_user_details Details about the end user. + * @property int $expected_arrival_date The date when funds are expected to arrive in the destination account. + * @property string $financial_account The FinancialAccount that funds were pulled from. + * @property null|string $hosted_regulatory_receipt_url A hosted transaction receipt URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. + * @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. + * @property null|\Stripe\StripeObject $returned_details Details about a returned OutboundPayment. Only set when the status is returned. + * @property string $statement_descriptor The description that appears on the receiving end for an OutboundPayment (for example, bank statement for external bank transfer). + * @property string $status Current status of the OutboundPayment: processing, failed, posted, returned, canceled. An OutboundPayment is processing if it has been created and is pending. The status changes to posted once the OutboundPayment has been "confirmed" and funds have left the account, or to failed or canceled. If an OutboundPayment fails to arrive at its destination, its status will change to returned. + * @property \Stripe\StripeObject $status_transitions + * @property string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + */ +class OutboundPayment extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.outbound_payment'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; + + const STATUS_CANCELED = 'canceled'; + const STATUS_FAILED = 'failed'; + const STATUS_POSTED = 'posted'; + const STATUS_PROCESSING = 'processing'; + const STATUS_RETURNED = 'returned'; + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundPayment the canceled outbound payment + */ + public function cancel($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/cancel'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } +} diff --git a/lib/Treasury/OutboundTransfer.php b/lib/Treasury/OutboundTransfer.php new file mode 100644 index 000000000..cd64cf73e --- /dev/null +++ b/lib/Treasury/OutboundTransfer.php @@ -0,0 +1,69 @@ +FinancialAccount to a + * PaymentMethod belonging to the same entity. To send funds to a different party, + * use OutboundPayments + * instead. You can send funds over ACH rails or through a domestic wire transfer + * to a user's own external bank account. + * + * Simulate OutboundTransfer state changes with the + * /v1/test_helpers/treasury/outbound_transfers endpoints. These + * methods can only be called on test mode objects. + * + * @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 Amount (in cents) transferred. + * @property bool $cancelable Returns true if the object can be canceled, and false otherwise. + * @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 null|string $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property string $destination_payment_method The PaymentMethod used as the payment instrument for an OutboundTransfer. + * @property \Stripe\StripeObject $destination_payment_method_details + * @property int $expected_arrival_date The date when funds are expected to arrive in the destination account. + * @property string $financial_account The FinancialAccount that funds were pulled from. + * @property null|string $hosted_regulatory_receipt_url A hosted transaction receipt URL that is provided when money movement is considered regulated under Stripe's money transmission licenses. + * @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. + * @property null|\Stripe\StripeObject $returned_details Details about a returned OutboundTransfer. Only set when the status is returned. + * @property string $statement_descriptor Information about the OutboundTransfer to be sent to the recipient account. + * @property string $status Current status of the OutboundTransfer: processing, failed, canceled, posted, returned. An OutboundTransfer is processing if it has been created and is pending. The status changes to posted once the OutboundTransfer has been "confirmed" and funds have left the account, or to failed or canceled. If an OutboundTransfer fails to arrive at its destination, its status will change to returned. + * @property \Stripe\StripeObject $status_transitions + * @property string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + */ +class OutboundTransfer extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.outbound_transfer'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; + + const STATUS_CANCELED = 'canceled'; + const STATUS_FAILED = 'failed'; + const STATUS_POSTED = 'posted'; + const STATUS_PROCESSING = 'processing'; + const STATUS_RETURNED = 'returned'; + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Treasury\OutboundTransfer the canceled outbound transfer + */ + public function cancel($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/cancel'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } +} diff --git a/lib/Treasury/ReceivedCredit.php b/lib/Treasury/ReceivedCredit.php new file mode 100644 index 000000000..f9e17b080 --- /dev/null +++ b/lib/Treasury/ReceivedCredit.php @@ -0,0 +1,46 @@ +FinancialAccount (for + * example, via ACH or wire). These money movements are not initiated from the + * FinancialAccount. + * + * @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 Amount (in cents) transferred. + * @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 $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string $failure_code Reason for the failure. A ReceivedCredit might fail because the receiving FinancialAccount is closed or frozen. + * @property null|string $financial_account The FinancialAccount that received the funds. + * @property \Stripe\StripeObject $initiating_payment_method_details + * @property \Stripe\StripeObject $linked_flows + * @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 $network The rails used to send the funds. + * @property string $status Status of the ReceivedCredit. ReceivedCredits are created either succeeded (approved) or failed (declined). If a ReceivedCredit is declined, the failure reason can be found in the failure_code field. + * @property null|string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + */ +class ReceivedCredit extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.received_credit'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Retrieve; + + const FAILURE_CODE_ACCOUNT_CLOSED = 'account_closed'; + const FAILURE_CODE_ACCOUNT_FROZEN = 'account_frozen'; + const FAILURE_CODE_OTHER = 'other'; + + const NETWORK_ACH = 'ach'; + const NETWORK_CARD = 'card'; + const NETWORK_STRIPE = 'stripe'; + const NETWORK_US_DOMESTIC_WIRE = 'us_domestic_wire'; + + const STATUS_FAILED = 'failed'; + const STATUS_SUCCEEDED = 'succeeded'; +} diff --git a/lib/Treasury/ReceivedDebit.php b/lib/Treasury/ReceivedDebit.php new file mode 100644 index 000000000..9303c4b8c --- /dev/null +++ b/lib/Treasury/ReceivedDebit.php @@ -0,0 +1,45 @@ +FinancialAccount. + * These are not initiated from the FinancialAccount. + * + * @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 Amount (in cents) transferred. + * @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 $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|string $failure_code Reason for the failure. A ReceivedDebit might fail because the FinancialAccount doesn't have sufficient funds, is closed, or is frozen. + * @property null|string $financial_account The FinancialAccount that funds were pulled from. + * @property \Stripe\StripeObject $initiating_payment_method_details + * @property \Stripe\StripeObject $linked_flows + * @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 $network The network used for the ReceivedDebit. + * @property string $status Status of the ReceivedDebit. ReceivedDebits are created with a status of either succeeded (approved) or failed (declined). The failure reason can be found under the failure_code. + * @property null|string|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + */ +class ReceivedDebit extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.received_debit'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Retrieve; + + const FAILURE_CODE_ACCOUNT_CLOSED = 'account_closed'; + const FAILURE_CODE_ACCOUNT_FROZEN = 'account_frozen'; + const FAILURE_CODE_INSUFFICIENT_FUNDS = 'insufficient_funds'; + const FAILURE_CODE_OTHER = 'other'; + + const NETWORK_ACH = 'ach'; + const NETWORK_CARD = 'card'; + const NETWORK_STRIPE = 'stripe'; + + const STATUS_FAILED = 'failed'; + const STATUS_SUCCEEDED = 'succeeded'; +} diff --git a/lib/Treasury/Transaction.php b/lib/Treasury/Transaction.php new file mode 100644 index 000000000..321689844 --- /dev/null +++ b/lib/Treasury/Transaction.php @@ -0,0 +1,48 @@ +FinancialAccount's + * balance. + * + * @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 Amount (in cents) transferred. + * @property \Stripe\StripeObject $balance_impact Change to a FinancialAccount's balance + * @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 $description An arbitrary string attached to the object. Often useful for displaying to users. + * @property null|\Stripe\Collection<\Stripe\Treasury\TransactionEntry> $entries A list of TransactionEntries that are part of this Transaction. This cannot be expanded in any list endpoints. + * @property string $financial_account The FinancialAccount associated with this object. + * @property null|string $flow ID of the flow that created the Transaction. + * @property null|\Stripe\StripeObject $flow_details Details of the flow that created the Transaction. + * @property string $flow_type Type of the flow that created the 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 Status of the Transaction. + * @property \Stripe\StripeObject $status_transitions + */ +class Transaction extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.transaction'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Retrieve; + + const FLOW_TYPE_CREDIT_REVERSAL = 'credit_reversal'; + const FLOW_TYPE_DEBIT_REVERSAL = 'debit_reversal'; + const FLOW_TYPE_INBOUND_TRANSFER = 'inbound_transfer'; + const FLOW_TYPE_ISSUING_AUTHORIZATION = 'issuing_authorization'; + const FLOW_TYPE_OTHER = 'other'; + const FLOW_TYPE_OUTBOUND_PAYMENT = 'outbound_payment'; + const FLOW_TYPE_OUTBOUND_TRANSFER = 'outbound_transfer'; + const FLOW_TYPE_RECEIVED_CREDIT = 'received_credit'; + const FLOW_TYPE_RECEIVED_DEBIT = 'received_debit'; + + const STATUS_OPEN = 'open'; + const STATUS_POSTED = 'posted'; + const STATUS_VOID = 'void'; +} diff --git a/lib/Treasury/TransactionEntry.php b/lib/Treasury/TransactionEntry.php new file mode 100644 index 000000000..e50dbad9b --- /dev/null +++ b/lib/Treasury/TransactionEntry.php @@ -0,0 +1,62 @@ +Transaction. + * + * @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 \Stripe\StripeObject $balance_impact Change to a FinancialAccount's balance + * @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 int $effective_at When the TransactionEntry will impact the FinancialAccount's balance. + * @property string $financial_account The FinancialAccount associated with this object. + * @property null|string $flow Token of the flow associated with the TransactionEntry. + * @property null|\Stripe\StripeObject $flow_details Details of the flow associated with the TransactionEntry. + * @property string $flow_type Type of the flow associated with the TransactionEntry. + * @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|\Stripe\Treasury\Transaction $transaction The Transaction associated with this object. + * @property string $type The specific money movement that generated the TransactionEntry. + */ +class TransactionEntry extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'treasury.transaction_entry'; + + use \Stripe\ApiOperations\All; + use \Stripe\ApiOperations\Retrieve; + + const FLOW_TYPE_CREDIT_REVERSAL = 'credit_reversal'; + const FLOW_TYPE_DEBIT_REVERSAL = 'debit_reversal'; + const FLOW_TYPE_INBOUND_TRANSFER = 'inbound_transfer'; + const FLOW_TYPE_ISSUING_AUTHORIZATION = 'issuing_authorization'; + const FLOW_TYPE_OTHER = 'other'; + const FLOW_TYPE_OUTBOUND_PAYMENT = 'outbound_payment'; + const FLOW_TYPE_OUTBOUND_TRANSFER = 'outbound_transfer'; + const FLOW_TYPE_RECEIVED_CREDIT = 'received_credit'; + const FLOW_TYPE_RECEIVED_DEBIT = 'received_debit'; + + const TYPE_CREDIT_REVERSAL = 'credit_reversal'; + const TYPE_CREDIT_REVERSAL_POSTING = 'credit_reversal_posting'; + const TYPE_DEBIT_REVERSAL = 'debit_reversal'; + const TYPE_INBOUND_TRANSFER = 'inbound_transfer'; + const TYPE_INBOUND_TRANSFER_RETURN = 'inbound_transfer_return'; + const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold'; + const TYPE_ISSUING_AUTHORIZATION_RELEASE = 'issuing_authorization_release'; + const TYPE_OTHER = 'other'; + const TYPE_OUTBOUND_PAYMENT = 'outbound_payment'; + const TYPE_OUTBOUND_PAYMENT_CANCELLATION = 'outbound_payment_cancellation'; + const TYPE_OUTBOUND_PAYMENT_FAILURE = 'outbound_payment_failure'; + const TYPE_OUTBOUND_PAYMENT_POSTING = 'outbound_payment_posting'; + const TYPE_OUTBOUND_PAYMENT_RETURN = 'outbound_payment_return'; + const TYPE_OUTBOUND_TRANSFER = 'outbound_transfer'; + const TYPE_OUTBOUND_TRANSFER_CANCELLATION = 'outbound_transfer_cancellation'; + const TYPE_OUTBOUND_TRANSFER_FAILURE = 'outbound_transfer_failure'; + const TYPE_OUTBOUND_TRANSFER_POSTING = 'outbound_transfer_posting'; + const TYPE_OUTBOUND_TRANSFER_RETURN = 'outbound_transfer_return'; + const TYPE_RECEIVED_CREDIT = 'received_credit'; + const TYPE_RECEIVED_DEBIT = 'received_debit'; +} diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php index e2a711a6e..93f7095d9 100644 --- a/lib/Util/ObjectTypes.php +++ b/lib/Util/ObjectTypes.php @@ -106,6 +106,17 @@ class ObjectTypes \Stripe\Topup::OBJECT_NAME => \Stripe\Topup::class, \Stripe\Transfer::OBJECT_NAME => \Stripe\Transfer::class, \Stripe\TransferReversal::OBJECT_NAME => \Stripe\TransferReversal::class, + \Stripe\Treasury\CreditReversal::OBJECT_NAME => \Stripe\Treasury\CreditReversal::class, + \Stripe\Treasury\DebitReversal::OBJECT_NAME => \Stripe\Treasury\DebitReversal::class, + \Stripe\Treasury\FinancialAccount::OBJECT_NAME => \Stripe\Treasury\FinancialAccount::class, + \Stripe\Treasury\FinancialAccountFeatures::OBJECT_NAME => \Stripe\Treasury\FinancialAccountFeatures::class, + \Stripe\Treasury\InboundTransfer::OBJECT_NAME => \Stripe\Treasury\InboundTransfer::class, + \Stripe\Treasury\OutboundPayment::OBJECT_NAME => \Stripe\Treasury\OutboundPayment::class, + \Stripe\Treasury\OutboundTransfer::OBJECT_NAME => \Stripe\Treasury\OutboundTransfer::class, + \Stripe\Treasury\ReceivedCredit::OBJECT_NAME => \Stripe\Treasury\ReceivedCredit::class, + \Stripe\Treasury\ReceivedDebit::OBJECT_NAME => \Stripe\Treasury\ReceivedDebit::class, + \Stripe\Treasury\Transaction::OBJECT_NAME => \Stripe\Treasury\Transaction::class, + \Stripe\Treasury\TransactionEntry::OBJECT_NAME => \Stripe\Treasury\TransactionEntry::class, \Stripe\UsageRecord::OBJECT_NAME => \Stripe\UsageRecord::class, \Stripe\UsageRecordSummary::OBJECT_NAME => \Stripe\UsageRecordSummary::class, \Stripe\WebhookEndpoint::OBJECT_NAME => \Stripe\WebhookEndpoint::class, diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index ccf7419d1..d32761538 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -19,30 +19,485 @@ protected function setUpService() $this->client = new \Stripe\StripeClient(['api_key' => 'sk_test_123', 'api_base' => MOCK_URL]); } - public function testListCustomer() + public function testExpireSession() + { + $this->expectsRequest('post', '/v1/checkout/sessions/sess_xyz/expire'); + $result = $this->client->checkout->sessions->expire('sess_xyz', []); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + } + + public function testCreateShippingRate() + { + $this->expectsRequest('post', '/v1/shipping_rates'); + $result = $this->client->shippingRates->create( + [ + 'display_name' => 'Sample Shipper', + 'fixed_amount' => ['currency' => 'usd', 'amount' => 400], + 'type' => 'fixed_amount', + ] + ); + static::assertInstanceOf(\Stripe\ShippingRate::class, $result); + } + + public function testListShippingRate() + { + $this->expectsRequest('get', '/v1/shipping_rates'); + $result = $this->client->shippingRates->all([]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\ShippingRate::class, $result->data[0]); + } + + public function testCreateSession() + { + $this->expectsRequest('post', '/v1/checkout/sessions'); + $result = $this->client->checkout->sessions->create( + [ + 'success_url' => 'https://example.com/success', + 'cancel_url' => 'https://example.com/cancel', + 'mode' => 'payment', + 'shipping_options' => [ + ['shipping_rate' => 'shr_standard'], + [ + 'shipping_rate_data' => [ + 'display_name' => 'Standard', + 'delivery_estimate' => [ + 'minimum' => ['unit' => 'day', 'value' => 5], + 'maximum' => ['unit' => 'day', 'value' => 7], + ], + ], + ], + ], + ] + ); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + } + + public function testCreatePaymentIntent() + { + $this->expectsRequest('post', '/v1/payment_intents'); + $result = $this->client->paymentIntents->create( + [ + 'amount' => 1099, + 'currency' => 'eur', + 'automatic_payment_methods' => ['enabled' => true], + ] + ); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $result); + } + + public function testCreatePaymentLink() + { + $this->expectsRequest('post', '/v1/payment_links'); + $result = $this->client->paymentLinks->create( + ['line_items' => [['price' => 'price_xxxxxxxxxxxxx', 'quantity' => 1]]] + ); + static::assertInstanceOf(\Stripe\PaymentLink::class, $result); + } + + public function testListLineItemsPaymentLink() + { + $this->expectsRequest('get', '/v1/payment_links/pl_xyz/line_items'); + $result = $this->client->paymentLinks->allLineItems('pl_xyz', []); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\LineItem::class, $result->data[0]); + } + + public function testRetrievePaymentLink() + { + $this->expectsRequest('get', '/v1/payment_links/pl_xyz'); + $result = $this->client->paymentLinks->retrieve('pl_xyz', []); + static::assertInstanceOf(\Stripe\PaymentLink::class, $result); + } + + public function testVerifyMicrodepositsPaymentIntent() + { + $this->expectsRequest( + 'post', + '/v1/payment_intents/pi_xxxxxxxxxxxxx/verify_microdeposits' + ); + $result = $this->client->paymentIntents->verifyMicrodeposits( + 'pi_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $result); + } + + public function testVerifyMicrodepositsSetupIntent() + { + $this->expectsRequest( + 'post', + '/v1/setup_intents/seti_xxxxxxxxxxxxx/verify_microdeposits' + ); + $result = $this->client->setupIntents->verifyMicrodeposits( + 'seti_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\SetupIntent::class, $result); + } + + public function testCreateTestClock() + { + $this->expectsRequest('post', '/v1/test_helpers/test_clocks'); + $result = $this->client->testHelpers->testClocks->create( + ['frozen_time' => 123, 'name' => 'cogsworth'] + ); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + } + + public function testRetrieveTestClock() + { + $this->expectsRequest('get', '/v1/test_helpers/test_clocks/clock_xyz'); + $result = $this->client->testHelpers->testClocks->retrieve('clock_xyz', []); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + } + + public function testListTestClock() + { + $this->expectsRequest('get', '/v1/test_helpers/test_clocks'); + $result = $this->client->testHelpers->testClocks->all([]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result->data[0]); + } + + public function testDeleteTestClock() + { + $this->expectsRequest('delete', '/v1/test_helpers/test_clocks/clock_xyz'); + $result = $this->client->testHelpers->testClocks->delete('clock_xyz', []); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + } + + public function testAdvanceTestClock() + { + $this->expectsRequest( + 'post', + '/v1/test_helpers/test_clocks/clock_xyz/advance' + ); + $result = $this->client->testHelpers->testClocks->advance( + 'clock_xyz', + ['frozen_time' => 142] + ); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + } + + public function testCreateFundingInstructionsCustomer() + { + $this->expectsRequest('post', '/v1/customers/cus_123/funding_instructions'); + $result = $this->client->customers->createFundingInstructions( + 'cus_123', + [ + 'bank_transfer' => [ + 'requested_address_types' => ['zengin'], + 'type' => 'jp_bank_transfer', + ], + 'currency' => 'usd', + 'funding_type' => 'bank_transfer', + ] + ); + static::assertInstanceOf(\Stripe\FundingInstructions::class, $result); + } + + public function testListConfiguration() + { + $this->expectsRequest('get', '/v1/terminal/configurations'); + $result = $this->client->terminal->configurations->all([]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result->data[0]); + } + + public function testRetrieveConfiguration() + { + $this->expectsRequest('get', '/v1/terminal/configurations/uc_123'); + $result = $this->client->terminal->configurations->retrieve('uc_123', []); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + } + + public function testUpdateConfiguration() + { + $this->expectsRequest('post', '/v1/terminal/configurations/uc_123'); + $result = $this->client->terminal->configurations->update( + 'uc_123', + ['tipping' => ['usd' => ['fixed_amounts' => [10]]]] + ); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + } + + public function testDeleteConfiguration() + { + $this->expectsRequest('delete', '/v1/terminal/configurations/uc_123'); + $result = $this->client->terminal->configurations->delete('uc_123', []); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + } + + public function testExpireRefund() + { + $this->expectsRequest('post', '/v1/test_helpers/refunds/re_123/expire'); + $result = $this->client->testHelpers->refunds->expire('re_123', []); + static::assertInstanceOf(\Stripe\Refund::class, $result); + } + + public function testCreateOrder() + { + $this->expectsRequest('post', '/v1/orders'); + $result = $this->client->orders->create( + [ + 'description' => 'description', + 'currency' => 'usd', + 'line_items' => [['description' => 'my line item']], + ] + ); + static::assertInstanceOf(\Stripe\Order::class, $result); + } + + public function testUpdateOrder() + { + $this->expectsRequest('post', '/v1/orders/order_xyz'); + $result = $this->client->orders->update('order_xyz', []); + static::assertInstanceOf(\Stripe\Order::class, $result); + } + + public function testListLineItemsOrder() + { + $this->expectsRequest('get', '/v1/orders/order_xyz/line_items'); + $result = $this->client->orders->allLineItems('order_xyz', []); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\LineItem::class, $result->data[0]); + } + + public function testCancelOrder() + { + $this->expectsRequest('post', '/v1/orders/order_xyz/cancel'); + $result = $this->client->orders->cancel('order_xyz', []); + static::assertInstanceOf(\Stripe\Order::class, $result); + } + + public function testReopenOrder() + { + $this->expectsRequest('post', '/v1/orders/order_xyz/reopen'); + $result = $this->client->orders->reopen('order_xyz', []); + static::assertInstanceOf(\Stripe\Order::class, $result); + } + + public function testSubmitOrder() + { + $this->expectsRequest('post', '/v1/orders/order_xyz/submit'); + $result = $this->client->orders->submit( + 'order_xyz', + ['expected_total' => 100] + ); + static::assertInstanceOf(\Stripe\Order::class, $result); + } + + public function testUpdateOrder2() { - $this->expectsRequest('get', '/v1/customers'); - $result = $this->client->customers->all(['limit' => 3]); + $this->expectsRequest('post', '/v1/orders/order_xyz'); + $result = $this->client->orders->update('order_xyz', []); + static::assertInstanceOf(\Stripe\Order::class, $result); + } + + public function testRetrieveAccount() + { + $this->expectsRequest('get', '/v1/financial_connections/accounts/fca_xyz'); + $result = $this->client->financialConnections->accounts->retrieve( + 'fca_xyz', + [] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result); + } + + public function testRefreshAccount() + { + $this->expectsRequest( + 'post', + '/v1/financial_connections/accounts/fca_xyz/refresh' + ); + $result = $this->client->financialConnections->accounts->refresh( + 'fca_xyz', + ['features' => ['balance']] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result); + } + + public function testDisconnectAccount() + { + $this->expectsRequest( + 'post', + '/v1/financial_connections/accounts/fca_xyz/disconnect' + ); + $result = $this->client->financialConnections->accounts->disconnect( + 'fca_xyz', + [] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result); + } + + public function testCreateSession2() + { + $this->expectsRequest('post', '/v1/financial_connections/sessions'); + $result = $this->client->financialConnections->sessions->create( + [ + 'account_holder' => ['type' => 'customer', 'customer' => 'cus_123'], + 'permissions' => ['balances'], + ] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Session::class, $result); + } + + public function testRetrieveSession() + { + $this->expectsRequest( + 'get', + '/v1/financial_connections/sessions/fcsess_xyz' + ); + $result = $this->client->financialConnections->sessions->retrieve( + 'fcsess_xyz', + [] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Session::class, $result); + } + + public function testListAccount() + { + $this->expectsRequest('get', '/v1/financial_connections/accounts'); + $result = $this->client->financialConnections->accounts->all([]); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Customer::class, $result->data[0]); + static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result->data[0]); + } + + public function testListOwnersAccount() + { + $this->expectsRequest( + 'get', + '/v1/financial_connections/accounts/fca_xyz/owners' + ); + $result = $this->client->financialConnections->accounts->allOwners( + 'fca_xyz', + ['ownership' => 'fcaowns_xyz'] + ); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\FinancialConnections\AccountOwner::class, $result->data[0]); + } + + public function testFailInboundTransfer() + { + $this->expectsRequest( + 'post', + '/v1/test_helpers/treasury/inbound_transfers/ibt_123/fail' + ); + $result = $this->client->testHelpers->treasury->inboundTransfers->fail( + 'ibt_123', + ['failure_details' => ['code' => 'account_closed']] + ); + static::assertInstanceOf(\Stripe\Treasury\InboundTransfer::class, $result); + } + + public function testReturnInboundTransferInboundTransfer() + { + $this->expectsRequest( + 'post', + '/v1/test_helpers/treasury/inbound_transfers/ibt_123/return' + ); + $result = $this->client->testHelpers->treasury->inboundTransfers->returnInboundTransfer( + 'ibt_123', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\InboundTransfer::class, $result); } - public function testRetrieveBalanceTransaction() + public function testSucceedInboundTransfer() { - $this->expectsRequest('get', '/v1/balance_transactions/txn_xxxxxxxxxxxxx'); - $result = $this->client->balanceTransactions->retrieve( - 'txn_xxxxxxxxxxxxx', + $this->expectsRequest( + 'post', + '/v1/test_helpers/treasury/inbound_transfers/ibt_123/succeed' + ); + $result = $this->client->testHelpers->treasury->inboundTransfers->succeed( + 'ibt_123', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\InboundTransfer::class, $result); + } + + public function testPostOutboundTransfer() + { + $this->expectsRequest( + 'post', + '/v1/test_helpers/treasury/outbound_transfers/obt_123/post' + ); + $result = $this->client->testHelpers->treasury->outboundTransfers->post( + 'obt_123', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\OutboundTransfer::class, $result); + } + + public function testFailOutboundTransfer() + { + $this->expectsRequest( + 'post', + '/v1/test_helpers/treasury/outbound_transfers/obt_123/fail' + ); + $result = $this->client->testHelpers->treasury->outboundTransfers->fail( + 'obt_123', [] ); - static::assertInstanceOf(\Stripe\BalanceTransaction::class, $result); + static::assertInstanceOf(\Stripe\Treasury\OutboundTransfer::class, $result); + } + + public function testReturnOutboundTransferOutboundTransfer() + { + $this->expectsRequest( + 'post', + '/v1/test_helpers/treasury/outbound_transfers/obt_123/return' + ); + $result = $this->client->testHelpers->treasury->outboundTransfers->returnOutboundTransfer( + 'obt_123', + ['returned_details' => ['code' => 'account_closed']] + ); + static::assertInstanceOf(\Stripe\Treasury\OutboundTransfer::class, $result); + } + + public function testCreateReceivedCredit() + { + $this->expectsRequest('post', '/v1/test_helpers/treasury/received_credits'); + $result = $this->client->testHelpers->treasury->receivedCredits->create( + [ + 'financial_account' => 'fa_123', + 'network' => 'ach', + 'amount' => 1234, + 'currency' => 'usd', + ] + ); + static::assertInstanceOf(\Stripe\Treasury\ReceivedCredit::class, $result); + } + + public function testCreateReceivedDebit() + { + $this->expectsRequest('post', '/v1/test_helpers/treasury/received_debits'); + $result = $this->client->testHelpers->treasury->receivedDebits->create( + [ + 'financial_account' => 'fa_123', + 'network' => 'ach', + 'amount' => 1234, + 'currency' => 'usd', + ] + ); + static::assertInstanceOf(\Stripe\Treasury\ReceivedDebit::class, $result); } - public function testListBalanceTransaction() + public function testListCustomer() { - $this->expectsRequest('get', '/v1/balance_transactions'); - $result = $this->client->balanceTransactions->all(['limit' => 3]); + $this->expectsRequest('get', '/v1/customers'); + $result = $this->client->customers->all(['limit' => 3]); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\BalanceTransaction::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Customer::class, $result->data[0]); + } + + public function testSearchCustomer() + { + $this->expectsRequest('get', '/v1/customers/search'); + $result = $this->client->customers->search( + ['query' => 'name:\'fakename\' AND metadata[\'foo\']:\'bar\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]}} } public function testCreateCharge() @@ -91,6 +546,15 @@ public function testListCharge() static::assertInstanceOf(\Stripe\Charge::class, $result->data[0]); } + public function testSearchCharge() + { + $this->expectsRequest('get', '/v1/charges/search'); + $result = $this->client->charges->search( + ['query' => 'amount>999 AND metadata[\'order_id\']:\'6735\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Charge","namespaces":[]}} + } + public function testCreateCustomer() { $this->expectsRequest('post', '/v1/customers'); @@ -132,6 +596,15 @@ public function testListCustomer2() static::assertInstanceOf(\Stripe\Customer::class, $result->data[0]); } + public function testSearchCustomer2() + { + $this->expectsRequest('get', '/v1/customers/search'); + $result = $this->client->customers->search( + ['query' => 'name:\'fakename\' AND metadata[\'foo\']:\'bar\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]}} + } + public function testRetrieveDispute() { $this->expectsRequest('get', '/v1/disputes/dp_xxxxxxxxxxxxx'); @@ -235,7 +708,7 @@ public function testRetrieveMandate() static::assertInstanceOf(\Stripe\Mandate::class, $result); } - public function testCreatePaymentIntent() + public function testCreatePaymentIntent2() { $this->expectsRequest('post', '/v1/payment_intents'); $result = $this->client->paymentIntents->create( @@ -306,6 +779,41 @@ public function testListPaymentIntent() static::assertInstanceOf(\Stripe\PaymentIntent::class, $result->data[0]); } + public function testIncrementAuthorizationPaymentIntent() + { + $this->expectsRequest( + 'post', + '/v1/payment_intents/pi_xxxxxxxxxxxxx/increment_authorization' + ); + $result = $this->client->paymentIntents->incrementAuthorization( + 'pi_xxxxxxxxxxxxx', + ['amount' => 2099] + ); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $result); + } + + public function testSearchPaymentIntent() + { + $this->expectsRequest('get', '/v1/payment_intents/search'); + $result = $this->client->paymentIntents->search( + ['query' => 'status:\'succeeded\' AND metadata[\'order_id\']:\'6735\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"PaymentIntent","namespaces":[]}} + } + + public function testApplyCustomerBalancePaymentIntent() + { + $this->expectsRequest( + 'post', + '/v1/payment_intents/pi_xxxxxxxxxxxxx/apply_customer_balance' + ); + $result = $this->client->paymentIntents->applyCustomerBalance( + 'pi_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $result); + } + public function testCreateSetupIntent() { $this->expectsRequest('post', '/v1/setup_intents'); @@ -367,7 +875,7 @@ public function testListSetupAttempt() { $this->expectsRequest('get', '/v1/setup_attempts'); $result = $this->client->setupAttempts->all( - ['setup_intent' => 'seti_xxxxxxxxxxxxx', 'limit' => 3] + ['limit' => 3, 'setup_intent' => 'si_xyz'] ); static::assertInstanceOf(\Stripe\Collection::class, $result); static::assertInstanceOf(\Stripe\SetupAttempt::class, $result->data[0]); @@ -421,84 +929,6 @@ public function testReversePayout() static::assertInstanceOf(\Stripe\Payout::class, $result); } - public function testCreateProduct() - { - $this->expectsRequest('post', '/v1/products'); - $result = $this->client->products->create(['name' => 'Gold Special']); - static::assertInstanceOf(\Stripe\Product::class, $result); - } - - public function testRetrieveProduct() - { - $this->expectsRequest('get', '/v1/products/prod_xxxxxxxxxxxxx'); - $result = $this->client->products->retrieve('prod_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\Product::class, $result); - } - - public function testUpdateProduct() - { - $this->expectsRequest('post', '/v1/products/prod_xxxxxxxxxxxxx'); - $result = $this->client->products->update( - 'prod_xxxxxxxxxxxxx', - ['metadata' => ['order_id' => '6735']] - ); - static::assertInstanceOf(\Stripe\Product::class, $result); - } - - public function testListProduct() - { - $this->expectsRequest('get', '/v1/products'); - $result = $this->client->products->all(['limit' => 3]); - static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Product::class, $result->data[0]); - } - - public function testDeleteProduct() - { - $this->expectsRequest('delete', '/v1/products/prod_xxxxxxxxxxxxx'); - $result = $this->client->products->delete('prod_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\Product::class, $result); - } - - public function testCreatePrice() - { - $this->expectsRequest('post', '/v1/prices'); - $result = $this->client->prices->create( - [ - 'unit_amount' => 2000, - 'currency' => 'usd', - 'recurring' => ['interval' => 'month'], - 'product' => 'prod_xxxxxxxxxxxxx', - ] - ); - static::assertInstanceOf(\Stripe\Price::class, $result); - } - - public function testRetrievePrice() - { - $this->expectsRequest('get', '/v1/prices/price_xxxxxxxxxxxxx'); - $result = $this->client->prices->retrieve('price_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\Price::class, $result); - } - - public function testUpdatePrice() - { - $this->expectsRequest('post', '/v1/prices/price_xxxxxxxxxxxxx'); - $result = $this->client->prices->update( - 'price_xxxxxxxxxxxxx', - ['metadata' => ['order_id' => '6735']] - ); - static::assertInstanceOf(\Stripe\Price::class, $result); - } - - public function testListPrice() - { - $this->expectsRequest('get', '/v1/prices'); - $result = $this->client->prices->all(['limit' => 3]); - static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Price::class, $result->data[0]); - } - public function testCreateRefund() { $this->expectsRequest('post', '/v1/refunds'); @@ -523,6 +953,13 @@ public function testUpdateRefund() static::assertInstanceOf(\Stripe\Refund::class, $result); } + public function testCancelRefund() + { + $this->expectsRequest('post', '/v1/refunds/re_xxxxxxxxxxxxx/cancel'); + $result = $this->client->refunds->cancel('re_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Refund::class, $result); + } + public function testListRefund() { $this->expectsRequest('get', '/v1/refunds'); @@ -539,7 +976,7 @@ public function testCreateToken() 'card' => [ 'number' => '4242424242424242', 'exp_month' => '5', - 'exp_year' => '2022', + 'exp_year' => '2023', 'cvc' => '314', ], ] @@ -626,7 +1063,7 @@ public function testCreatePaymentMethod() 'card' => [ 'number' => '4242424242424242', 'exp_month' => 5, - 'exp_year' => 2022, + 'exp_year' => 2023, 'cvc' => '314', ], ] @@ -701,37 +1138,100 @@ public function testUpdateSource() static::assertInstanceOf(\Stripe\Source::class, $result); } - public function testCreateSession() + public function testCreateProduct() { - $this->expectsRequest('post', '/v1/checkout/sessions'); - $result = $this->client->checkout->sessions->create( + $this->expectsRequest('post', '/v1/products'); + $result = $this->client->products->create(['name' => 'Gold Special']); + static::assertInstanceOf(\Stripe\Product::class, $result); + } + + public function testRetrieveProduct() + { + $this->expectsRequest('get', '/v1/products/prod_xxxxxxxxxxxxx'); + $result = $this->client->products->retrieve('prod_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Product::class, $result); + } + + public function testUpdateProduct() + { + $this->expectsRequest('post', '/v1/products/prod_xxxxxxxxxxxxx'); + $result = $this->client->products->update( + 'prod_xxxxxxxxxxxxx', + ['metadata' => ['order_id' => '6735']] + ); + static::assertInstanceOf(\Stripe\Product::class, $result); + } + + public function testListProduct() + { + $this->expectsRequest('get', '/v1/products'); + $result = $this->client->products->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Product::class, $result->data[0]); + } + + public function testDeleteProduct() + { + $this->expectsRequest('delete', '/v1/products/prod_xxxxxxxxxxxxx'); + $result = $this->client->products->delete('prod_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Product::class, $result); + } + + public function testSearchProduct() + { + $this->expectsRequest('get', '/v1/products/search'); + $result = $this->client->products->search( + ['query' => 'active:\'true\' AND metadata[\'order_id\']:\'6735\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Product","namespaces":[]}} + } + + public function testCreatePrice() + { + $this->expectsRequest('post', '/v1/prices'); + $result = $this->client->prices->create( [ - 'success_url' => 'https://example.com/success', - 'cancel_url' => 'https://example.com/cancel', - 'payment_method_types' => ['card'], - 'line_items' => [['price' => 'price_xxxxxxxxxxxxx', 'quantity' => 2]], - 'mode' => 'payment', + 'unit_amount' => 2000, + 'currency' => 'usd', + 'recurring' => ['interval' => 'month'], + 'product' => 'prod_xxxxxxxxxxxxx', ] ); - static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + static::assertInstanceOf(\Stripe\Price::class, $result); } - public function testRetrieveSession() + public function testRetrievePrice() { - $this->expectsRequest('get', '/v1/checkout/sessions/cs_test_xxxxxxxxxxxxx'); - $result = $this->client->checkout->sessions->retrieve( - 'cs_test_xxxxxxxxxxxxx', - [] + $this->expectsRequest('get', '/v1/prices/price_xxxxxxxxxxxxx'); + $result = $this->client->prices->retrieve('price_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Price::class, $result); + } + + public function testUpdatePrice() + { + $this->expectsRequest('post', '/v1/prices/price_xxxxxxxxxxxxx'); + $result = $this->client->prices->update( + 'price_xxxxxxxxxxxxx', + ['metadata' => ['order_id' => '6735']] ); - static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + static::assertInstanceOf(\Stripe\Price::class, $result); } - public function testListSession() + public function testListPrice() { - $this->expectsRequest('get', '/v1/checkout/sessions'); - $result = $this->client->checkout->sessions->all(['limit' => 3]); + $this->expectsRequest('get', '/v1/prices'); + $result = $this->client->prices->all(['limit' => 3]); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Checkout\Session::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Price::class, $result->data[0]); + } + + public function testSearchPrice() + { + $this->expectsRequest('get', '/v1/prices/search'); + $result = $this->client->prices->search( + ['query' => 'active:\'true\' AND metadata[\'order_id\']:\'6735\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Price","namespaces":[]}} } public function testCreateCoupon() @@ -739,7 +1239,7 @@ public function testCreateCoupon() $this->expectsRequest('post', '/v1/coupons'); $result = $this->client->coupons->create( [ - 'percent_off' => 25, + 'percent_off' => 25.5, 'duration' => 'repeating', 'duration_in_months' => 3, ] @@ -749,16 +1249,16 @@ public function testCreateCoupon() public function testRetrieveCoupon() { - $this->expectsRequest('get', '/v1/coupons/25_5OFF'); - $result = $this->client->coupons->retrieve('25_5OFF', []); + $this->expectsRequest('get', '/v1/coupons/Z4OV52SU'); + $result = $this->client->coupons->retrieve('Z4OV52SU', []); static::assertInstanceOf(\Stripe\Coupon::class, $result); } public function testUpdateCoupon() { - $this->expectsRequest('post', '/v1/coupons/co_xxxxxxxxxxxxx'); + $this->expectsRequest('post', '/v1/coupons/Z4OV52SU'); $result = $this->client->coupons->update( - 'co_xxxxxxxxxxxxx', + 'Z4OV52SU', ['metadata' => ['order_id' => '6735']] ); static::assertInstanceOf(\Stripe\Coupon::class, $result); @@ -766,8 +1266,8 @@ public function testUpdateCoupon() public function testDeleteCoupon() { - $this->expectsRequest('delete', '/v1/coupons/co_xxxxxxxxxxxxx'); - $result = $this->client->coupons->delete('co_xxxxxxxxxxxxx', []); + $this->expectsRequest('delete', '/v1/coupons/Z4OV52SU'); + $result = $this->client->coupons->delete('Z4OV52SU', []); static::assertInstanceOf(\Stripe\Coupon::class, $result); } @@ -779,22 +1279,211 @@ public function testListCoupon() static::assertInstanceOf(\Stripe\Coupon::class, $result->data[0]); } - public function testPreviewCreditNote() + public function testCreatePromotionCode() + { + $this->expectsRequest('post', '/v1/promotion_codes'); + $result = $this->client->promotionCodes->create(['coupon' => 'Z4OV52SU']); + static::assertInstanceOf(\Stripe\PromotionCode::class, $result); + } + + public function testUpdatePromotionCode() + { + $this->expectsRequest('post', '/v1/promotion_codes/promo_xxxxxxxxxxxxx'); + $result = $this->client->promotionCodes->update( + 'promo_xxxxxxxxxxxxx', + ['metadata' => ['order_id' => '6735']] + ); + static::assertInstanceOf(\Stripe\PromotionCode::class, $result); + } + + public function testRetrievePromotionCode() + { + $this->expectsRequest('get', '/v1/promotion_codes/promo_xxxxxxxxxxxxx'); + $result = $this->client->promotionCodes->retrieve( + 'promo_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\PromotionCode::class, $result); + } + + public function testListPromotionCode() + { + $this->expectsRequest('get', '/v1/promotion_codes'); + $result = $this->client->promotionCodes->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\PromotionCode::class, $result->data[0]); + } + + public function testListTaxCode() { - $this->expectsRequest('get', '/v1/credit_notes/preview'); - $result = $this->client->creditNotes->preview( + $this->expectsRequest('get', '/v1/tax_codes'); + $result = $this->client->taxCodes->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\TaxCode::class, $result->data[0]); + } + + public function testRetrieveTaxCode() + { + $this->expectsRequest('get', '/v1/tax_codes/txcd_xxxxxxxxxxxxx'); + $result = $this->client->taxCodes->retrieve('txcd_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\TaxCode::class, $result); + } + + public function testCreateTaxRate() + { + $this->expectsRequest('post', '/v1/tax_rates'); + $result = $this->client->taxRates->create( [ - 'invoice' => 'in_xxxxxxxxxxxxx', - 'lines' => [ - [ - 'type' => 'invoice_line_item', - 'invoice_line_item' => 'il_xxxxxxxxxxxxx', - 'quantity' => 1, - ], - ], + 'display_name' => 'VAT', + 'description' => 'VAT Germany', + 'jurisdiction' => 'DE', + 'percentage' => 16, + 'inclusive' => false, + ] + ); + static::assertInstanceOf(\Stripe\TaxRate::class, $result); + } + + public function testRetrieveTaxRate() + { + $this->expectsRequest('get', '/v1/tax_rates/txr_xxxxxxxxxxxxx'); + $result = $this->client->taxRates->retrieve('txr_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\TaxRate::class, $result); + } + + public function testUpdateTaxRate() + { + $this->expectsRequest('post', '/v1/tax_rates/txr_xxxxxxxxxxxxx'); + $result = $this->client->taxRates->update( + 'txr_xxxxxxxxxxxxx', + ['active' => false] + ); + static::assertInstanceOf(\Stripe\TaxRate::class, $result); + } + + public function testListTaxRate() + { + $this->expectsRequest('get', '/v1/tax_rates'); + $result = $this->client->taxRates->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\TaxRate::class, $result->data[0]); + } + + public function testCreateShippingRate2() + { + $this->expectsRequest('post', '/v1/shipping_rates'); + $result = $this->client->shippingRates->create( + [ + 'display_name' => 'Ground shipping', + 'type' => 'fixed_amount', + 'fixed_amount' => ['amount' => 500, 'currency' => 'usd'], + ] + ); + static::assertInstanceOf(\Stripe\ShippingRate::class, $result); + } + + public function testRetrieveShippingRate() + { + $this->expectsRequest('get', '/v1/shipping_rates/shr_xxxxxxxxxxxxx'); + $result = $this->client->shippingRates->retrieve('shr_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\ShippingRate::class, $result); + } + + public function testUpdateShippingRate() + { + $this->expectsRequest('post', '/v1/shipping_rates/shr_xxxxxxxxxxxxx'); + $result = $this->client->shippingRates->update( + 'shr_xxxxxxxxxxxxx', + ['metadata' => ['order_id' => '6735']] + ); + static::assertInstanceOf(\Stripe\ShippingRate::class, $result); + } + + public function testListShippingRate2() + { + $this->expectsRequest('get', '/v1/shipping_rates'); + $result = $this->client->shippingRates->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\ShippingRate::class, $result->data[0]); + } + + public function testCreateSession3() + { + $this->expectsRequest('post', '/v1/checkout/sessions'); + $result = $this->client->checkout->sessions->create( + [ + 'success_url' => 'https://example.com/success', + 'cancel_url' => 'https://example.com/cancel', + 'line_items' => [['price' => 'price_xxxxxxxxxxxxx', 'quantity' => 2]], + 'mode' => 'payment', ] ); - static::assertInstanceOf(\Stripe\CreditNote::class, $result); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + } + + public function testExpireSession2() + { + $this->expectsRequest( + 'post', + '/v1/checkout/sessions/cs_test_xxxxxxxxxxxxx/expire' + ); + $result = $this->client->checkout->sessions->expire( + 'cs_test_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + } + + public function testRetrieveSession2() + { + $this->expectsRequest('get', '/v1/checkout/sessions/cs_test_xxxxxxxxxxxxx'); + $result = $this->client->checkout->sessions->retrieve( + 'cs_test_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + } + + public function testListSession() + { + $this->expectsRequest('get', '/v1/checkout/sessions'); + $result = $this->client->checkout->sessions->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Checkout\Session::class, $result->data[0]); + } + + public function testCreatePaymentLink2() + { + $this->expectsRequest('post', '/v1/payment_links'); + $result = $this->client->paymentLinks->create( + ['line_items' => [['price' => 'price_xxxxxxxxxxxxx', 'quantity' => 1]]] + ); + static::assertInstanceOf(\Stripe\PaymentLink::class, $result); + } + + public function testRetrievePaymentLink2() + { + $this->expectsRequest('get', '/v1/payment_links/plink_xxxxxxxxxxxxx'); + $result = $this->client->paymentLinks->retrieve('plink_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\PaymentLink::class, $result); + } + + public function testUpdatePaymentLink() + { + $this->expectsRequest('post', '/v1/payment_links/plink_xxxxxxxxxxxxx'); + $result = $this->client->paymentLinks->update( + 'plink_xxxxxxxxxxxxx', + ['active' => false] + ); + static::assertInstanceOf(\Stripe\PaymentLink::class, $result); + } + + public function testListPaymentLink() + { + $this->expectsRequest('get', '/v1/payment_links'); + $result = $this->client->paymentLinks->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\PaymentLink::class, $result->data[0]); } public function testCreateCreditNote() @@ -843,24 +1532,6 @@ public function testListCreditNoteLineItem() static::assertInstanceOf(\Stripe\CreditNoteLineItem::class, $result->data[0]); } - public function testPreviewCreditNote2() - { - $this->expectsRequest('get', '/v1/credit_notes/preview'); - $result = $this->client->creditNotes->preview( - [ - 'invoice' => 'in_xxxxxxxxxxxxx', - 'lines' => [ - [ - 'type' => 'invoice_line_item', - 'invoice_line_item' => 'il_xxxxxxxxxxxxx', - 'quantity' => 1, - ], - ], - ] - ); - static::assertInstanceOf(\Stripe\CreditNote::class, $result); - } - public function testVoidCreditNoteCreditNote() { $this->expectsRequest('post', '/v1/credit_notes/cn_xxxxxxxxxxxxx/void'); @@ -934,7 +1605,7 @@ public function testListCustomerBalanceTransaction() static::assertInstanceOf(\Stripe\CustomerBalanceTransaction::class, $result->data[0]); } - public function testCreateSession2() + public function testCreateSession4() { $this->expectsRequest('post', '/v1/billing_portal/sessions'); $result = $this->client->billingPortal->sessions->create( @@ -946,7 +1617,7 @@ public function testCreateSession2() static::assertInstanceOf(\Stripe\BillingPortal\Session::class, $result); } - public function testUpdateConfiguration() + public function testUpdateConfiguration2() { $this->expectsRequest( 'post', @@ -964,7 +1635,7 @@ public function testUpdateConfiguration() static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $result); } - public function testRetrieveConfiguration() + public function testRetrieveConfiguration2() { $this->expectsRequest( 'get', @@ -977,7 +1648,7 @@ public function testRetrieveConfiguration() static::assertInstanceOf(\Stripe\BillingPortal\Configuration::class, $result); } - public function testListConfiguration() + public function testListConfiguration2() { $this->expectsRequest('get', '/v1/billing_portal/configurations'); $result = $this->client->billingPortal->configurations->all(['limit' => 3]); @@ -1116,6 +1787,15 @@ public function testListInvoice() static::assertInstanceOf(\Stripe\Invoice::class, $result->data[0]); } + public function testSearchInvoice() + { + $this->expectsRequest('get', '/v1/invoices/search'); + $result = $this->client->invoices->search( + ['query' => 'total>999 AND metadata[\'order_id\']:\'6735\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Invoice","namespaces":[]}} + } + public function testCreateInvoiceItem() { $this->expectsRequest('post', '/v1/invoiceitems'); @@ -1203,39 +1883,62 @@ public function testListPlan() static::assertInstanceOf(\Stripe\Plan::class, $result->data[0]); } - public function testCreatePromotionCode() + public function testCreateQuote() { - $this->expectsRequest('post', '/v1/promotion_codes'); - $result = $this->client->promotionCodes->create(['coupon' => '25_5OFF']); - static::assertInstanceOf(\Stripe\PromotionCode::class, $result); + $this->expectsRequest('post', '/v1/quotes'); + $result = $this->client->quotes->create( + [ + 'customer' => 'cus_xxxxxxxxxxxxx', + 'line_items' => [['price' => 'price_xxxxxxxxxxxxx', 'quantity' => 2]], + ] + ); + static::assertInstanceOf(\Stripe\Quote::class, $result); } - public function testUpdatePromotionCode() + public function testRetrieveQuote() { - $this->expectsRequest('post', '/v1/promotion_codes/promo_xxxxxxxxxxxxx'); - $result = $this->client->promotionCodes->update( - 'promo_xxxxxxxxxxxxx', + $this->expectsRequest('get', '/v1/quotes/qt_xxxxxxxxxxxxx'); + $result = $this->client->quotes->retrieve('qt_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Quote::class, $result); + } + + public function testUpdateQuote() + { + $this->expectsRequest('post', '/v1/quotes/qt_xxxxxxxxxxxxx'); + $result = $this->client->quotes->update( + 'qt_xxxxxxxxxxxxx', ['metadata' => ['order_id' => '6735']] ); - static::assertInstanceOf(\Stripe\PromotionCode::class, $result); + static::assertInstanceOf(\Stripe\Quote::class, $result); } - public function testRetrievePromotionCode() + public function testFinalizeQuoteQuote() { - $this->expectsRequest('get', '/v1/promotion_codes/promo_xxxxxxxxxxxxx'); - $result = $this->client->promotionCodes->retrieve( - 'promo_xxxxxxxxxxxxx', - [] - ); - static::assertInstanceOf(\Stripe\PromotionCode::class, $result); + $this->expectsRequest('post', '/v1/quotes/qt_xxxxxxxxxxxxx/finalize'); + $result = $this->client->quotes->finalizeQuote('qt_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Quote::class, $result); } - public function testListPromotionCode() + public function testAcceptQuote() { - $this->expectsRequest('get', '/v1/promotion_codes'); - $result = $this->client->promotionCodes->all(['limit' => 3]); + $this->expectsRequest('post', '/v1/quotes/qt_xxxxxxxxxxxxx/accept'); + $result = $this->client->quotes->accept('qt_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Quote::class, $result); + } + + public function testCancelQuote() + { + $this->expectsRequest('post', '/v1/quotes/qt_xxxxxxxxxxxxx/cancel'); + $result = $this->client->quotes->cancel('qt_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Quote::class, $result); + } + + public function testListQuote() + { + $this->expectsRequest('get', '/v1/quotes'); + $result = $this->client->quotes->all(['limit' => 3]); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\PromotionCode::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Quote::class, $result->data[0]); } public function testCreateSubscription() @@ -1282,6 +1985,15 @@ public function testListSubscription() static::assertInstanceOf(\Stripe\Subscription::class, $result->data[0]); } + public function testSearchSubscription() + { + $this->expectsRequest('get', '/v1/subscriptions/search'); + $result = $this->client->subscriptions->search( + ['query' => 'status:\'active\' AND metadata[\'order_id\']:\'6735\''] + ); + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Subscription","namespaces":[]}} + } + public function testCreateSubscriptionItem() { $this->expectsRequest('post', '/v1/subscription_items'); @@ -1338,7 +2050,7 @@ public function testCreateSubscriptionSchedule() $result = $this->client->subscriptionSchedules->create( [ 'customer' => 'cus_xxxxxxxxxxxxx', - 'start_date' => 1620753115, + 'start_date' => 1652909005, 'end_behavior' => 'release', 'phases' => [ [ @@ -1411,44 +2123,60 @@ public function testListSubscriptionSchedule() static::assertInstanceOf(\Stripe\SubscriptionSchedule::class, $result->data[0]); } - public function testCreateTaxRate() + public function testCreateTestClock2() { - $this->expectsRequest('post', '/v1/tax_rates'); - $result = $this->client->taxRates->create( - [ - 'display_name' => 'VAT', - 'description' => 'VAT Germany', - 'jurisdiction' => 'DE', - 'percentage' => 16, - 'inclusive' => false, - ] + $this->expectsRequest('post', '/v1/test_helpers/test_clocks'); + $result = $this->client->testHelpers->testClocks->create( + ['frozen_time' => 1577836800] ); - static::assertInstanceOf(\Stripe\TaxRate::class, $result); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); } - public function testRetrieveTaxRate() + public function testRetrieveTestClock2() { - $this->expectsRequest('get', '/v1/tax_rates/txr_xxxxxxxxxxxxx'); - $result = $this->client->taxRates->retrieve('txr_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\TaxRate::class, $result); + $this->expectsRequest( + 'get', + '/v1/test_helpers/test_clocks/clock_xxxxxxxxxxxxx' + ); + $result = $this->client->testHelpers->testClocks->retrieve( + 'clock_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); } - public function testUpdateTaxRate() + public function testDeleteTestClock2() { - $this->expectsRequest('post', '/v1/tax_rates/txr_xxxxxxxxxxxxx'); - $result = $this->client->taxRates->update( - 'txr_xxxxxxxxxxxxx', - ['active' => false] + $this->expectsRequest( + 'delete', + '/v1/test_helpers/test_clocks/clock_xxxxxxxxxxxxx' ); - static::assertInstanceOf(\Stripe\TaxRate::class, $result); + $result = $this->client->testHelpers->testClocks->delete( + 'clock_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); } - public function testListTaxRate() + public function testAdvanceTestClock2() { - $this->expectsRequest('get', '/v1/tax_rates'); - $result = $this->client->taxRates->all(['limit' => 3]); + $this->expectsRequest( + 'post', + '/v1/test_helpers/test_clocks/clock_xxxxxxxxxxxxx/advance' + ); + $result = $this->client->testHelpers->testClocks->advance( + 'clock_xxxxxxxxxxxxx', + ['frozen_time' => 1652390605] + ); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + } + + public function testListTestClock2() + { + $this->expectsRequest('get', '/v1/test_helpers/test_clocks'); + $result = $this->client->testHelpers->testClocks->all(['limit' => 3]); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\TaxRate::class, $result->data[0]); + static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result->data[0]); } public function testCreateUsageRecord() @@ -1495,7 +2223,7 @@ public function testCreateAccount() static::assertInstanceOf(\Stripe\Account::class, $result); } - public function testRetrieveAccount() + public function testRetrieveAccount2() { $this->expectsRequest('get', '/v1/accounts/acct_xxxxxxxxxxxxx'); $result = $this->client->accounts->retrieve('acct_xxxxxxxxxxxxx', []); @@ -1529,7 +2257,7 @@ public function testRejectAccount() static::assertInstanceOf(\Stripe\Account::class, $result); } - public function testListAccount() + public function testListAccount2() { $this->expectsRequest('get', '/v1/accounts'); $result = $this->client->accounts->all(['limit' => 3]); @@ -2341,532 +3069,823 @@ public function testCreateReader() public function testRetrieveReader() { - $this->expectsRequest('get', '/v1/terminal/readers/tmr_P400-123-456-789'); + $this->expectsRequest('get', '/v1/terminal/readers/tmr_xxxxxxxxxxxxx'); $result = $this->client->terminal->readers->retrieve( - 'tmr_P400-123-456-789', + 'tmr_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + } + + public function testUpdateReader() + { + $this->expectsRequest('post', '/v1/terminal/readers/tmr_xxxxxxxxxxxxx'); + $result = $this->client->terminal->readers->update( + 'tmr_xxxxxxxxxxxxx', + ['label' => 'Blue Rabbit'] + ); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + } + + public function testDeleteReader() + { + $this->expectsRequest('delete', '/v1/terminal/readers/tmr_xxxxxxxxxxxxx'); + $result = $this->client->terminal->readers->delete('tmr_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + } + + public function testListReader() + { + $this->expectsRequest('get', '/v1/terminal/readers'); + $result = $this->client->terminal->readers->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result->data[0]); + } + + public function testProcessPaymentIntentReader() + { + $this->expectsRequest( + 'post', + '/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_payment_intent' + ); + $result = $this->client->terminal->readers->processPaymentIntent( + 'tmr_xxxxxxxxxxxxx', + ['payment_intent' => 'pi_xxxxxxxxxxxxx'] + ); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + } + + public function testProcessSetupIntentReader() + { + $this->expectsRequest( + 'post', + '/v1/terminal/readers/tmr_xxxxxxxxxxxxx/process_setup_intent' + ); + $result = $this->client->terminal->readers->processSetupIntent( + 'tmr_xxxxxxxxxxxxx', + [ + 'setup_intent' => 'seti_xxxxxxxxxxxxx', + 'customer_consent_collected' => true, + ] + ); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + } + + public function testCancelActionReader() + { + $this->expectsRequest( + 'post', + '/v1/terminal/readers/tmr_xxxxxxxxxxxxx/cancel_action' + ); + $result = $this->client->terminal->readers->cancelAction( + 'tmr_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + } + + public function testRetrieveConfiguration3() + { + $this->expectsRequest( + 'get', + '/v1/terminal/configurations/tmc_xxxxxxxxxxxxx' + ); + $result = $this->client->terminal->configurations->retrieve( + 'tmc_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + } + + public function testUpdateConfiguration3() + { + $this->expectsRequest( + 'post', + '/v1/terminal/configurations/tmc_xxxxxxxxxxxxx' + ); + $result = $this->client->terminal->configurations->update( + 'tmc_xxxxxxxxxxxxx', + ['bbpos_wisepos_e' => ['splashscreen' => 'file_xxxxxxxxxxxxx']] + ); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + } + + public function testDeleteConfiguration2() + { + $this->expectsRequest( + 'delete', + '/v1/terminal/configurations/tmc_xxxxxxxxxxxxx' + ); + $result = $this->client->terminal->configurations->delete( + 'tmc_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + } + + public function testListConfiguration3() + { + $this->expectsRequest('get', '/v1/terminal/configurations'); + $result = $this->client->terminal->configurations->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result->data[0]); + } + + public function testCreateFinancialAccount() + { + $this->expectsRequest('post', '/v1/treasury/financial_accounts'); + $result = $this->client->treasury->financialAccounts->create( + ['supported_currencies' => ['usd'], 'features' => []] + ); + static::assertInstanceOf(\Stripe\Treasury\FinancialAccount::class, $result); + } + + public function testUpdateFinancialAccount() + { + $this->expectsRequest( + 'post', + '/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx' + ); + $result = $this->client->treasury->financialAccounts->update( + 'fa_xxxxxxxxxxxxx', + ['metadata' => ['order_id' => '6735']] + ); + static::assertInstanceOf(\Stripe\Treasury\FinancialAccount::class, $result); + } + + public function testRetrieveFinancialAccount() + { + $this->expectsRequest( + 'get', + '/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx' + ); + $result = $this->client->treasury->financialAccounts->retrieve( + 'fa_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\FinancialAccount::class, $result); + } + + public function testListFinancialAccount() + { + $this->expectsRequest('get', '/v1/treasury/financial_accounts'); + $result = $this->client->treasury->financialAccounts->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Treasury\FinancialAccount::class, $result->data[0]); + } + + public function testUpdateFeaturesFinancialAccount() + { + $this->expectsRequest( + 'post', + '/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx/features' + ); + $result = $this->client->treasury->financialAccounts->updateFeatures( + 'fa_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\FinancialAccountFeatures::class, $result); + } + + public function testRetrieveFeaturesFinancialAccount() + { + $this->expectsRequest( + 'get', + '/v1/treasury/financial_accounts/fa_xxxxxxxxxxxxx/features' + ); + $result = $this->client->treasury->financialAccounts->retrieveFeatures( + 'fa_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\FinancialAccountFeatures::class, $result); + } + + public function testRetrieveTransaction2() + { + $this->expectsRequest( + 'get', + '/v1/treasury/transactions/trxn_xxxxxxxxxxxxx' + ); + $result = $this->client->treasury->transactions->retrieve( + 'trxn_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + static::assertInstanceOf(\Stripe\Treasury\Transaction::class, $result); } - public function testUpdateReader() + public function testListTransaction2() { - $this->expectsRequest('post', '/v1/terminal/readers/tmr_P400-123-456-789'); - $result = $this->client->terminal->readers->update( - 'tmr_P400-123-456-789', - ['label' => 'Blue Rabbit'] + $this->expectsRequest('get', '/v1/treasury/transactions'); + $result = $this->client->treasury->transactions->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] ); - static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Treasury\Transaction::class, $result->data[0]); } - public function testDeleteReader() + public function testRetrieveTransactionEntry() { $this->expectsRequest( - 'delete', - '/v1/terminal/readers/tmr_P400-123-456-789' + 'get', + '/v1/treasury/transaction_entries/trxne_xxxxxxxxxxxxx' ); - $result = $this->client->terminal->readers->delete( - 'tmr_P400-123-456-789', + $result = $this->client->treasury->transactionEntries->retrieve( + 'trxne_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result); + static::assertInstanceOf(\Stripe\Treasury\TransactionEntry::class, $result); } - public function testListReader() + public function testListTransactionEntry() { - $this->expectsRequest('get', '/v1/terminal/readers'); - $result = $this->client->terminal->readers->all(['limit' => 3]); + $this->expectsRequest('get', '/v1/treasury/transaction_entries'); + $result = $this->client->treasury->transactionEntries->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] + ); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Terminal\Reader::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Treasury\TransactionEntry::class, $result->data[0]); } - public function testCreateSku() + public function testCreateOutboundTransfer() { - $this->expectsRequest('post', '/v1/skus'); - $result = $this->client->skus->create( + $this->expectsRequest('post', '/v1/treasury/outbound_transfers'); + $result = $this->client->treasury->outboundTransfers->create( [ - 'attributes' => ['size' => 'Medium', 'gender' => 'Unisex'], - 'price' => 1500, + 'financial_account' => 'fa_xxxxxxxxxxxxx', + 'destination_payment_method' => 'pm_xxxxxxxxxxxxx', + 'amount' => 500, 'currency' => 'usd', - 'inventory' => ['type' => 'finite', 'quantity' => 500], - 'product' => 'prod_xxxxxxxxxxxxx', + 'description' => 'OutboundTransfer to my external bank account', ] ); - static::assertInstanceOf(\Stripe\SKU::class, $result); - } - - public function testRetrieveSku() - { - $this->expectsRequest('get', '/v1/skus/sku_xxxxxxxxxxxxx'); - $result = $this->client->skus->retrieve('sku_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\SKU::class, $result); + static::assertInstanceOf(\Stripe\Treasury\OutboundTransfer::class, $result); } - public function testUpdateSku() + public function testCancelOutboundTransfer() { - $this->expectsRequest('post', '/v1/skus/sku_xxxxxxxxxxxxx'); - $result = $this->client->skus->update( - 'sku_xxxxxxxxxxxxx', - ['metadata' => ['order_id' => '6735']] + $this->expectsRequest( + 'post', + '/v1/treasury/outbound_transfers/obt_xxxxxxxxxxxxx/cancel' ); - static::assertInstanceOf(\Stripe\SKU::class, $result); - } - - public function testListSku() - { - $this->expectsRequest('get', '/v1/skus'); - $result = $this->client->skus->all(['limit' => 3]); - static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\SKU::class, $result->data[0]); - } - - public function testDeleteSku() - { - $this->expectsRequest('delete', '/v1/skus/sku_xxxxxxxxxxxxx'); - $result = $this->client->skus->delete('sku_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\SKU::class, $result); + $result = $this->client->treasury->outboundTransfers->cancel( + 'obt_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\OutboundTransfer::class, $result); } - public function testRetrieveScheduledQueryRun() + public function testRetrieveOutboundTransfer() { $this->expectsRequest( 'get', - '/v1/sigma/scheduled_query_runs/sqr_xxxxxxxxxxxxx' + '/v1/treasury/outbound_transfers/obt_xxxxxxxxxxxxx' ); - $result = $this->client->sigma->scheduledQueryRuns->retrieve( - 'sqr_xxxxxxxxxxxxx', + $result = $this->client->treasury->outboundTransfers->retrieve( + 'obt_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $result); + static::assertInstanceOf(\Stripe\Treasury\OutboundTransfer::class, $result); } - public function testListScheduledQueryRun() + public function testListOutboundTransfer() { - $this->expectsRequest('get', '/v1/sigma/scheduled_query_runs'); - $result = $this->client->sigma->scheduledQueryRuns->all(['limit' => 3]); + $this->expectsRequest('get', '/v1/treasury/outbound_transfers'); + $result = $this->client->treasury->outboundTransfers->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] + ); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Treasury\OutboundTransfer::class, $result->data[0]); } - public function testCreateReportRun() + public function testCreateOutboundPayment() { - $this->expectsRequest('post', '/v1/reporting/report_runs'); - $result = $this->client->reporting->reportRuns->create( + $this->expectsRequest('post', '/v1/treasury/outbound_payments'); + $result = $this->client->treasury->outboundPayments->create( [ - 'report_type' => 'balance.summary.1', - 'parameters' => [ - 'interval_start' => 1522540800, - 'interval_end' => 1525132800, - ], + 'financial_account' => 'fa_xxxxxxxxxxxxx', + 'amount' => 10000, + 'currency' => 'usd', + 'customer' => 'cu_xxxxxxxxxxxxx', + 'destination_payment_method' => 'pm_xxxxxxxxxxxxx', + 'description' => 'OutboundPayment to a 3rd party', ] ); - static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $result); + static::assertInstanceOf(\Stripe\Treasury\OutboundPayment::class, $result); } - public function testRetrieveReportRun() + public function testCancelOutboundPayment() { - $this->expectsRequest('get', '/v1/reporting/report_runs/frr_xxxxxxxxxxxxx'); - $result = $this->client->reporting->reportRuns->retrieve( - 'frr_xxxxxxxxxxxxx', + $this->expectsRequest( + 'post', + '/v1/treasury/outbound_payments/obp_xxxxxxxxxxxxx/cancel' + ); + $result = $this->client->treasury->outboundPayments->cancel( + 'obp_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $result); - } - - public function testListReportRun() - { - $this->expectsRequest('get', '/v1/reporting/report_runs'); - $result = $this->client->reporting->reportRuns->all(['limit' => 3]); - static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Treasury\OutboundPayment::class, $result); } - public function testRetrieveReportType() + public function testRetrieveOutboundPayment() { $this->expectsRequest( 'get', - '/v1/reporting/report_types/balance.summary.1' + '/v1/treasury/outbound_payments/obp_xxxxxxxxxxxxx' ); - $result = $this->client->reporting->reportTypes->retrieve( - 'balance.summary.1', + $result = $this->client->treasury->outboundPayments->retrieve( + 'obp_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\Reporting\ReportType::class, $result); + static::assertInstanceOf(\Stripe\Treasury\OutboundPayment::class, $result); } - public function testListReportType() + public function testListOutboundPayment() { - $this->expectsRequest('get', '/v1/reporting/report_types'); - $result = $this->client->reporting->reportTypes->all([]); + $this->expectsRequest('get', '/v1/treasury/outbound_payments'); + $result = $this->client->treasury->outboundPayments->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] + ); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Reporting\ReportType::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Treasury\OutboundPayment::class, $result->data[0]); } - public function testRetrieveWebhookEndpoint() + public function testCreateInboundTransfer() { - $this->expectsRequest('get', '/v1/webhook_endpoints/we_xxxxxxxxxxxxx'); - $result = $this->client->webhookEndpoints->retrieve('we_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result); + $this->expectsRequest('post', '/v1/treasury/inbound_transfers'); + $result = $this->client->treasury->inboundTransfers->create( + [ + 'financial_account' => 'fa_xxxxxxxxxxxxx', + 'amount' => 10000, + 'currency' => 'usd', + 'origin_payment_method' => 'pm_xxxxxxxxxxxxx', + 'description' => 'InboundTransfer from my bank account', + ] + ); + static::assertInstanceOf(\Stripe\Treasury\InboundTransfer::class, $result); } - public function testUpdateWebhookEndpoint() + public function testRetrieveInboundTransfer() { - $this->expectsRequest('post', '/v1/webhook_endpoints/we_xxxxxxxxxxxxx'); - $result = $this->client->webhookEndpoints->update( - 'we_xxxxxxxxxxxxx', - ['url' => 'https://example.com/new_endpoint'] + $this->expectsRequest( + 'get', + '/v1/treasury/inbound_transfers/ibt_xxxxxxxxxxxxx' ); - static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result); + $result = $this->client->treasury->inboundTransfers->retrieve( + 'ibt_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\InboundTransfer::class, $result); } - public function testListWebhookEndpoint() + public function testListInboundTransfer() { - $this->expectsRequest('get', '/v1/webhook_endpoints'); - $result = $this->client->webhookEndpoints->all(['limit' => 3]); + $this->expectsRequest('get', '/v1/treasury/inbound_transfers'); + $result = $this->client->treasury->inboundTransfers->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] + ); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Treasury\InboundTransfer::class, $result->data[0]); } - public function testDeleteWebhookEndpoint() + public function testCancelInboundTransfer() { - $this->expectsRequest('delete', '/v1/webhook_endpoints/we_xxxxxxxxxxxxx'); - $result = $this->client->webhookEndpoints->delete('we_xxxxxxxxxxxxx', []); - static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result); + $this->expectsRequest( + 'post', + '/v1/treasury/inbound_transfers/ibt_xxxxxxxxxxxxx/cancel' + ); + $result = $this->client->treasury->inboundTransfers->cancel( + 'ibt_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\InboundTransfer::class, $result); } - public function testExpireSession() + public function testRetrieveReceivedCredit() { - $this->expectsRequest('post', '/v1/checkout/sessions/sess_xyz/expire'); - $result = $this->client->checkout->sessions->expire('sess_xyz', []); - static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + $this->expectsRequest( + 'get', + '/v1/treasury/received_credits/rc_xxxxxxxxxxxxx' + ); + $result = $this->client->treasury->receivedCredits->retrieve( + 'rc_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\ReceivedCredit::class, $result); } - public function testCreateShippingRate() + public function testListReceivedCredit() { - $this->expectsRequest('post', '/v1/shipping_rates'); - $result = $this->client->shippingRates->create( - [ - 'display_name' => 'Sample Shipper', - 'fixed_amount' => ['currency' => 'usd', 'amount' => 400], - 'type' => 'fixed_amount', - ] + $this->expectsRequest('get', '/v1/treasury/received_credits'); + $result = $this->client->treasury->receivedCredits->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] ); - static::assertInstanceOf(\Stripe\ShippingRate::class, $result); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Treasury\ReceivedCredit::class, $result->data[0]); } - public function testListShippingRate() + public function testRetrieveReceivedDebit() { - $this->expectsRequest('get', '/v1/shipping_rates'); - $result = $this->client->shippingRates->all([]); - static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\ShippingRate::class, $result->data[0]); + $this->expectsRequest( + 'get', + '/v1/treasury/received_debits/rd_xxxxxxxxxxxxx' + ); + $result = $this->client->treasury->receivedDebits->retrieve( + 'rd_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\ReceivedDebit::class, $result); } - public function testCreateSession3() + public function testListReceivedDebit() { - $this->expectsRequest('post', '/v1/checkout/sessions'); - $result = $this->client->checkout->sessions->create( - [ - 'success_url' => 'https://example.com/success', - 'cancel_url' => 'https://example.com/cancel', - 'mode' => 'payment', - 'shipping_options' => [ - ['shipping_rate' => 'shr_standard'], - [ - 'shipping_rate_data' => [ - 'display_name' => 'Standard', - 'delivery_estimate' => [ - 'minimum' => ['unit' => 'day', 'value' => 5], - 'maximum' => ['unit' => 'day', 'value' => 7], - ], - ], - ], - ], - ] + $this->expectsRequest('get', '/v1/treasury/received_debits'); + $result = $this->client->treasury->receivedDebits->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] ); - static::assertInstanceOf(\Stripe\Checkout\Session::class, $result); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Treasury\ReceivedDebit::class, $result->data[0]); } - public function testCreatePaymentIntent2() + public function testCreateCreditReversal() { - $this->expectsRequest('post', '/v1/payment_intents'); - $result = $this->client->paymentIntents->create( - [ - 'amount' => 1099, - 'currency' => 'eur', - 'automatic_payment_methods' => ['enabled' => true], - ] + $this->expectsRequest('post', '/v1/treasury/credit_reversals'); + $result = $this->client->treasury->creditReversals->create( + ['received_credit' => 'rc_xxxxxxxxxxxxx'] ); - static::assertInstanceOf(\Stripe\PaymentIntent::class, $result); + static::assertInstanceOf(\Stripe\Treasury\CreditReversal::class, $result); } - public function testCreatePaymentLink() + public function testRetrieveCreditReversal() { - $this->expectsRequest('post', '/v1/payment_links'); - $result = $this->client->paymentLinks->create( - ['line_items' => [['price' => 'price_xxxxxxxxxxxxx', 'quantity' => 1]]] + $this->expectsRequest( + 'get', + '/v1/treasury/credit_reversals/credrev_xxxxxxxxxxxxx' ); - static::assertInstanceOf(\Stripe\PaymentLink::class, $result); + $result = $this->client->treasury->creditReversals->retrieve( + 'credrev_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Treasury\CreditReversal::class, $result); } - public function testListLineItemsPaymentLink() + public function testListCreditReversal() { - $this->expectsRequest('get', '/v1/payment_links/pl_xyz/line_items'); - $result = $this->client->paymentLinks->allLineItems('pl_xyz', []); + $this->expectsRequest('get', '/v1/treasury/credit_reversals'); + $result = $this->client->treasury->creditReversals->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] + ); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\LineItem::class, $result->data[0]); + static::assertInstanceOf(\Stripe\Treasury\CreditReversal::class, $result->data[0]); } - public function testRetrievePaymentLink() + public function testCreateDebitReversal() { - $this->expectsRequest('get', '/v1/payment_links/pl_xyz'); - $result = $this->client->paymentLinks->retrieve('pl_xyz', []); - static::assertInstanceOf(\Stripe\PaymentLink::class, $result); + $this->expectsRequest('post', '/v1/treasury/debit_reversals'); + $result = $this->client->treasury->debitReversals->create( + ['received_debit' => 'rd_xxxxxxxxxxxxx'] + ); + static::assertInstanceOf(\Stripe\Treasury\DebitReversal::class, $result); } - public function testVerifyMicrodepositsPaymentIntent() + public function testRetrieveDebitReversal() { $this->expectsRequest( - 'post', - '/v1/payment_intents/pi_xxxxxxxxxxxxx/verify_microdeposits' + 'get', + '/v1/treasury/debit_reversals/debrev_xxxxxxxxxxxxx' ); - $result = $this->client->paymentIntents->verifyMicrodeposits( - 'pi_xxxxxxxxxxxxx', + $result = $this->client->treasury->debitReversals->retrieve( + 'debrev_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\PaymentIntent::class, $result); + static::assertInstanceOf(\Stripe\Treasury\DebitReversal::class, $result); } - public function testVerifyMicrodepositsSetupIntent() + public function testListDebitReversal() { - $this->expectsRequest( - 'post', - '/v1/setup_intents/seti_xxxxxxxxxxxxx/verify_microdeposits' - ); - $result = $this->client->setupIntents->verifyMicrodeposits( - 'seti_xxxxxxxxxxxxx', - [] + $this->expectsRequest('get', '/v1/treasury/debit_reversals'); + $result = $this->client->treasury->debitReversals->all( + ['financial_account' => 'fa_xxxxxxxxxxxxx', 'limit' => 3] ); - static::assertInstanceOf(\Stripe\SetupIntent::class, $result); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Treasury\DebitReversal::class, $result->data[0]); } - public function testCreateTestClock() + public function testCreateSku() { - $this->expectsRequest('post', '/v1/test_helpers/test_clocks'); - $result = $this->client->testHelpers->testClocks->create( - ['frozen_time' => 123, 'name' => 'cogsworth'] + $this->expectsRequest('post', '/v1/skus'); + $result = $this->client->skus->create( + [ + 'attributes' => ['size' => 'Medium', 'gender' => 'Unisex'], + 'price' => 1500, + 'currency' => 'usd', + 'inventory' => ['type' => 'finite', 'quantity' => 500], + 'product' => 'prod_xxxxxxxxxxxxx', + ] ); - static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + static::assertInstanceOf(\Stripe\SKU::class, $result); } - public function testRetrieveTestClock() + public function testRetrieveSku() + { + $this->expectsRequest('get', '/v1/skus/sku_xxxxxxxxxxxxx'); + $result = $this->client->skus->retrieve('sku_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\SKU::class, $result); + } + + public function testUpdateSku() { - $this->expectsRequest('get', '/v1/test_helpers/test_clocks/clock_xyz'); - $result = $this->client->testHelpers->testClocks->retrieve('clock_xyz', []); - static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + $this->expectsRequest('post', '/v1/skus/sku_xxxxxxxxxxxxx'); + $result = $this->client->skus->update( + 'sku_xxxxxxxxxxxxx', + ['metadata' => ['order_id' => '6735']] + ); + static::assertInstanceOf(\Stripe\SKU::class, $result); } - public function testListTestClock() + public function testListSku() { - $this->expectsRequest('get', '/v1/test_helpers/test_clocks'); - $result = $this->client->testHelpers->testClocks->all([]); + $this->expectsRequest('get', '/v1/skus'); + $result = $this->client->skus->all(['limit' => 3]); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result->data[0]); + static::assertInstanceOf(\Stripe\SKU::class, $result->data[0]); } - public function testDeleteTestClock() + public function testDeleteSku() { - $this->expectsRequest('delete', '/v1/test_helpers/test_clocks/clock_xyz'); - $result = $this->client->testHelpers->testClocks->delete('clock_xyz', []); - static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + $this->expectsRequest('delete', '/v1/skus/sku_xxxxxxxxxxxxx'); + $result = $this->client->skus->delete('sku_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\SKU::class, $result); } - public function testAdvanceTestClock() + public function testRetrieveScheduledQueryRun() { $this->expectsRequest( - 'post', - '/v1/test_helpers/test_clocks/clock_xyz/advance' + 'get', + '/v1/sigma/scheduled_query_runs/sqr_xxxxxxxxxxxxx' ); - $result = $this->client->testHelpers->testClocks->advance( - 'clock_xyz', - ['frozen_time' => 142] + $result = $this->client->sigma->scheduledQueryRuns->retrieve( + 'sqr_xxxxxxxxxxxxx', + [] ); - static::assertInstanceOf(\Stripe\TestHelpers\TestClock::class, $result); + static::assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $result); } - public function testCreateFundingInstructionsCustomer() + public function testListScheduledQueryRun() { - $this->expectsRequest('post', '/v1/customers/cus_123/funding_instructions'); - $result = $this->client->customers->createFundingInstructions( - 'cus_123', + $this->expectsRequest('get', '/v1/sigma/scheduled_query_runs'); + $result = $this->client->sigma->scheduledQueryRuns->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Sigma\ScheduledQueryRun::class, $result->data[0]); + } + + public function testCreateReportRun() + { + $this->expectsRequest('post', '/v1/reporting/report_runs'); + $result = $this->client->reporting->reportRuns->create( [ - 'bank_transfer' => [ - 'requested_address_types' => ['zengin'], - 'type' => 'jp_bank_transfer', + 'report_type' => 'balance.summary.1', + 'parameters' => [ + 'interval_start' => 1522540800, + 'interval_end' => 1525132800, ], - 'currency' => 'usd', - 'funding_type' => 'bank_transfer', ] ); - static::assertInstanceOf(\Stripe\FundingInstructions::class, $result); + static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $result); } - public function testListConfiguration2() + public function testRetrieveReportRun() { - $this->expectsRequest('get', '/v1/terminal/configurations'); - $result = $this->client->terminal->configurations->all([]); - static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result->data[0]); + $this->expectsRequest('get', '/v1/reporting/report_runs/frr_xxxxxxxxxxxxx'); + $result = $this->client->reporting->reportRuns->retrieve( + 'frr_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $result); } - public function testRetrieveConfiguration2() + public function testListReportRun() { - $this->expectsRequest('get', '/v1/terminal/configurations/uc_123'); - $result = $this->client->terminal->configurations->retrieve('uc_123', []); - static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + $this->expectsRequest('get', '/v1/reporting/report_runs'); + $result = $this->client->reporting->reportRuns->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Reporting\ReportRun::class, $result->data[0]); } - public function testUpdateConfiguration2() + public function testRetrieveReportType() { - $this->expectsRequest('post', '/v1/terminal/configurations/uc_123'); - $result = $this->client->terminal->configurations->update( - 'uc_123', - ['tipping' => ['usd' => ['fixed_amounts' => [10]]]] + $this->expectsRequest( + 'get', + '/v1/reporting/report_types/balance.summary.1' ); - static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + $result = $this->client->reporting->reportTypes->retrieve( + 'balance.summary.1', + [] + ); + static::assertInstanceOf(\Stripe\Reporting\ReportType::class, $result); } - public function testDeleteConfiguration() + public function testListReportType() { - $this->expectsRequest('delete', '/v1/terminal/configurations/uc_123'); - $result = $this->client->terminal->configurations->delete('uc_123', []); - static::assertInstanceOf(\Stripe\Terminal\Configuration::class, $result); + $this->expectsRequest('get', '/v1/reporting/report_types'); + $result = $this->client->reporting->reportTypes->all([]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Reporting\ReportType::class, $result->data[0]); } - public function testExpireRefund() + public function testRetrieveAccount3() { - $this->expectsRequest('post', '/v1/test_helpers/refunds/re_123/expire'); - $result = $this->client->testHelpers->refunds->expire('re_123', []); - static::assertInstanceOf(\Stripe\Refund::class, $result); + $this->expectsRequest( + 'get', + '/v1/financial_connections/accounts/fca_xxxxxxxxxxxxx' + ); + $result = $this->client->financialConnections->accounts->retrieve( + 'fca_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result); } - public function testCreateOrder() + public function testListAccount3() { - $this->expectsRequest('post', '/v1/orders'); - $result = $this->client->orders->create( - [ - 'description' => 'description', - 'currency' => 'usd', - 'line_items' => [['description' => 'my line item']], - ] + $this->expectsRequest('get', '/v1/financial_connections/accounts'); + $result = $this->client->financialConnections->accounts->all( + ['account_holder' => ['customer' => 'cus_xxxxxxxxxxxxx']] ); - static::assertInstanceOf(\Stripe\Order::class, $result); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result->data[0]); } - public function testUpdateOrder() + public function testListOwnersAccount2() { - $this->expectsRequest('post', '/v1/orders/order_xyz'); - $result = $this->client->orders->update('order_xyz', []); - static::assertInstanceOf(\Stripe\Order::class, $result); + $this->expectsRequest( + 'get', + '/v1/financial_connections/accounts/fca_xxxxxxxxxxxxx/owners' + ); + $result = $this->client->financialConnections->accounts->allOwners( + 'fca_xxxxxxxxxxxxx', + ['limit' => 3, 'ownership' => 'fcaowns_xxxxxxxxxxxxx'] + ); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\FinancialConnections\AccountOwner::class, $result->data[0]); } - public function testListLineItemsOrder() + public function testCreateSession5() { - $this->expectsRequest('get', '/v1/orders/order_xyz/line_items'); - $result = $this->client->orders->allLineItems('order_xyz', []); - static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\LineItem::class, $result->data[0]); + $this->expectsRequest('post', '/v1/financial_connections/sessions'); + $result = $this->client->financialConnections->sessions->create( + [ + 'account_holder' => [ + 'type' => 'customer', + 'customer' => 'cus_xxxxxxxxxxxxx', + ], + 'permissions' => ['payment_method', 'balances'], + 'filters' => ['countries' => ['US']], + ] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Session::class, $result); } - public function testCancelOrder() + public function testRetrieveSession3() { - $this->expectsRequest('post', '/v1/orders/order_xyz/cancel'); - $result = $this->client->orders->cancel('order_xyz', []); - static::assertInstanceOf(\Stripe\Order::class, $result); + $this->expectsRequest( + 'get', + '/v1/financial_connections/sessions/fcsess_xxxxxxxxxxxxx' + ); + $result = $this->client->financialConnections->sessions->retrieve( + 'fcsess_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\FinancialConnections\Session::class, $result); } - public function testReopenOrder() + public function testRetrieveSource2() { - $this->expectsRequest('post', '/v1/orders/order_xyz/reopen'); - $result = $this->client->orders->reopen('order_xyz', []); - static::assertInstanceOf(\Stripe\Order::class, $result); + $this->expectsRequest('get', '/v1/sources/src_xxxxxxxxxxxxx'); + $result = $this->client->sources->retrieve('src_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\Source::class, $result); } - public function testSubmitOrder() + public function testCreateVerificationSession() { - $this->expectsRequest('post', '/v1/orders/order_xyz/submit'); - $result = $this->client->orders->submit( - 'order_xyz', - ['expected_total' => 100] + $this->expectsRequest('post', '/v1/identity/verification_sessions'); + $result = $this->client->identity->verificationSessions->create( + ['type' => 'document'] ); - static::assertInstanceOf(\Stripe\Order::class, $result); + static::assertInstanceOf(\Stripe\Identity\VerificationSession::class, $result); } - public function testUpdateOrder2() + public function testListVerificationSession() { - $this->expectsRequest('post', '/v1/orders/order_xyz'); - $result = $this->client->orders->update('order_xyz', []); - static::assertInstanceOf(\Stripe\Order::class, $result); + $this->expectsRequest('get', '/v1/identity/verification_sessions'); + $result = $this->client->identity->verificationSessions->all( + ['limit' => 3] + ); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Identity\VerificationSession::class, $result->data[0]); } - public function testRetrieveAccount2() + public function testRetrieveVerificationSession() { - $this->expectsRequest('get', '/v1/financial_connections/accounts/fca_xyz'); - $result = $this->client->financialConnections->accounts->retrieve( - 'fca_xyz', + $this->expectsRequest( + 'get', + '/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx' + ); + $result = $this->client->identity->verificationSessions->retrieve( + 'vs_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result); + static::assertInstanceOf(\Stripe\Identity\VerificationSession::class, $result); } - public function testRefreshAccount() + public function testUpdateVerificationSession() { $this->expectsRequest( 'post', - '/v1/financial_connections/accounts/fca_xyz/refresh' + '/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx' ); - $result = $this->client->financialConnections->accounts->refresh( - 'fca_xyz', - ['features' => ['balance']] + $result = $this->client->identity->verificationSessions->update( + 'vs_xxxxxxxxxxxxx', + ['type' => 'id_number'] ); - static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result); + static::assertInstanceOf(\Stripe\Identity\VerificationSession::class, $result); } - public function testDisconnectAccount() + public function testCancelVerificationSession() { $this->expectsRequest( 'post', - '/v1/financial_connections/accounts/fca_xyz/disconnect' + '/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx/cancel' ); - $result = $this->client->financialConnections->accounts->disconnect( - 'fca_xyz', + $result = $this->client->identity->verificationSessions->cancel( + 'vs_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\FinancialConnections\Account::class, $result); + static::assertInstanceOf(\Stripe\Identity\VerificationSession::class, $result); } - public function testCreateSession4() + public function testRedactVerificationSession() { - $this->expectsRequest('post', '/v1/financial_connections/sessions'); - $result = $this->client->financialConnections->sessions->create( - [ - 'account_holder' => ['type' => 'customer', 'customer' => 'cus_123'], - 'permissions' => ['balances'], - ] + $this->expectsRequest( + 'post', + '/v1/identity/verification_sessions/vs_xxxxxxxxxxxxx/redact' ); - static::assertInstanceOf(\Stripe\FinancialConnections\Session::class, $result); + $result = $this->client->identity->verificationSessions->redact( + 'vs_xxxxxxxxxxxxx', + [] + ); + static::assertInstanceOf(\Stripe\Identity\VerificationSession::class, $result); } - public function testRetrieveSession2() + public function testRetrieveVerificationReport() { $this->expectsRequest( 'get', - '/v1/financial_connections/sessions/fcsess_xyz' + '/v1/identity/verification_reports/vr_xxxxxxxxxxxxx' ); - $result = $this->client->financialConnections->sessions->retrieve( - 'fcsess_xyz', + $result = $this->client->identity->verificationReports->retrieve( + 'vr_xxxxxxxxxxxxx', [] ); - static::assertInstanceOf(\Stripe\FinancialConnections\Session::class, $result); + static::assertInstanceOf(\Stripe\Identity\VerificationReport::class, $result); + } + + public function testListVerificationReport() + { + $this->expectsRequest('get', '/v1/identity/verification_reports'); + $result = $this->client->identity->verificationReports->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Identity\VerificationReport::class, $result->data[0]); + } + + public function testRetrieveWebhookEndpoint() + { + $this->expectsRequest('get', '/v1/webhook_endpoints/we_xxxxxxxxxxxxx'); + $result = $this->client->webhookEndpoints->retrieve('we_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result); + } + + public function testUpdateWebhookEndpoint() + { + $this->expectsRequest('post', '/v1/webhook_endpoints/we_xxxxxxxxxxxxx'); + $result = $this->client->webhookEndpoints->update( + 'we_xxxxxxxxxxxxx', + ['url' => 'https://example.com/new_endpoint'] + ); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result); + } + + public function testListWebhookEndpoint() + { + $this->expectsRequest('get', '/v1/webhook_endpoints'); + $result = $this->client->webhookEndpoints->all(['limit' => 3]); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result->data[0]); + } + + public function testDeleteWebhookEndpoint() + { + $this->expectsRequest('delete', '/v1/webhook_endpoints/we_xxxxxxxxxxxxx'); + $result = $this->client->webhookEndpoints->delete('we_xxxxxxxxxxxxx', []); + static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result); } }