From 9f872169705c06f5fe2b668ee31d75d520734ee0 Mon Sep 17 00:00:00 2001 From: Kamil Pajdzik Date: Thu, 18 Aug 2022 16:02:20 -0700 Subject: [PATCH] Codegen for openapi v183 --- OPENAPI_VERSION | 2 +- init.php | 1 + lib/Checkout/Session.php | 4 +-- lib/Customer.php | 30 +++++++++++++++++++ lib/CustomerCashBalanceTransaction.php | 41 ++++++++++++++++++++++++++ lib/Event.php | 1 + lib/Identity/VerificationSession.php | 2 +- lib/PaymentLink.php | 1 + lib/Service/CustomerService.php | 35 ++++++++++++++++++++++ lib/Topup.php | 2 +- lib/Util/ObjectTypes.php | 1 + tests/Stripe/GeneratedExamplesTest.php | 16 +++++----- 12 files changed, 123 insertions(+), 13 deletions(-) create mode 100644 lib/CustomerCashBalanceTransaction.php diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index fe5aa3c01..d9f3b7218 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v178 \ No newline at end of file +v183 \ No newline at end of file diff --git a/init.php b/init.php index b869746a5..39adb4c21 100644 --- a/init.php +++ b/init.php @@ -100,6 +100,7 @@ require __DIR__ . '/lib/CreditNoteLineItem.php'; require __DIR__ . '/lib/Customer.php'; require __DIR__ . '/lib/CustomerBalanceTransaction.php'; +require __DIR__ . '/lib/CustomerCashBalanceTransaction.php'; require __DIR__ . '/lib/Discount.php'; require __DIR__ . '/lib/Dispute.php'; require __DIR__ . '/lib/EphemeralKey.php'; diff --git a/lib/Checkout/Session.php b/lib/Checkout/Session.php index 03ddc71c5..e7f09df60 100644 --- a/lib/Checkout/Session.php +++ b/lib/Checkout/Session.php @@ -20,8 +20,8 @@ * You can create a Checkout Session on your server and pass its ID to the client * to begin Checkout. * - * Related guide: Checkout - * Server Quickstart. + * Related guide: Checkout + * Quickstart. * * @property string $id Unique identifier for the object. Used to pass to redirectToCheckout in Stripe.js. * @property string $object String representing the object's type. Objects of the same type share the same value. diff --git a/lib/Customer.php b/lib/Customer.php index efbf083fd..db1148c3b 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -227,6 +227,36 @@ public static function updateBalanceTransaction($id, $balanceTransactionId, $par { return self::_updateNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts); } + const PATH_CASH_BALANCE_TRANSACTIONS = '/cash_balance_transactions'; + + /** + * @param string $id the ID of the customer on which to retrieve the customer cash balance transactions + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\CustomerCashBalanceTransaction> the list of customer cash balance transactions + */ + public static function allCashBalanceTransactions($id, $params = null, $opts = null) + { + return self::_allNestedResources($id, static::PATH_CASH_BALANCE_TRANSACTIONS, $params, $opts); + } + + /** + * @param string $id the ID of the customer to which the customer cash balance transaction belongs + * @param string $cashBalanceTransactionId the ID of the customer cash balance transaction to retrieve + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\CustomerCashBalanceTransaction + */ + public static function retrieveCashBalanceTransaction($id, $cashBalanceTransactionId, $params = null, $opts = null) + { + return self::_retrieveNestedResource($id, static::PATH_CASH_BALANCE_TRANSACTIONS, $cashBalanceTransactionId, $params, $opts); + } const PATH_SOURCES = '/sources'; /** diff --git a/lib/CustomerCashBalanceTransaction.php b/lib/CustomerCashBalanceTransaction.php new file mode 100644 index 000000000..143875a4f --- /dev/null +++ b/lib/CustomerCashBalanceTransaction.php @@ -0,0 +1,41 @@ +ISO currency code, in lowercase. Must be a supported currency. + * @property string|\Stripe\Customer $customer The customer whose available cash balance changed as a result of this transaction. + * @property int $ending_balance The total available cash balance for the specified currency after this transaction was applied. Represented in the smallest currency unit. + * @property \Stripe\StripeObject $funded + * @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 int $net_amount The amount by which the cash balance changed, represented in the smallest currency unit. A positive value represents funds being added to the cash balance, a negative value represents funds being removed from the cash balance. + * @property \Stripe\StripeObject $refunded_from_payment + * @property string $type The type of the cash balance transaction. One of applied_to_payment, unapplied_from_payment, refunded_from_payment, funded, return_initiated, or return_canceled. New types may be added in future. See Customer Balance to learn more about these types. + * @property \Stripe\StripeObject $unapplied_from_payment + */ +class CustomerCashBalanceTransaction extends ApiResource +{ + const OBJECT_NAME = 'customer_cash_balance_transaction'; + + use ApiOperations\All; + use ApiOperations\Retrieve; + + const TYPE_APPLIED_TO_PAYMENT = 'applied_to_payment'; + const TYPE_FUNDED = 'funded'; + const TYPE_REFUNDED_FROM_PAYMENT = 'refunded_from_payment'; + const TYPE_RETURN_CANCELED = 'return_canceled'; + const TYPE_RETURN_INITIATED = 'return_initiated'; + const TYPE_UNAPPLIED_FROM_PAYMENT = 'unapplied_from_payment'; +} diff --git a/lib/Event.php b/lib/Event.php index 507d3f53c..c934ec2c3 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -117,6 +117,7 @@ class Event extends ApiResource const CUSTOMER_TAX_ID_DELETED = 'customer.tax_id.deleted'; const CUSTOMER_TAX_ID_UPDATED = 'customer.tax_id.updated'; const CUSTOMER_UPDATED = 'customer.updated'; + const CUSTOMER_CASH_BALANCE_TRANSACTION_CREATED = 'customer_cash_balance_transaction.created'; const FILE_CREATED = 'file.created'; const FINANCIAL_CONNECTIONS_ACCOUNT_CREATED = 'financial_connections.account.created'; const FINANCIAL_CONNECTIONS_ACCOUNT_DEACTIVATED = 'financial_connections.account.deactivated'; diff --git a/lib/Identity/VerificationSession.php b/lib/Identity/VerificationSession.php index 501939976..180e5091e 100644 --- a/lib/Identity/VerificationSession.php +++ b/lib/Identity/VerificationSession.php @@ -14,7 +14,7 @@ * A VerificationSession transitions through multiple statuses throughout its * lifetime as it progresses through the verification flow. The VerificationSession - * contains the user’s verified data after verification checks are complete. + * contains the user's verified data after verification checks are complete. * * Related guide: The Verification diff --git a/lib/PaymentLink.php b/lib/PaymentLink.php index 9de3e91b6..d2fc6df63 100644 --- a/lib/PaymentLink.php +++ b/lib/PaymentLink.php @@ -27,6 +27,7 @@ * @property \Stripe\StripeObject $automatic_tax * @property string $billing_address_collection Configuration for collecting the customer's billing address. * @property null|\Stripe\StripeObject $consent_collection When set, provides configuration to gather active consent from customers. + * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. * @property string $customer_creation Configuration for Customer creation during checkout. * @property \Stripe\Collection<\Stripe\LineItem> $line_items The line items representing what is being sold. * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. diff --git a/lib/Service/CustomerService.php b/lib/Service/CustomerService.php index 5735f32cf..5cb7910a2 100644 --- a/lib/Service/CustomerService.php +++ b/lib/Service/CustomerService.php @@ -39,6 +39,23 @@ public function allBalanceTransactions($parentId, $params = null, $opts = null) return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/balance_transactions', $parentId), $params, $opts); } + /** + * Returns a list of transactions that modified the customer’s cash balance. + * + * @param string $parentId + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\CustomerCashBalanceTransaction> + */ + public function allCashBalanceTransactions($parentId, $params = null, $opts = null) + { + return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/cash_balance_transactions', $parentId), $params, $opts); + } + /** * Returns a list of PaymentMethods for a given Customer. * @@ -292,6 +309,24 @@ public function retrieveCashBalance($parentId, $params = null, $opts = null) return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance', $parentId), $params, $opts); } + /** + * Retrieves a specific cash balance transaction, which updated the customer’s cash balance. + * + * @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\CustomerCashBalanceTransaction + */ + public function retrieveCashBalanceTransaction($parentId, $id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/customers/%s/cash_balance_transactions/%s', $parentId, $id), $params, $opts); + } + /** * Retrieves a PaymentMethod object for a given Customer. * diff --git a/lib/Topup.php b/lib/Topup.php index 69cdd689b..a0ea053cd 100644 --- a/lib/Topup.php +++ b/lib/Topup.php @@ -24,7 +24,7 @@ * @property null|string $failure_message Message to user further explaining reason for top-up failure if available. * @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 \Stripe\Source $source

Source objects allow you to accept a variety of payment methods. They represent a customer's payment instrument, and can be used with the Stripe API just like a Card object: once chargeable, they can be charged, or can be attached to customers.

Related guides: Sources API and Sources & Customers.

+ * @property null|\Stripe\Source $source For most Stripe users, the source of every top-up is a bank account. This hash is then the source object describing that bank account. * @property null|string $statement_descriptor Extra information about a top-up. This will appear on your source's bank statement. It must contain at least one letter. * @property string $status The status of the top-up is either canceled, failed, pending, reversed, or succeeded. * @property null|string $transfer_group A string that identifies this top-up as part of a group. diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php index b0b8f1e3e..a94b58291 100644 --- a/lib/Util/ObjectTypes.php +++ b/lib/Util/ObjectTypes.php @@ -33,6 +33,7 @@ class ObjectTypes \Stripe\CreditNoteLineItem::OBJECT_NAME => \Stripe\CreditNoteLineItem::class, \Stripe\Customer::OBJECT_NAME => \Stripe\Customer::class, \Stripe\CustomerBalanceTransaction::OBJECT_NAME => \Stripe\CustomerBalanceTransaction::class, + \Stripe\CustomerCashBalanceTransaction::OBJECT_NAME => \Stripe\CustomerCashBalanceTransaction::class, \Stripe\Discount::OBJECT_NAME => \Stripe\Discount::class, \Stripe\Dispute::OBJECT_NAME => \Stripe\Dispute::class, \Stripe\EphemeralKey::OBJECT_NAME => \Stripe\EphemeralKey::class, diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index d457906fb..206a87c18 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -1005,7 +1005,7 @@ public function testSearchCharge() $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":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Charge","namespaces":[]},"hasSearchResultType":true} } public function testListSession() @@ -1337,7 +1337,7 @@ public function testSearchCustomer() $result = $this->client->customers->search( ['query' => 'name:\'fakename\' AND metadata[\'foo\']:\'bar\''] ); - // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]},"hasSearchResultType":true} } public function testSearchCustomer2() @@ -1346,7 +1346,7 @@ public function testSearchCustomer2() $result = $this->client->customers->search( ['query' => 'name:\'fakename\' AND metadata[\'foo\']:\'bar\''] ); - // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Customer","namespaces":[]},"hasSearchResultType":true} } public function testListDispute() @@ -1732,7 +1732,7 @@ public function testSearchInvoice() $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":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Invoice","namespaces":[]},"hasSearchResultType":true} } public function testListAuthorization() @@ -2065,7 +2065,7 @@ public function testSearchPaymentIntent() $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":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"PaymentIntent","namespaces":[]},"hasSearchResultType":true} } public function testListPaymentLink() @@ -2308,7 +2308,7 @@ public function testSearchPrice() $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":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Price","namespaces":[]},"hasSearchResultType":true} } public function testListProduct() @@ -2356,7 +2356,7 @@ public function testSearchProduct() $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":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Product","namespaces":[]},"hasSearchResultType":true} } public function testListPromotionCode() @@ -3074,7 +3074,7 @@ public function testSearchSubscription() $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":[]}} + // TODO: assert proper instance, {"shape":"searchResultObject","type":{"shape":"ref","ref":"Subscription","namespaces":[]},"hasSearchResultType":true} } public function testListTaxCode()