Skip to content

Commit

Permalink
Merge pull request #1354 from stripe/latest-codegen-beta
Browse files Browse the repository at this point in the history
API Updates for beta branch
  • Loading branch information
pakrym-stripe authored Aug 23, 2022
2 parents 97b48a5 + 16e8e72 commit 8440546
Show file tree
Hide file tree
Showing 21 changed files with 199 additions and 17 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v178
v184
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
30 changes: 30 additions & 0 deletions lib/AccountSession.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe;

/**
* An AccountSession allows a Connect platform to grant access to a connected
* account in Connect Elements.
*
* We recommend that you create an AccountSession each time you need to display an
* embedded UI to your user. Do not save AccountSessions to your database as they
* expire relatively quickly, and cannot be used more than once.
*
* Related guide: <a
* href="https://stripe.com/docs/connect/get-started-connect-elements">Connect
* Elements</a>.
*
* @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 <p>The client secret of this AccountSession. Used on the client to set up secure access to the given <code>account</code>.</p><p>The client secret can be used to provide access to <code>account</code> 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.</p><p>Refer to our docs to <a href="https://stripe.com/docs/connect/get-started-connect-elements">setup Connect Elements</a> and learn about how <code>client_secret</code> should be handled.</p>
* @property int $expires_at The timestamp at which this AccountSession will expire.
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
*/
class AccountSession extends ApiResource
{
const OBJECT_NAME = 'account_session';

use ApiOperations\Create;
}
4 changes: 2 additions & 2 deletions lib/Checkout/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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: <a href="https://stripe.com/docs/payments/checkout/api">Checkout
* Server Quickstart</a>.
* Related guide: <a href="https://stripe.com/docs/checkout/quickstart">Checkout
* Quickstart</a>.
*
* @property string $id Unique identifier for the object. Used to pass to <code>redirectToCheckout</code> in Stripe.js.
* @property string $object String representing the object's type. Objects of the same type share the same value.
Expand Down
30 changes: 30 additions & 0 deletions lib/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down
41 changes: 41 additions & 0 deletions lib/CustomerCashBalanceTransaction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe;

/**
* Customers with certain payments enabled have a cash balance, representing funds
* that were paid by the customer to a merchant, but have not yet been allocated to
* a payment. Cash Balance Transactions represent when funds are moved into or out
* of this balance. This includes funding by the customer, allocation to payments,
* and refunds to the customer.
*
* @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 $applied_to_payment
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
* @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 <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>.
* @property \Stripe\StripeObject $funded
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property int $net_amount The amount by which the cash balance changed, represented in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>. 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 <code>applied_to_payment</code>, <code>unapplied_from_payment</code>, <code>refunded_from_payment</code>, <code>funded</code>, <code>return_initiated</code>, or <code>return_canceled</code>. New types may be added in future. See <a href="https://stripe.com/docs/payments/customer-balance#types">Customer Balance</a> 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';
}
1 change: 1 addition & 0 deletions lib/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/Identity/VerificationSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* A VerificationSession transitions through <a
* href="/docs/identity/how-sessions-work">multiple statuses</a> throughout its
* lifetime as it progresses through the verification flow. The VerificationSession
* contains the users verified data after verification checks are complete.
* contains the user's verified data after verification checks are complete.
*
* Related guide: <a
* href="https://stripe.com/docs/identity/verification-sessions">The Verification
Expand Down
1 change: 1 addition & 0 deletions lib/PaymentLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
* @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 <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
Expand Down
24 changes: 24 additions & 0 deletions lib/Service/AccountSessionService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\Service;

class AccountSessionService extends \Stripe\Service\AbstractService
{
/**
* Creates a AccountSession object that includes a single-use token that the
* platform can use on their front-end to grant client-side API access.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\AccountSession
*/
public function create($params = null, $opts = null)
{
return $this->request('post', '/v1/account_sessions', $params, $opts);
}
}
2 changes: 2 additions & 0 deletions lib/Service/CoreServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* @property AccountLinkService $accountLinks
* @property AccountService $accounts
* @property AccountSessionService $accountSessions
* @property ApplePayDomainService $applePayDomains
* @property ApplicationFeeService $applicationFees
* @property Apps\AppsServiceFactory $apps
Expand Down Expand Up @@ -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,
Expand Down
35 changes: 35 additions & 0 deletions lib/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a
* href="/docs/payments/customer-balance">cash balance</a>.
*
* @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.
*
Expand Down Expand Up @@ -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 <a
* href="/docs/payments/customer-balance">cash balance</a>.
*
* @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.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions lib/StripeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/Topup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> 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 <p><code>Source</code> 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 <code>Card</code> object: once chargeable, they can be charged, or can be attached to customers.</p><p>Related guides: <a href="https://stripe.com/docs/sources">Sources API</a> and <a href="https://stripe.com/docs/sources/customers">Sources &amp; Customers</a>.</p>
* @property null|\Stripe\Source $source For most Stripe users, the source of every top-up is a bank account. This hash is then the <a href="https://stripe.com/docs/api#source_object">source object</a> 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 <code>canceled</code>, <code>failed</code>, <code>pending</code>, <code>reversed</code>, or <code>succeeded</code>.
* @property null|string $transfer_group A string that identifies this top-up as part of a group.
Expand Down
2 changes: 1 addition & 1 deletion lib/Treasury/OutboundTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
* @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.
Expand Down
2 changes: 1 addition & 1 deletion lib/Util/ApiVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
2 changes: 2 additions & 0 deletions lib/Util/ObjectTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 8440546

Please sign in to comment.