From e29cc511a253cf5c7002f0fd37a406aa0a9ee156 Mon Sep 17 00:00:00 2001 From: Dominic Charley-Roy <78050200+dcr-stripe@users.noreply.github.com> Date: Thu, 5 May 2022 09:23:13 -0400 Subject: [PATCH] API Updates (#1281) --- init.php | 7 ++ lib/FinancialConnections/Account.php | 84 +++++++++++++++++++ lib/FinancialConnections/AccountOwner.php | 20 +++++ lib/FinancialConnections/AccountOwnership.php | 18 ++++ lib/FinancialConnections/Session.php | 27 ++++++ lib/Service/CoreServiceFactory.php | 2 + .../FinancialConnections/AccountService.php | 58 +++++++++++++ .../FinancialConnectionsServiceFactory.php | 27 ++++++ .../FinancialConnections/SessionService.php | 41 +++++++++ lib/StripeClient.php | 1 + lib/Util/ObjectTypes.php | 4 + 11 files changed, 289 insertions(+) create mode 100644 lib/FinancialConnections/Account.php create mode 100644 lib/FinancialConnections/AccountOwner.php create mode 100644 lib/FinancialConnections/AccountOwnership.php create mode 100644 lib/FinancialConnections/Session.php create mode 100644 lib/Service/FinancialConnections/AccountService.php create mode 100644 lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php create mode 100644 lib/Service/FinancialConnections/SessionService.php diff --git a/init.php b/init.php index 91ab70998..e611aa5c6 100644 --- a/init.php +++ b/init.php @@ -108,6 +108,10 @@ require __DIR__ . '/lib/ExchangeRate.php'; require __DIR__ . '/lib/File.php'; require __DIR__ . '/lib/FileLink.php'; +require __DIR__ . '/lib/FinancialConnections/Account.php'; +require __DIR__ . '/lib/FinancialConnections/AccountOwner.php'; +require __DIR__ . '/lib/FinancialConnections/AccountOwnership.php'; +require __DIR__ . '/lib/FinancialConnections/Session.php'; require __DIR__ . '/lib/FundingInstructions.php'; require __DIR__ . '/lib/Identity/VerificationReport.php'; require __DIR__ . '/lib/Identity/VerificationSession.php'; @@ -194,6 +198,8 @@ require __DIR__ . '/lib/Service/ExchangeRateService.php'; require __DIR__ . '/lib/Service/FileService.php'; require __DIR__ . '/lib/Service/FileLinkService.php'; +require __DIR__ . '/lib/Service/FinancialConnections/AccountService.php'; +require __DIR__ . '/lib/Service/FinancialConnections/SessionService.php'; require __DIR__ . '/lib/Service/Identity/VerificationReportService.php'; require __DIR__ . '/lib/Service/Identity/VerificationSessionService.php'; require __DIR__ . '/lib/Service/InvoiceService.php'; @@ -249,6 +255,7 @@ require __DIR__ . '/lib/Service/BillingPortal/BillingPortalServiceFactory.php'; require __DIR__ . '/lib/Service/Checkout/CheckoutServiceFactory.php'; require __DIR__ . '/lib/Service/CoreServiceFactory.php'; +require __DIR__ . '/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php'; require __DIR__ . '/lib/Service/Identity/IdentityServiceFactory.php'; require __DIR__ . '/lib/Service/Issuing/IssuingServiceFactory.php'; require __DIR__ . '/lib/Service/Radar/RadarServiceFactory.php'; diff --git a/lib/FinancialConnections/Account.php b/lib/FinancialConnections/Account.php new file mode 100644 index 000000000..f24ef43d9 --- /dev/null +++ b/lib/FinancialConnections/Account.php @@ -0,0 +1,84 @@ +subcategory. + * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. + * @property null|string $display_name A human-readable name that has been assigned to this account, either by the account holder or by the institution. + * @property string $institution_name The name of the institution that holds this account. + * @property null|string $last4 The last 4 digits of the account number. If present, this will be 4 numeric characters. + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property null|string|\Stripe\FinancialConnections\AccountOwnership $ownership The most recent information about the account's owners. + * @property null|\Stripe\StripeObject $ownership_refresh The state of the most recent attempt to refresh the account owners. + * @property null|string[] $permissions The list of permissions granted by this account. + * @property string $status The status of the link to the account. + * @property string $subcategory

If category is cash, one of:

- checking - savings - other

If category is credit, one of:

- mortgage - line_of_credit - credit_card - other

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

+ * @property string[] $supported_payment_method_types The PaymentMethod type(s) that can be created from this account. + */ +class Account extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'financial_connections.account'; + + use \Stripe\ApiOperations\Retrieve; + + const CATEGORY_CASH = 'cash'; + const CATEGORY_CREDIT = 'credit'; + const CATEGORY_INVESTMENT = 'investment'; + const CATEGORY_OTHER = 'other'; + + const STATUS_ACTIVE = 'active'; + const STATUS_DISCONNECTED = 'disconnected'; + const STATUS_INACTIVE = 'inactive'; + + const SUBCATEGORY_CHECKING = 'checking'; + const SUBCATEGORY_CREDIT_CARD = 'credit_card'; + const SUBCATEGORY_LINE_OF_CREDIT = 'line_of_credit'; + const SUBCATEGORY_MORTGAGE = 'mortgage'; + const SUBCATEGORY_OTHER = 'other'; + const SUBCATEGORY_SAVINGS = 'savings'; + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\FinancialConnections\Account the disconnected account + */ + public function disconnect($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/disconnect'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\FinancialConnections\Account the refreshed account + */ + public function refresh($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/refresh'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } +} diff --git a/lib/FinancialConnections/AccountOwner.php b/lib/FinancialConnections/AccountOwner.php new file mode 100644 index 000000000..53a7f1a4c --- /dev/null +++ b/lib/FinancialConnections/AccountOwner.php @@ -0,0 +1,20 @@ + $owners A paginated list of owners for this account. + */ +class AccountOwnership extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'financial_connections.account_ownership'; +} diff --git a/lib/FinancialConnections/Session.php b/lib/FinancialConnections/Session.php new file mode 100644 index 000000000..8d55cd06e --- /dev/null +++ b/lib/FinancialConnections/Session.php @@ -0,0 +1,27 @@ + $accounts The accounts that were collected as part of this Session. + * @property string $client_secret A value that will be passed to the client to launch the authentication flow. + * @property \Stripe\StripeObject $filters + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property string[] $permissions Permissions requested for accounts collected during this session. + * @property string $return_url For webview integrations only. Upon completing OAuth login in the native browser, the user will be redirected to this URL to return to your app. + */ +class Session extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'financial_connections.session'; + + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; +} diff --git a/lib/Service/CoreServiceFactory.php b/lib/Service/CoreServiceFactory.php index 5157c2b68..76f82c3c3 100644 --- a/lib/Service/CoreServiceFactory.php +++ b/lib/Service/CoreServiceFactory.php @@ -26,6 +26,7 @@ * @property ExchangeRateService $exchangeRates * @property FileLinkService $fileLinks * @property FileService $files + * @property FinancialConnections\FinancialConnectionsServiceFactory $financialConnections * @property Identity\IdentityServiceFactory $identity * @property InvoiceItemService $invoiceItems * @property InvoiceService $invoices @@ -90,6 +91,7 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory 'exchangeRates' => ExchangeRateService::class, 'fileLinks' => FileLinkService::class, 'files' => FileService::class, + 'financialConnections' => FinancialConnections\FinancialConnectionsServiceFactory::class, 'identity' => Identity\IdentityServiceFactory::class, 'invoiceItems' => InvoiceItemService::class, 'invoices' => InvoiceService::class, diff --git a/lib/Service/FinancialConnections/AccountService.php b/lib/Service/FinancialConnections/AccountService.php new file mode 100644 index 000000000..1c96b1244 --- /dev/null +++ b/lib/Service/FinancialConnections/AccountService.php @@ -0,0 +1,58 @@ +Account. You will + * no longer be able to access data associated with the account (e.g. balances, + * transactions). + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\FinancialConnections\Account + */ + public function disconnect($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/financial_connections/accounts/%s/disconnect', $id), $params, $opts); + } + + /** + * Refreshes the data associated with a Financial Connections 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\FinancialConnections\Account + */ + public function refresh($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/financial_connections/accounts/%s/refresh', $id), $params, $opts); + } + + /** + * Retrieves the details of an Financial Connections 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\FinancialConnections\Account + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/financial_connections/accounts/%s', $id), $params, $opts); + } +} diff --git a/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php b/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php new file mode 100644 index 000000000..7dd826341 --- /dev/null +++ b/lib/Service/FinancialConnections/FinancialConnectionsServiceFactory.php @@ -0,0 +1,27 @@ + + */ + private static $classMap = [ + 'accounts' => AccountService::class, + 'sessions' => SessionService::class, + ]; + + protected function getServiceClass($name) + { + return \array_key_exists($name, self::$classMap) ? self::$classMap[$name] : null; + } +} diff --git a/lib/Service/FinancialConnections/SessionService.php b/lib/Service/FinancialConnections/SessionService.php new file mode 100644 index 000000000..eab589cda --- /dev/null +++ b/lib/Service/FinancialConnections/SessionService.php @@ -0,0 +1,41 @@ +Session. The session’s client_secret can be used to + * launch the flow using Stripe.js. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\FinancialConnections\Session + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/financial_connections/sessions', $params, $opts); + } + + /** + * Retrieves the details of a Financial Connections Session. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\FinancialConnections\Session + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/financial_connections/sessions/%s', $id), $params, $opts); + } +} diff --git a/lib/StripeClient.php b/lib/StripeClient.php index 89dedad2e..27c58cac4 100644 --- a/lib/StripeClient.php +++ b/lib/StripeClient.php @@ -26,6 +26,7 @@ * @property \Stripe\Service\ExchangeRateService $exchangeRates * @property \Stripe\Service\FileLinkService $fileLinks * @property \Stripe\Service\FileService $files + * @property \Stripe\Service\FinancialConnections\FinancialConnectionsServiceFactory $financialConnections * @property \Stripe\Service\Identity\IdentityServiceFactory $identity * @property \Stripe\Service\InvoiceItemService $invoiceItems * @property \Stripe\Service\InvoiceService $invoices diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php index b3b8400d9..715c5bd85 100644 --- a/lib/Util/ObjectTypes.php +++ b/lib/Util/ObjectTypes.php @@ -43,6 +43,10 @@ class ObjectTypes \Stripe\File::OBJECT_NAME => \Stripe\File::class, \Stripe\File::OBJECT_NAME_ALT => \Stripe\File::class, \Stripe\FileLink::OBJECT_NAME => \Stripe\FileLink::class, + \Stripe\FinancialConnections\Account::OBJECT_NAME => \Stripe\FinancialConnections\Account::class, + \Stripe\FinancialConnections\AccountOwner::OBJECT_NAME => \Stripe\FinancialConnections\AccountOwner::class, + \Stripe\FinancialConnections\AccountOwnership::OBJECT_NAME => \Stripe\FinancialConnections\AccountOwnership::class, + \Stripe\FinancialConnections\Session::OBJECT_NAME => \Stripe\FinancialConnections\Session::class, \Stripe\FundingInstructions::OBJECT_NAME => \Stripe\FundingInstructions::class, \Stripe\Identity\VerificationReport::OBJECT_NAME => \Stripe\Identity\VerificationReport::class, \Stripe\Identity\VerificationSession::OBJECT_NAME => \Stripe\Identity\VerificationSession::class,