diff --git a/CHANGELOG.md b/CHANGELOG.md index 797e00cf3..38c6b991e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 9.2.0 - 2022-08-19 +* [#1352](https://github.com/stripe/stripe-php/pull/1352) API Updates + * Add support for new resource `CustomerCashBalanceTransaction` + * Add support for `currency` on `PaymentLink` + * Add constant for `customer_cash_balance_transaction.created` webhook event. +* [#1351](https://github.com/stripe/stripe-php/pull/1351) Add a support section to the readme +* [#1304](https://github.com/stripe/stripe-php/pull/1304) Allow passing PSR-3 loggers to setLogger as they are compatible + ## 9.2.0-beta.1 - 2022-08-11 * [#1349](https://github.com/stripe/stripe-php/pull/1349) API Updates for beta branch - Updated stable APIs to the latest version diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index fe5aa3c01..c13f8f959 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v178 \ No newline at end of file +v184 \ No newline at end of file diff --git a/README.md b/README.md index 41c202164..f7b9192b3 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Stripe API. +## Support + +New features and bug fixes are released on the latest major version of the Stripe PHP library. If you are on an older major version, we recommend that you upgrade to the latest in order to use the new features and bug fixes including those for security vulnerabilities. Older major versions of the package will continue to be available for use, but will not be receiving any updates. + ## Requirements PHP 5.6.0 and later. diff --git a/init.php b/init.php index 214d7b4ce..c077152ba 100644 --- a/init.php +++ b/init.php @@ -79,6 +79,7 @@ // Stripe API Resources require __DIR__ . '/lib/Account.php'; require __DIR__ . '/lib/AccountLink.php'; +require __DIR__ . '/lib/AccountSession.php'; require __DIR__ . '/lib/ApplePayDomain.php'; require __DIR__ . '/lib/ApplicationFee.php'; require __DIR__ . '/lib/ApplicationFeeRefund.php'; @@ -100,6 +101,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'; @@ -187,6 +189,7 @@ // Services require __DIR__ . '/lib/Service/AccountService.php'; require __DIR__ . '/lib/Service/AccountLinkService.php'; +require __DIR__ . '/lib/Service/AccountSessionService.php'; require __DIR__ . '/lib/Service/ApplePayDomainService.php'; require __DIR__ . '/lib/Service/ApplicationFeeService.php'; require __DIR__ . '/lib/Service/Apps/SecretService.php'; diff --git a/lib/AccountSession.php b/lib/AccountSession.php new file mode 100644 index 000000000..ab1936d57 --- /dev/null +++ b/lib/AccountSession.php @@ -0,0 +1,30 @@ +Connect + * Elements. + * + * @property string $object String representing the object's type. Objects of the same type share the same value. + * @property string $account The ID of the account the AccountSession was created for + * @property string $client_secret
The client secret of this AccountSession. Used on the client to set up secure access to the given account
.
The client secret can be used to provide access to account
from your frontend. It should not be stored, logged, or exposed to anyone other than the connected account. Make sure that you have TLS enabled on any page that includes the client secret.
Refer to our docs to setup Connect Elements and learn about how client_secret
should be handled.
true
if the object exists in live mode or the value false
if the object exists in test mode.
+ */
+class AccountSession extends ApiResource
+{
+ const OBJECT_NAME = 'account_session';
+
+ use ApiOperations\Create;
+}
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/AccountSessionService.php b/lib/Service/AccountSessionService.php
new file mode 100644
index 000000000..e7d8a1f9f
--- /dev/null
+++ b/lib/Service/AccountSessionService.php
@@ -0,0 +1,24 @@
+request('post', '/v1/account_sessions', $params, $opts);
+ }
+}
diff --git a/lib/Service/CoreServiceFactory.php b/lib/Service/CoreServiceFactory.php
index dd9f0a66c..193c02e41 100644
--- a/lib/Service/CoreServiceFactory.php
+++ b/lib/Service/CoreServiceFactory.php
@@ -9,6 +9,7 @@
*
* @property AccountLinkService $accountLinks
* @property AccountService $accounts
+ * @property AccountSessionService $accountSessions
* @property ApplePayDomainService $applePayDomains
* @property ApplicationFeeService $applicationFees
* @property Apps\AppsServiceFactory $apps
@@ -76,6 +77,7 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory
private static $classMap = [
'accountLinks' => AccountLinkService::class,
'accounts' => AccountService::class,
+ 'accountSessions' => AccountSessionService::class,
'applePayDomains' => ApplePayDomainService::class,
'applicationFees' => ApplicationFeeService::class,
'apps' => Apps\AppsServiceFactory::class,
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/Stripe.php b/lib/Stripe.php
index d969c5a61..df6cf1e16 100644
--- a/lib/Stripe.php
+++ b/lib/Stripe.php
@@ -90,7 +90,7 @@ public static function getLogger()
}
/**
- * @param Util\LoggerInterface $logger the logger to which the library
+ * @param \Psr\Log\LoggerInterface|Util\LoggerInterface $logger the logger to which the library
* will produce messages
*/
public static function setLogger($logger)
diff --git a/lib/StripeClient.php b/lib/StripeClient.php
index bc0fcd613..3c5b7d1b0 100644
--- a/lib/StripeClient.php
+++ b/lib/StripeClient.php
@@ -8,6 +8,7 @@
* Client used to send requests to Stripe's API.
*
* @property \Stripe\Service\AccountLinkService $accountLinks
+ * @property \Stripe\Service\AccountSessionService $accountSessions
* @property \Stripe\Service\AccountService $accounts
* @property \Stripe\Service\ApplePayDomainService $applePayDomains
* @property \Stripe\Service\ApplicationFeeService $applicationFees
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 eithercanceled
, 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/Treasury/OutboundTransfer.php b/lib/Treasury/OutboundTransfer.php
index f78c8653f..66e0ce1d8 100644
--- a/lib/Treasury/OutboundTransfer.php
+++ b/lib/Treasury/OutboundTransfer.php
@@ -23,7 +23,7 @@
* @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 null|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.
diff --git a/lib/Util/ApiVersion.php b/lib/Util/ApiVersion.php
index 99099de23..7cd0170ae 100644
--- a/lib/Util/ApiVersion.php
+++ b/lib/Util/ApiVersion.php
@@ -6,5 +6,5 @@
class ApiVersion
{
- const CURRENT = '2022-08-01; server_side_confirmation_beta=v1; orders_beta=v4; terminal_interac_refunds_beta=v1';
+ const CURRENT = '2022-08-01';
}
diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php
index ca1318b5a..2a70a1364 100644
--- a/lib/Util/ObjectTypes.php
+++ b/lib/Util/ObjectTypes.php
@@ -12,6 +12,7 @@ class ObjectTypes
const mapping = [
\Stripe\Account::OBJECT_NAME => \Stripe\Account::class,
\Stripe\AccountLink::OBJECT_NAME => \Stripe\AccountLink::class,
+ \Stripe\AccountSession::OBJECT_NAME => \Stripe\AccountSession::class,
\Stripe\ApplePayDomain::OBJECT_NAME => \Stripe\ApplePayDomain::class,
\Stripe\ApplicationFee::OBJECT_NAME => \Stripe\ApplicationFee::class,
\Stripe\ApplicationFeeRefund::OBJECT_NAME => \Stripe\ApplicationFeeRefund::class,
@@ -33,6 +34,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 cd78e002c..e55400caa 100644
--- a/tests/Stripe/GeneratedExamplesTest.php
+++ b/tests/Stripe/GeneratedExamplesTest.php
@@ -444,7 +444,7 @@ public function testFundCashBalanceCustomer()
'cus_123',
['amount' => 30, 'currency' => 'eur']
);
- static::assertInstanceOf(\Stripe\CustomerBalanceTransaction::class, $result);
+ static::assertInstanceOf(\Stripe\CustomerCashBalanceTransaction::class, $result);
}
public function testDeliverCardCard()
@@ -1067,7 +1067,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()
@@ -1399,7 +1399,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()
@@ -1408,7 +1408,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()
@@ -1794,7 +1794,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()
@@ -2135,7 +2135,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()
@@ -2378,7 +2378,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()
@@ -2426,7 +2426,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()
@@ -3144,7 +3144,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()