This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

524
vendor/stripe/stripe-php/lib/Account.php vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,45 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* Account Links are the means by which a Connect platform grants a connected account permission to access
* Stripe-hosted applications, such as Connect Onboarding.
*
* Related guide: <a href="https://stripe.com/docs/connect/custom/hosted-onboarding">Connect Onboarding</a>
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property int $expires_at The timestamp at which this account link will expire.
* @property string $url The URL for the account link.
*/
class AccountLink extends ApiResource
{
const OBJECT_NAME = 'account_link';
/**
* Creates an AccountLink object that includes a single-use Stripe URL that the
* platform can redirect their user to in order to take them through the Connect
* Onboarding flow.
*
* @param null|array{account: string, collect?: string, collection_options?: array{fields?: string, future_requirements?: string}, expand?: string[], refresh_url?: string, return_url?: string, type: string} $params
* @param null|array|string $options
*
* @return AccountLink the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,49 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* An AccountSession allows a Connect platform to grant access to a connected account in Connect embedded components.
*
* We recommend that you create an AccountSession each time you need to display an embedded component
* 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-embedded-components">Connect embedded components</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-embedded-components">setup Connect embedded components</a> and learn about how <code>client_secret</code> should be handled.</p>
* @property (object{account_management: (object{enabled: bool, features: (object{disable_stripe_user_authentication: bool, external_account_collection: bool}&StripeObject)}&StripeObject), account_onboarding: (object{enabled: bool, features: (object{disable_stripe_user_authentication: bool, external_account_collection: bool}&StripeObject)}&StripeObject), balances: (object{enabled: bool, features: (object{disable_stripe_user_authentication: bool, edit_payout_schedule: bool, external_account_collection: bool, instant_payouts: bool, standard_payouts: bool}&StripeObject)}&StripeObject), disputes_list: (object{enabled: bool, features: (object{capture_payments: bool, destination_on_behalf_of_charge_management: bool, dispute_management: bool, refund_management: bool}&StripeObject)}&StripeObject), documents: (object{enabled: bool, features: (object{}&StripeObject)}&StripeObject), financial_account: (object{enabled: bool, features: (object{disable_stripe_user_authentication: bool, external_account_collection: bool, send_money: bool, transfer_balance: bool}&StripeObject)}&StripeObject), financial_account_transactions: (object{enabled: bool, features: (object{card_spend_dispute_management: bool}&StripeObject)}&StripeObject), issuing_card: (object{enabled: bool, features: (object{card_management: bool, card_spend_dispute_management: bool, cardholder_management: bool, spend_control_management: bool}&StripeObject)}&StripeObject), issuing_cards_list: (object{enabled: bool, features: (object{card_management: bool, card_spend_dispute_management: bool, cardholder_management: bool, disable_stripe_user_authentication: bool, spend_control_management: bool}&StripeObject)}&StripeObject), notification_banner: (object{enabled: bool, features: (object{disable_stripe_user_authentication: bool, external_account_collection: bool}&StripeObject)}&StripeObject), payment_details: (object{enabled: bool, features: (object{capture_payments: bool, destination_on_behalf_of_charge_management: bool, dispute_management: bool, refund_management: bool}&StripeObject)}&StripeObject), payment_disputes: (object{enabled: bool, features: (object{destination_on_behalf_of_charge_management: bool, dispute_management: bool, refund_management: bool}&StripeObject)}&StripeObject), payments: (object{enabled: bool, features: (object{capture_payments: bool, destination_on_behalf_of_charge_management: bool, dispute_management: bool, refund_management: bool}&StripeObject)}&StripeObject), payouts: (object{enabled: bool, features: (object{disable_stripe_user_authentication: bool, edit_payout_schedule: bool, external_account_collection: bool, instant_payouts: bool, standard_payouts: bool}&StripeObject)}&StripeObject), payouts_list: (object{enabled: bool, features: (object{}&StripeObject)}&StripeObject), tax_registrations: (object{enabled: bool, features: (object{}&StripeObject)}&StripeObject), tax_settings: (object{enabled: bool, features: (object{}&StripeObject)}&StripeObject)}&StripeObject) $components
* @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';
/**
* 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{account: string, components: array{account_management?: array{enabled: bool, features?: array{disable_stripe_user_authentication?: bool, external_account_collection?: bool}}, account_onboarding?: array{enabled: bool, features?: array{disable_stripe_user_authentication?: bool, external_account_collection?: bool}}, balances?: array{enabled: bool, features?: array{disable_stripe_user_authentication?: bool, edit_payout_schedule?: bool, external_account_collection?: bool, instant_payouts?: bool, standard_payouts?: bool}}, disputes_list?: array{enabled: bool, features?: array{capture_payments?: bool, destination_on_behalf_of_charge_management?: bool, dispute_management?: bool, refund_management?: bool}}, documents?: array{enabled: bool, features?: array{}}, financial_account?: array{enabled: bool, features?: array{disable_stripe_user_authentication?: bool, external_account_collection?: bool, send_money?: bool, transfer_balance?: bool}}, financial_account_transactions?: array{enabled: bool, features?: array{card_spend_dispute_management?: bool}}, issuing_card?: array{enabled: bool, features?: array{card_management?: bool, card_spend_dispute_management?: bool, cardholder_management?: bool, spend_control_management?: bool}}, issuing_cards_list?: array{enabled: bool, features?: array{card_management?: bool, card_spend_dispute_management?: bool, cardholder_management?: bool, disable_stripe_user_authentication?: bool, spend_control_management?: bool}}, notification_banner?: array{enabled: bool, features?: array{disable_stripe_user_authentication?: bool, external_account_collection?: bool}}, payment_details?: array{enabled: bool, features?: array{capture_payments?: bool, destination_on_behalf_of_charge_management?: bool, dispute_management?: bool, refund_management?: bool}}, payment_disputes?: array{enabled: bool, features?: array{destination_on_behalf_of_charge_management?: bool, dispute_management?: bool, refund_management?: bool}}, payments?: array{enabled: bool, features?: array{capture_payments?: bool, destination_on_behalf_of_charge_management?: bool, dispute_management?: bool, refund_management?: bool}}, payouts?: array{enabled: bool, features?: array{disable_stripe_user_authentication?: bool, edit_payout_schedule?: bool, external_account_collection?: bool, instant_payouts?: bool, standard_payouts?: bool}}, payouts_list?: array{enabled: bool, features?: array{}}, tax_registrations?: array{enabled: bool, features?: array{}}, tax_settings?: array{enabled: bool, features?: array{}}}, expand?: string[]} $params
* @param null|array|string $options
*
* @return AccountSession the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for listable resources. Adds a `all()` static method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait All
{
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return \Stripe\Collection of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for creatable resources. Adds a `create()` static method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Create
{
/**
* @param null|array $params
* @param null|array|string $options
*
* @return static the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for deletable resources. Adds a `delete()` method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Delete
{
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return static the deleted resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@@ -0,0 +1,135 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for resources that have nested resources.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait NestedResource
{
/**
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param null|array $params
* @param null|array|string $options
*
* @return \Stripe\StripeObject
*/
protected static function _nestedResourceOperation($method, $url, $params = null, $options = null)
{
self::_validateParams($params);
list($response, $opts) = static::_staticRequest($method, $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param string $id
* @param string $nestedPath
* @param null|string $nestedId
*
* @return string
*/
protected static function _nestedResourceUrl($id, $nestedPath, $nestedId = null)
{
$url = static::resourceUrl($id) . $nestedPath;
if (null !== $nestedId) {
$url .= "/{$nestedId}";
}
return $url;
}
/**
* @param string $id
* @param string $nestedPath
* @param null|array $params
* @param null|array|string $options
*
* @return \Stripe\StripeObject
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _createNestedResource($id, $nestedPath, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath);
return self::_nestedResourceOperation('post', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param null|string $nestedId
* @param null|array $params
* @param null|array|string $options
*
* @return \Stripe\StripeObject
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _retrieveNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
return self::_nestedResourceOperation('get', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param null|string $nestedId
* @param null|array $params
* @param null|array|string $options
*
* @return \Stripe\StripeObject
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _updateNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
return self::_nestedResourceOperation('post', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param null|string $nestedId
* @param null|array $params
* @param null|array|string $options
*
* @return \Stripe\StripeObject
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _deleteNestedResource($id, $nestedPath, $nestedId, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath, $nestedId);
return self::_nestedResourceOperation('delete', $url, $params, $options);
}
/**
* @param string $id
* @param string $nestedPath
* @param null|array $params
* @param null|array|string $options
*
* @return \Stripe\StripeObject
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _allNestedResources($id, $nestedPath, $params = null, $options = null)
{
$url = static::_nestedResourceUrl($id, $nestedPath);
return self::_nestedResourceOperation('get', $url, $params, $options);
}
}

View File

@@ -0,0 +1,134 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for resources that need to make API requests.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Request
{
/**
* @param null|array|mixed $params The list of parameters to validate
*
* @throws \Stripe\Exception\InvalidArgumentException if $params exists and is not an array
*/
protected static function _validateParams($params = null)
{
if ($params && !\is_array($params)) {
$message = 'You must pass an array as the first argument to Stripe API '
. 'method calls. (HINT: an example call to create a charge '
. "would be: \"Stripe\\Charge::create(['amount' => 100, "
. "'currency' => 'usd', 'source' => 'tok_1234'])\")";
throw new \Stripe\Exception\InvalidArgumentException($message);
}
}
/**
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param array $params list of parameters for the request
* @param null|array|string $options
* @param string[] $usage names of tracked behaviors associated with this request
* @param 'v1'|'v2' $apiMode
*
* @return array tuple containing (the JSON response, $options)
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected function _request($method, $url, $params = [], $options = null, $usage = [], $apiMode = 'v1')
{
$opts = $this->_opts->merge($options);
list($resp, $options) = static::_staticRequest($method, $url, $params, $opts, $usage, $apiMode);
$this->setLastResponse($resp);
return [$resp->json, $options];
}
/**
* @param string $url URL for the request
* @param class-string< \Stripe\Collection|\Stripe\SearchResult > $resultClass indicating what type of paginated result is returned
* @param null|array $params list of parameters for the request
* @param null|array|string $options
* @param string[] $usage names of tracked behaviors associated with this request
*
* @return \Stripe\Collection|\Stripe\SearchResult
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _requestPage($url, $resultClass, $params = null, $options = null, $usage = [])
{
self::_validateParams($params);
list($response, $opts) = static::_staticRequest('get', $url, $params, $options, $usage);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
if (!$obj instanceof $resultClass) {
throw new \Stripe\Exception\UnexpectedValueException(
'Expected type ' . $resultClass . ', got "' . \get_class($obj) . '" instead.'
);
}
$obj->setLastResponse($response);
$obj->setFilters($params);
return $obj;
}
/**
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param callable $readBodyChunk function that will receive chunks of data from a successful request body
* @param array $params list of parameters for the request
* @param null|array|string $options
* @param string[] $usage names of tracked behaviors associated with this request
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected function _requestStream($method, $url, $readBodyChunk, $params = [], $options = null, $usage = [])
{
$opts = $this->_opts->merge($options);
static::_staticStreamingRequest($method, $url, $readBodyChunk, $params, $opts, $usage);
}
/**
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param array $params list of parameters for the request
* @param null|array|string $options
* @param string[] $usage names of tracked behaviors associated with this request
* @param 'v1'|'v2' $apiMode
*
* @return array tuple containing (the JSON response, $options)
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _staticRequest($method, $url, $params, $options, $usage = [], $apiMode = 'v1')
{
$opts = \Stripe\Util\RequestOptions::parse($options);
$baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
$requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
list($response, $opts->apiKey) = $requestor->request($method, $url, $params, $opts->headers, $apiMode, $usage);
$opts->discardNonPersistentHeaders();
return [$response, $opts];
}
/**
* @param 'delete'|'get'|'post' $method HTTP method ('get', 'post', etc.)
* @param string $url URL for the request
* @param callable $readBodyChunk function that will receive chunks of data from a successful request body
* @param array $params list of parameters for the request
* @param null|array|string $options
* @param string[] $usage names of tracked behaviors associated with this request
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
protected static function _staticStreamingRequest($method, $url, $readBodyChunk, $params, $options, $usage = [])
{
$opts = \Stripe\Util\RequestOptions::parse($options);
$baseUrl = isset($opts->apiBase) ? $opts->apiBase : static::baseUrl();
$requestor = new \Stripe\ApiRequestor($opts->apiKey, $baseUrl);
$requestor->requestStream($method, $url, $readBodyChunk, $params, $opts->headers);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for retrievable resources. Adds a `retrieve()` static method to the
* class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Retrieve
{
/**
* @param array|string $id the ID of the API resource to retrieve,
* or an options array containing an `id` key
* @param null|array|string $opts
*
* @return static
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for retrievable singleton resources. Adds a `retrieve()` static method to the
* class.
*
* This trait should only be applied to classes that derive from SingletonApiResource.
*/
trait SingletonRetrieve
{
/**
* @param null|array|string $opts the ID of the API resource to retrieve,
* or an options array containing an `id` key
*
* @return static
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static(null, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,56 @@
<?php
namespace Stripe\ApiOperations;
/**
* Trait for updatable resources. Adds an `update()` static method and a
* `save()` method to the class.
*
* This trait should only be applied to classes that derive from StripeObject.
*/
trait Update
{
/**
* @param string $id the ID of the resource to update
* @param null|array $params
* @param null|array|string $opts
*
* @return static the updated resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param null|array|string $opts
*
* @return static the saved resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @deprecated The `save` method is deprecated and will be removed in a
* future major version of the library. Use the static method `update`
* on the resource instead.
*/
public function save($opts = null)
{
$params = $this->serializeParameters();
if (\count($params) > 0) {
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
$this->refreshFrom($response, $opts);
}
return $this;
}
}

View File

@@ -0,0 +1,709 @@
<?php
namespace Stripe;
/**
* Class ApiRequestor.
*/
class ApiRequestor
{
/**
* @var null|string
*/
private $_apiKey;
/**
* @var string
*/
private $_apiBase;
/**
* @var null|array
*/
private $_appInfo;
/**
* @var HttpClient\ClientInterface
*/
private static $_httpClient;
/**
* @var HttpClient\StreamingClientInterface
*/
private static $_streamingHttpClient;
/**
* @var RequestTelemetry
*/
private static $requestTelemetry;
private static $OPTIONS_KEYS = ['api_key', 'idempotency_key', 'stripe_account', 'stripe_context', 'stripe_version', 'api_base'];
/**
* ApiRequestor constructor.
*
* @param null|string $apiKey
* @param null|string $apiBase
* @param null|array $appInfo
*/
public function __construct($apiKey = null, $apiBase = null, $appInfo = null)
{
$this->_apiKey = $apiKey;
if (!$apiBase) {
$apiBase = Stripe::$apiBase;
}
$this->_apiBase = $apiBase;
$this->_appInfo = $appInfo;
}
/**
* Creates a telemetry json blob for use in 'X-Stripe-Client-Telemetry' headers.
*
* @static
*
* @param RequestTelemetry $requestTelemetry
*
* @return string
*/
private static function _telemetryJson($requestTelemetry)
{
$payload = [
'last_request_metrics' => [
'request_id' => $requestTelemetry->requestId,
'request_duration_ms' => $requestTelemetry->requestDuration,
],
];
if (\count($requestTelemetry->usage) > 0) {
$payload['last_request_metrics']['usage'] = $requestTelemetry->usage;
}
$result = \json_encode($payload);
if (false !== $result) {
return $result;
}
Stripe::getLogger()->error('Serializing telemetry payload failed!');
return '{}';
}
/**
* @static
*
* @param ApiResource|array|bool|mixed $d
*
* @return ApiResource|array|mixed|string
*/
private static function _encodeObjects($d)
{
if ($d instanceof ApiResource) {
return Util\Util::utf8($d->id);
}
if (true === $d) {
return 'true';
}
if (false === $d) {
return 'false';
}
if (\is_array($d)) {
$res = [];
foreach ($d as $k => $v) {
$res[$k] = self::_encodeObjects($v);
}
return $res;
}
return Util\Util::utf8($d);
}
/**
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param null|array $params
* @param null|array $headers
* @param 'v1'|'v2' $apiMode
* @param string[] $usage
* @param null|int $maxNetworkRetries
*
* @return array tuple containing (ApiReponse, API key)
*
* @throws Exception\ApiErrorException
*/
public function request($method, $url, $params = null, $headers = null, $apiMode = 'v1', $usage = [], $maxNetworkRetries = null)
{
$params = $params ?: [];
$headers = $headers ?: [];
list($rbody, $rcode, $rheaders, $myApiKey)
= $this->_requestRaw($method, $url, $params, $headers, $apiMode, $usage, $maxNetworkRetries);
$json = $this->_interpretResponse($rbody, $rcode, $rheaders, $apiMode);
$resp = new ApiResponse($rbody, $rcode, $rheaders, $json);
return [$resp, $myApiKey];
}
/**
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param callable $readBodyChunkCallable
* @param null|array $params
* @param null|array $headers
* @param 'v1'|'v2' $apiMode
* @param string[] $usage
* @param null|int $maxNetworkRetries
*
* @throws Exception\ApiErrorException
*/
public function requestStream($method, $url, $readBodyChunkCallable, $params = null, $headers = null, $apiMode = 'v1', $usage = [], $maxNetworkRetries = null)
{
$params = $params ?: [];
$headers = $headers ?: [];
list($rbody, $rcode, $rheaders, $myApiKey)
= $this->_requestRawStreaming($method, $url, $params, $headers, $apiMode, $usage, $readBodyChunkCallable, $maxNetworkRetries);
if ($rcode >= 300) {
$this->_interpretResponse($rbody, $rcode, $rheaders, $apiMode);
}
}
/**
* @param string $rbody a JSON string
* @param int $rcode
* @param array $rheaders
* @param array $resp
* @param 'v1'|'v2' $apiMode
*
* @throws Exception\UnexpectedValueException
* @throws Exception\ApiErrorException
*/
public function handleErrorResponse($rbody, $rcode, $rheaders, $resp, $apiMode)
{
if (!\is_array($resp) || !isset($resp['error'])) {
$msg = "Invalid response object from API: {$rbody} "
. "(HTTP response code was {$rcode})";
throw new Exception\UnexpectedValueException($msg);
}
$errorData = $resp['error'];
$error = null;
if (\is_string($errorData)) {
$error = self::_specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorData);
}
if (!$error) {
$error = 'v1' === $apiMode ? self::_specificV1APIError($rbody, $rcode, $rheaders, $resp, $errorData) : self::_specificV2APIError($rbody, $rcode, $rheaders, $resp, $errorData);
}
throw $error;
}
/**
* @static
*
* @param string $rbody
* @param int $rcode
* @param array $rheaders
* @param array $resp
* @param array $errorData
*
* @return Exception\ApiErrorException
*/
private static function _specificV1APIError($rbody, $rcode, $rheaders, $resp, $errorData)
{
$msg = isset($errorData['message']) ? $errorData['message'] : null;
$param = isset($errorData['param']) ? $errorData['param'] : null;
$code = isset($errorData['code']) ? $errorData['code'] : null;
$type = isset($errorData['type']) ? $errorData['type'] : null;
$declineCode = isset($errorData['decline_code']) ? $errorData['decline_code'] : null;
switch ($rcode) {
case 400:
// 'rate_limit' code is deprecated, but left here for backwards compatibility
// for API versions earlier than 2015-09-08
if ('rate_limit' === $code) {
return Exception\RateLimitException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param);
}
if ('idempotency_error' === $type) {
return Exception\IdempotencyException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
}
// fall through in generic 400 or 404, returns InvalidRequestException by default
// no break
case 404:
return Exception\InvalidRequestException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param);
case 401:
return Exception\AuthenticationException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
case 402:
return Exception\CardException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $declineCode, $param);
case 403:
return Exception\PermissionException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
case 429:
return Exception\RateLimitException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code, $param);
default:
return Exception\UnknownApiErrorException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
}
}
/**
* @static
*
* @param string $rbody
* @param int $rcode
* @param array $rheaders
* @param array $resp
* @param array $errorData
*
* @return Exception\ApiErrorException
*/
private static function _specificV2APIError($rbody, $rcode, $rheaders, $resp, $errorData)
{
$msg = isset($errorData['message']) ? $errorData['message'] : null;
$code = isset($errorData['code']) ? $errorData['code'] : null;
$type = isset($errorData['type']) ? $errorData['type'] : null;
switch ($type) {
case 'idempotency_error':
return Exception\IdempotencyException::factory($msg, $rcode, $rbody, $resp, $rheaders, $code);
// The beginning of the section generated from our OpenAPI spec
case 'temporary_session_expired':
return Exception\TemporarySessionExpiredException::factory(
$msg,
$rcode,
$rbody,
$resp,
$rheaders,
$code
);
// The end of the section generated from our OpenAPI spec
default:
return self::_specificV1APIError($rbody, $rcode, $rheaders, $resp, $errorData);
}
}
/**
* @static
*
* @param bool|string $rbody
* @param int $rcode
* @param array $rheaders
* @param array $resp
* @param string $errorCode
*
* @return Exception\OAuth\OAuthErrorException
*/
private static function _specificOAuthError($rbody, $rcode, $rheaders, $resp, $errorCode)
{
$description = isset($resp['error_description']) ? $resp['error_description'] : $errorCode;
switch ($errorCode) {
case 'invalid_client':
return Exception\OAuth\InvalidClientException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'invalid_grant':
return Exception\OAuth\InvalidGrantException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'invalid_request':
return Exception\OAuth\InvalidRequestException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'invalid_scope':
return Exception\OAuth\InvalidScopeException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'unsupported_grant_type':
return Exception\OAuth\UnsupportedGrantTypeException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
case 'unsupported_response_type':
return Exception\OAuth\UnsupportedResponseTypeException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
default:
return Exception\OAuth\UnknownOAuthErrorException::factory($description, $rcode, $rbody, $resp, $rheaders, $errorCode);
}
}
/**
* @static
*
* @param null|array $appInfo
*
* @return null|string
*/
private static function _formatAppInfo($appInfo)
{
if (null !== $appInfo) {
$string = $appInfo['name'];
if (\array_key_exists('version', $appInfo) && null !== $appInfo['version']) {
$string .= '/' . $appInfo['version'];
}
if (\array_key_exists('url', $appInfo) && null !== $appInfo['url']) {
$string .= ' (' . $appInfo['url'] . ')';
}
return $string;
}
return null;
}
/**
* @static
*
* @param string $disableFunctionsOutput - String value of the 'disable_function' setting, as output by \ini_get('disable_functions')
* @param string $functionName - Name of the function we are interesting in seeing whether or not it is disabled
*
* @return bool
*/
private static function _isDisabled($disableFunctionsOutput, $functionName)
{
$disabledFunctions = \explode(',', $disableFunctionsOutput);
foreach ($disabledFunctions as $disabledFunction) {
if (\trim($disabledFunction) === $functionName) {
return true;
}
}
return false;
}
/**
* @static
*
* @param string $apiKey the Stripe API key, to be used in regular API requests
* @param null $clientInfo client user agent information
* @param null $appInfo information to identify a plugin that integrates Stripe using this library
* @param 'v1'|'v2' $apiMode
*
* @return array
*/
private static function _defaultHeaders($apiKey, $clientInfo = null, $appInfo = null, $apiMode = 'v1')
{
$uaString = "Stripe/{$apiMode} PhpBindings/" . Stripe::VERSION;
$langVersion = \PHP_VERSION;
$uname_disabled = self::_isDisabled(\ini_get('disable_functions'), 'php_uname');
$uname = $uname_disabled ? '(disabled)' : \php_uname();
// Fallback to global configuration to maintain backwards compatibility.
$appInfo = $appInfo ?: Stripe::getAppInfo();
$ua = [
'bindings_version' => Stripe::VERSION,
'lang' => 'php',
'lang_version' => $langVersion,
'publisher' => 'stripe',
'uname' => $uname,
];
if ($clientInfo) {
$ua = \array_merge($clientInfo, $ua);
}
if (null !== $appInfo) {
$uaString .= ' ' . self::_formatAppInfo($appInfo);
$ua['application'] = $appInfo;
}
return [
'X-Stripe-Client-User-Agent' => \json_encode($ua),
'User-Agent' => $uaString,
'Authorization' => 'Bearer ' . $apiKey,
'Stripe-Version' => Stripe::getApiVersion(),
];
}
/**
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param array $params
* @param array $headers
* @param 'v1'|'v2' $apiMode
*/
private function _prepareRequest($method, $url, $params, $headers, $apiMode)
{
$myApiKey = $this->_apiKey;
if (!$myApiKey) {
$myApiKey = Stripe::$apiKey;
}
if (!$myApiKey) {
$msg = 'No API key provided. (HINT: set your API key using '
. '"Stripe::setApiKey(<API-KEY>)". You can generate API keys from '
. 'the Stripe web interface. See https://stripe.com/api for '
. 'details, or email support@stripe.com if you have any questions.';
throw new Exception\AuthenticationException($msg);
}
// Clients can supply arbitrary additional keys to be included in the
// X-Stripe-Client-User-Agent header via the optional getUserAgentInfo()
// method
$clientUAInfo = null;
if (\method_exists(self::httpClient(), 'getUserAgentInfo')) {
$clientUAInfo = self::httpClient()->getUserAgentInfo();
}
if ($params && \is_array($params)) {
$optionKeysInParams = \array_filter(
self::$OPTIONS_KEYS,
static function ($key) use ($params) {
return \array_key_exists($key, $params);
}
);
if (\count($optionKeysInParams) > 0) {
$message = \sprintf('Options found in $params: %s. Options should '
. 'be passed in their own array after $params. (HINT: pass an '
. 'empty array to $params if you do not have any.)', \implode(', ', $optionKeysInParams));
\trigger_error($message, \E_USER_WARNING);
}
}
$absUrl = $this->_apiBase . $url;
if ('v1' === $apiMode) {
$params = self::_encodeObjects($params);
}
$defaultHeaders = $this->_defaultHeaders($myApiKey, $clientUAInfo, $this->_appInfo, $apiMode);
if (Stripe::$accountId) {
$defaultHeaders['Stripe-Account'] = Stripe::$accountId;
}
if (Stripe::$enableTelemetry && null !== self::$requestTelemetry) {
$defaultHeaders['X-Stripe-Client-Telemetry'] = self::_telemetryJson(self::$requestTelemetry);
}
$hasFile = false;
foreach ($params as $k => $v) {
if (\is_resource($v)) {
$hasFile = true;
$params[$k] = self::_processResourceParam($v);
} elseif ($v instanceof \CURLFile) {
$hasFile = true;
}
}
if ($hasFile) {
$defaultHeaders['Content-Type'] = 'multipart/form-data';
} elseif ('v2' === $apiMode) {
$defaultHeaders['Content-Type'] = 'application/json';
} elseif ('v1' === $apiMode) {
$defaultHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
} else {
throw new Exception\InvalidArgumentException('Unknown API mode: ' . $apiMode);
}
$combinedHeaders = \array_merge($defaultHeaders, $headers);
$rawHeaders = [];
foreach ($combinedHeaders as $header => $value) {
$rawHeaders[] = $header . ': ' . $value;
}
return [$absUrl, $rawHeaders, $params, $hasFile, $myApiKey];
}
/**
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param array $params
* @param array $headers
* @param 'v1'|'v2' $apiMode
* @param string[] $usage
* @param null|int $maxNetworkRetries
*
* @return array
*
* @throws Exception\AuthenticationException
* @throws Exception\ApiConnectionException
*/
private function _requestRaw($method, $url, $params, $headers, $apiMode, $usage, $maxNetworkRetries)
{
list($absUrl, $rawHeaders, $params, $hasFile, $myApiKey) = $this->_prepareRequest($method, $url, $params, $headers, $apiMode);
// for some reason, PHP users will sometimes include null bytes in their paths, which leads to cryptic server 400s.
// we'll be louder about this to help catch issues earlier.
if (false !== \strpos($absUrl, "\0") || false !== \strpos($absUrl, '%00')) {
throw new Exception\InvalidRequestException("URLs may not contain null bytes ('\\0'); double check any IDs you're including with the request.");
}
$requestStartMs = Util\Util::currentTimeMillis();
list($rbody, $rcode, $rheaders) = self::httpClient()->request(
$method,
$absUrl,
$rawHeaders,
$params,
$hasFile,
$apiMode,
$maxNetworkRetries
);
if (
isset($rheaders['request-id'])
&& \is_string($rheaders['request-id'])
&& '' !== $rheaders['request-id']
) {
self::$requestTelemetry = new RequestTelemetry(
$rheaders['request-id'],
Util\Util::currentTimeMillis() - $requestStartMs,
$usage
);
}
return [$rbody, $rcode, $rheaders, $myApiKey];
}
/**
* @param 'delete'|'get'|'post' $method
* @param string $url
* @param array $params
* @param array $headers
* @param string[] $usage
* @param callable $readBodyChunkCallable
* @param 'v1'|'v2' $apiMode
* @param int $maxNetworkRetries
*
* @return array
*
* @throws Exception\AuthenticationException
* @throws Exception\ApiConnectionException
*/
private function _requestRawStreaming($method, $url, $params, $headers, $apiMode, $usage, $readBodyChunkCallable, $maxNetworkRetries)
{
list($absUrl, $rawHeaders, $params, $hasFile, $myApiKey) = $this->_prepareRequest($method, $url, $params, $headers, $apiMode);
$requestStartMs = Util\Util::currentTimeMillis();
list($rbody, $rcode, $rheaders) = self::streamingHttpClient()->requestStream(
$method,
$absUrl,
$rawHeaders,
$params,
$hasFile,
$readBodyChunkCallable,
$maxNetworkRetries
);
if (
isset($rheaders['request-id'])
&& \is_string($rheaders['request-id'])
&& '' !== $rheaders['request-id']
) {
self::$requestTelemetry = new RequestTelemetry(
$rheaders['request-id'],
Util\Util::currentTimeMillis() - $requestStartMs
);
}
return [$rbody, $rcode, $rheaders, $myApiKey];
}
/**
* @param resource $resource
*
* @return \CURLFile|string
*
* @throws Exception\InvalidArgumentException
*/
private function _processResourceParam($resource)
{
if ('stream' !== \get_resource_type($resource)) {
throw new Exception\InvalidArgumentException(
'Attempted to upload a resource that is not a stream'
);
}
$metaData = \stream_get_meta_data($resource);
if ('plainfile' !== $metaData['wrapper_type']) {
throw new Exception\InvalidArgumentException(
'Only plainfile resource streams are supported'
);
}
// We don't have the filename or mimetype, but the API doesn't care
return new \CURLFile($metaData['uri']);
}
/**
* @param string $rbody
* @param int $rcode
* @param array $rheaders
* @param 'v1'|'v2' $apiMode
*
* @return array
*
* @throws Exception\UnexpectedValueException
* @throws Exception\ApiErrorException
*/
private function _interpretResponse($rbody, $rcode, $rheaders, $apiMode)
{
$resp = \json_decode($rbody, true);
$jsonError = \json_last_error();
if (null === $resp && \JSON_ERROR_NONE !== $jsonError) {
$msg = "Invalid response body from API: {$rbody} "
. "(HTTP response code was {$rcode}, json_last_error() was {$jsonError})";
throw new Exception\UnexpectedValueException($msg, $rcode);
}
if ($rcode < 200 || $rcode >= 300) {
$this->handleErrorResponse($rbody, $rcode, $rheaders, $resp, $apiMode);
}
return $resp;
}
/**
* @static
*
* @param HttpClient\ClientInterface $client
*/
public static function setHttpClient($client)
{
self::$_httpClient = $client;
}
/**
* @static
*
* @param HttpClient\StreamingClientInterface $client
*/
public static function setStreamingHttpClient($client)
{
self::$_streamingHttpClient = $client;
}
/**
* @static
*
* Resets any stateful telemetry data
*/
public static function resetTelemetry()
{
self::$requestTelemetry = null;
}
/**
* @return HttpClient\ClientInterface
*/
public static function httpClient()
{
if (!self::$_httpClient) {
self::$_httpClient = HttpClient\CurlClient::instance();
}
return self::$_httpClient;
}
/**
* @return HttpClient\StreamingClientInterface
*/
public static function streamingHttpClient()
{
if (!self::$_streamingHttpClient) {
self::$_streamingHttpClient = HttpClient\CurlClient::instance();
}
return self::$_streamingHttpClient;
}
}

View File

@@ -0,0 +1,123 @@
<?php
namespace Stripe;
/**
* Class ApiResource.
*
* */
abstract class ApiResource extends StripeObject
{
use ApiOperations\Request;
/**
* @return Util\Set A list of fields that can be their own type of
* API resource (say a nested card under an account for example), and if
* that resource is set, it should be transmitted to the API on a create or
* update. Doing so is not the default behavior because API resources
* should normally be persisted on their own RESTful endpoints.
*/
public static function getSavedNestedResources()
{
static $savedNestedResources = null;
if (null === $savedNestedResources) {
$savedNestedResources = new Util\Set();
}
return $savedNestedResources;
}
/**
* @var bool A flag that can be set a behavior that will cause this
* resource to be encoded and sent up along with an update of its parent
* resource. This is usually not desirable because resources are updated
* individually on their own endpoints, but there are certain cases,
* replacing a customer's source for example, where this is allowed.
*/
public $saveWithParent = false;
public function __set($k, $v)
{
parent::__set($k, $v);
$v = $this->{$k};
if (static::getSavedNestedResources()->includes($k)
&& ($v instanceof ApiResource)) {
$v->saveWithParent = true;
}
}
/**
* @return ApiResource the refreshed resource
*
* @throws Exception\ApiErrorException
*/
public function refresh()
{
$requestor = new ApiRequestor($this->_opts->apiKey, static::baseUrl());
$url = $this->instanceUrl();
list($response, $this->_opts->apiKey) = $requestor->request(
'get',
$url,
$this->_retrieveOptions,
$this->_opts->headers
);
$this->setLastResponse($response);
$this->refreshFrom($response->json, $this->_opts);
return $this;
}
/**
* @return string the base URL for the given class
*/
public static function baseUrl()
{
return Stripe::$apiBase;
}
/**
* @return string the endpoint URL for the given class
*/
public static function classUrl()
{
// Replace dots with slashes for namespaced resources, e.g. if the object's name is
// "foo.bar", then its URL will be "/v1/foo/bars".
/** @phpstan-ignore-next-line */
$base = \str_replace('.', '/', static::OBJECT_NAME);
return "/v1/{$base}s";
}
/**
* @param null|string $id the ID of the resource
*
* @return string the instance endpoint URL for the given class
*
* @throws Exception\UnexpectedValueException if $id is null
*/
public static function resourceUrl($id)
{
if (null === $id) {
$class = static::class;
$message = 'Could not determine which URL to request: '
. "{$class} instance has invalid ID: {$id}";
throw new Exception\UnexpectedValueException($message);
}
$id = Util\Util::utf8($id);
$base = static::classUrl();
$extn = \urlencode($id);
return "{$base}/{$extn}";
}
/**
* @return string the full API URL for this API resource
*/
public function instanceUrl()
{
return static::resourceUrl($this['id']);
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace Stripe;
use Stripe\Util\CaseInsensitiveArray;
/**
* Class ApiResponse.
*/
class ApiResponse
{
/**
* @var null|array|CaseInsensitiveArray
*/
public $headers;
/**
* @var string
*/
public $body;
/**
* @var null|array
*/
public $json;
/**
* @var int
*/
public $code;
/**
* @param string $body
* @param int $code
* @param null|array|CaseInsensitiveArray $headers
* @param null|array $json
*/
public function __construct($body, $code, $headers, $json)
{
$this->body = $body;
$this->code = $code;
$this->headers = $headers;
$this->json = $json;
}
}

View File

@@ -0,0 +1,105 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $domain_name
* @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 ApplePayDomain extends ApiResource
{
const OBJECT_NAME = 'apple_pay_domain';
/**
* Create an apple pay domain.
*
* @param null|array{domain_name: string, expand?: string[]} $params
* @param null|array|string $options
*
* @return ApplePayDomain the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Delete an apple pay domain.
*
* @param null|array $params
* @param null|array|string $opts
*
* @return ApplePayDomain the deleted resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* List apple pay domains.
*
* @param null|array{domain_name?: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<ApplePayDomain> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieve an apple pay domain.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return ApplePayDomain
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* @return string The class URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
*/
public static function classUrl()
{
return '/v1/apple_pay/domains';
}
}

View File

@@ -0,0 +1,15 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* @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 $name The name of the application.
*/
class Application extends ApiResource
{
const OBJECT_NAME = 'application';
}

View File

@@ -0,0 +1,127 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* @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 Account|string $account ID of the Stripe account this fee was taken from.
* @property int $amount Amount earned, in cents (or local equivalent).
* @property int $amount_refunded Amount in cents (or local equivalent) refunded (can be less than the amount attribute on the fee if a partial refund was issued)
* @property Application|string $application ID of the Connect application that earned the fee.
* @property null|BalanceTransaction|string $balance_transaction Balance transaction that describes the impact of this collected application fee on your account balance (not including refunds).
* @property Charge|string $charge ID of the charge that the application fee was taken from.
* @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|(object{charge?: string, payout?: string, type: string}&StripeObject) $fee_source Polymorphic source of the application fee. Includes the ID of the object the application fee was created from.
* @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 null|Charge|string $originating_transaction ID of the corresponding charge on the platform account, if this fee was the result of a charge using the <code>destination</code> parameter.
* @property bool $refunded Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.
* @property Collection<ApplicationFeeRefund> $refunds A list of refunds that have been applied to the fee.
*/
class ApplicationFee extends ApiResource
{
const OBJECT_NAME = 'application_fee';
use ApiOperations\NestedResource;
/**
* Returns a list of application fees youve previously collected. The application
* fees are returned in sorted order, with the most recent fees appearing first.
*
* @param null|array{charge?: string, created?: array|int, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<ApplicationFee> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the details of an application fee that your account has collected. The
* same information is returned when refunding the application fee.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return ApplicationFee
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
const PATH_REFUNDS = '/refunds';
/**
* @param string $id the ID of the application fee on which to retrieve the application fee refunds
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<ApplicationFeeRefund> the list of application fee refunds
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function allRefunds($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_REFUNDS, $params, $opts);
}
/**
* @param string $id the ID of the application fee on which to create the application fee refund
* @param null|array $params
* @param null|array|string $opts
*
* @return ApplicationFeeRefund
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function createRefund($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_REFUNDS, $params, $opts);
}
/**
* @param string $id the ID of the application fee to which the application fee refund belongs
* @param string $refundId the ID of the application fee refund to retrieve
* @param null|array $params
* @param null|array|string $opts
*
* @return ApplicationFeeRefund
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieveRefund($id, $refundId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
}
/**
* @param string $id the ID of the application fee to which the application fee refund belongs
* @param string $refundId the ID of the application fee refund to update
* @param null|array $params
* @param null|array|string $opts
*
* @return ApplicationFeeRefund
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function updateRefund($id, $refundId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_REFUNDS, $refundId, $params, $opts);
}
}

View File

@@ -0,0 +1,64 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* <code>Application Fee Refund</code> objects allow you to refund an application fee that
* has previously been created but not yet refunded. Funds will be refunded to
* the Stripe account from which the fee was originally collected.
*
* Related guide: <a href="https://stripe.com/docs/connect/destination-charges#refunding-app-fee">Refunding application fees</a>
*
* @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 (or local equivalent).
* @property null|BalanceTransaction|string $balance_transaction Balance transaction that describes the impact on your account balance.
* @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 ApplicationFee|string $fee ID of the application fee that was refunded.
* @property null|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.
*/
class ApplicationFeeRefund extends ApiResource
{
const OBJECT_NAME = 'fee_refund';
use ApiOperations\Update {
save as protected _save;
}
/**
* @return string the API URL for this Stripe refund
*/
public function instanceUrl()
{
$id = $this['id'];
$fee = $this['fee'];
if (!$id) {
throw new Exception\UnexpectedValueException(
'Could not determine which URL to request: '
. "class instance has invalid ID: {$id}",
null
);
}
$id = Util\Util::utf8($id);
$fee = Util\Util::utf8($fee);
$base = ApplicationFee::classUrl();
$feeExtn = \urlencode($fee);
$extn = \urlencode($id);
return "{$base}/{$feeExtn}/refunds/{$extn}";
}
/**
* @param null|array|string $opts
*
* @return ApplicationFeeRefund the saved refund
*/
public function save($opts = null)
{
return $this->_save($opts);
}
}

View File

@@ -0,0 +1,106 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Apps;
/**
* Secret Store is an API that allows Stripe Apps developers to securely persist secrets for use by UI Extensions and app backends.
*
* The primary resource in Secret Store is a <code>secret</code>. Other apps can't view secrets created by an app. Additionally, secrets are scoped to provide further permission control.
*
* All Dashboard users and the app backend share <code>account</code> scoped secrets. Use the <code>account</code> scope for secrets that don't change per-user, like a third-party API key.
*
* A <code>user</code> scoped secret is accessible by the app backend and one specific Dashboard user. Use the <code>user</code> scope for per-user secrets like per-user OAuth tokens, where different users might have different permissions.
*
* Related guide: <a href="https://stripe.com/docs/stripe-apps/store-auth-data-custom-objects">Store data between page reloads</a>
*
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|bool $deleted If true, indicates that this secret has been deleted
* @property null|int $expires_at The Unix timestamp for the expiry time of the secret, after which the secret deletes.
* @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 string $name A name for the secret that's unique within the scope.
* @property null|string $payload The plaintext secret value to be stored.
* @property (object{type: string, user?: string}&\Stripe\StripeObject) $scope
*/
class Secret extends \Stripe\ApiResource
{
const OBJECT_NAME = 'apps.secret';
/**
* Create or replace a secret in the secret store.
*
* @param null|array{expand?: string[], expires_at?: int, name: string, payload: string, scope: array{type: string, user?: string}} $params
* @param null|array|string $options
*
* @return Secret the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* List all secrets stored on the given scope.
*
* @param null|array{ending_before?: string, expand?: string[], limit?: int, scope: array{type: string, user?: string}, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Secret> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Secret the deleted secret
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function deleteWhere($params = null, $opts = null)
{
$url = static::classUrl() . '/delete';
list($response, $opts) = static::_staticRequest('post', $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
*
* @return Secret the finded secret
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function find($params = null, $opts = null)
{
$url = static::classUrl() . '/find';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,53 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* This is an object representing your Stripe balance. You can retrieve it to see
* the balance currently on your Stripe account.
*
* You can also retrieve the balance history, which contains a list of
* <a href="https://stripe.com/docs/reporting/balance-transaction-types">transactions</a> that contributed to the balance
* (charges, payouts, and so forth).
*
* The available and pending amounts for each currency are broken down further by
* payment source types.
*
* Related guide: <a href="https://stripe.com/docs/connect/account-balances">Understanding Connect account balances</a>
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property (object{amount: int, currency: string, source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[] $available Available funds that you can transfer or pay out automatically by Stripe or explicitly through the <a href="https://stripe.com/docs/api#transfers">Transfers API</a> or <a href="https://stripe.com/docs/api#payouts">Payouts API</a>. You can find the available balance for each currency and payment type in the <code>source_types</code> property.
* @property null|(object{amount: int, currency: string, source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[] $connect_reserved Funds held due to negative balances on connected accounts where <a href="/api/accounts/object#account_object-controller-requirement_collection">account.controller.requirement_collection</a> is <code>application</code>, which includes Custom accounts. You can find the connect reserve balance for each currency and payment type in the <code>source_types</code> property.
* @property null|(object{amount: int, currency: string, net_available?: (object{amount: int, destination: string, source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[], source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[] $instant_available Funds that you can pay out using Instant Payouts.
* @property null|(object{available: (object{amount: int, currency: string, source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[]}&StripeObject) $issuing
* @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 (object{amount: int, currency: string, source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[] $pending Funds that aren't available in the balance yet. You can find the pending balance for each currency and each payment type in the <code>source_types</code> property.
* @property null|(object{available: (object{amount: int, currency: string, source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[], pending: (object{amount: int, currency: string, source_types?: (object{bank_account?: int, card?: int, fpx?: int}&StripeObject)}&StripeObject)[]}&StripeObject) $refund_and_dispute_prefunding
*/
class Balance extends SingletonApiResource
{
const OBJECT_NAME = 'balance';
/**
* Retrieves the current account balance, based on the authentication that was used
* to make the request. For a sample request, see <a
* href="/docs/connect/account-balances#accounting-for-negative-balances">Accounting
* for negative balances</a>.
*
* @param null|array|string $opts
*
* @return Balance
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static(null, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,126 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* Balance transactions represent funds moving through your Stripe account.
* Stripe creates them for every type of transaction that enters or leaves your Stripe account balance.
*
* Related guide: <a href="https://stripe.com/docs/reports/balance-transaction-types">Balance transaction types</a>
*
* @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 Gross amount of this transaction (in cents (or local equivalent)). A positive value represents funds charged to another party, and a negative value represents funds sent to another party.
* @property int $available_on The date that the transaction's net funds become available in the Stripe balance.
* @property string $balance_type The balance that this transaction impacts.
* @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 null|float $exchange_rate If applicable, this transaction uses an exchange rate. If money converts from currency A to currency B, then the <code>amount</code> in currency A, multipled by the <code>exchange_rate</code>, equals the <code>amount</code> in currency B. For example, if you charge a customer 10.00 EUR, the PaymentIntent's <code>amount</code> is <code>1000</code> and <code>currency</code> is <code>eur</code>. If this converts to 12.34 USD in your Stripe account, the BalanceTransaction's <code>amount</code> is <code>1234</code>, its <code>currency</code> is <code>usd</code>, and the <code>exchange_rate</code> is <code>1.234</code>.
* @property int $fee Fees (in cents (or local equivalent)) paid for this transaction. Represented as a positive integer when assessed.
* @property ((object{amount: int, application: null|string, currency: string, description: null|string, type: string}&StripeObject))[] $fee_details Detailed breakdown of fees (in cents (or local equivalent)) paid for this transaction.
* @property int $net Net impact to a Stripe balance (in cents (or local equivalent)). A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance. You can calculate the net impact of a transaction on a balance by <code>amount</code> - <code>fee</code>
* @property string $reporting_category Learn more about how <a href="https://stripe.com/docs/reports/reporting-categories">reporting categories</a> can help you understand balance transactions from an accounting perspective.
* @property null|ApplicationFee|ApplicationFeeRefund|Charge|ConnectCollectionTransfer|CustomerCashBalanceTransaction|Dispute|Issuing\Authorization|Issuing\Dispute|Issuing\Transaction|Payout|Refund|ReserveTransaction|string|TaxDeductedAtSource|Topup|Transfer|TransferReversal $source This transaction relates to the Stripe object.
* @property string $status The transaction's net funds status in the Stripe balance, which are either <code>available</code> or <code>pending</code>.
* @property string $type Transaction type: <code>adjustment</code>, <code>advance</code>, <code>advance_funding</code>, <code>anticipation_repayment</code>, <code>application_fee</code>, <code>application_fee_refund</code>, <code>charge</code>, <code>climate_order_purchase</code>, <code>climate_order_refund</code>, <code>connect_collection_transfer</code>, <code>contribution</code>, <code>issuing_authorization_hold</code>, <code>issuing_authorization_release</code>, <code>issuing_dispute</code>, <code>issuing_transaction</code>, <code>obligation_outbound</code>, <code>obligation_reversal_inbound</code>, <code>payment</code>, <code>payment_failure_refund</code>, <code>payment_network_reserve_hold</code>, <code>payment_network_reserve_release</code>, <code>payment_refund</code>, <code>payment_reversal</code>, <code>payment_unreconciled</code>, <code>payout</code>, <code>payout_cancel</code>, <code>payout_failure</code>, <code>payout_minimum_balance_hold</code>, <code>payout_minimum_balance_release</code>, <code>refund</code>, <code>refund_failure</code>, <code>reserve_transaction</code>, <code>reserved_funds</code>, <code>stripe_fee</code>, <code>stripe_fx_fee</code>, <code>stripe_balance_payment_debit</code>, <code>stripe_balance_payment_debit_reversal</code>, <code>tax_fee</code>, <code>topup</code>, <code>topup_reversal</code>, <code>transfer</code>, <code>transfer_cancel</code>, <code>transfer_failure</code>, or <code>transfer_refund</code>. Learn more about <a href="https://stripe.com/docs/reports/balance-transaction-types">balance transaction types and what they represent</a>. To classify transactions for accounting purposes, consider <code>reporting_category</code> instead.
*/
class BalanceTransaction extends ApiResource
{
const OBJECT_NAME = 'balance_transaction';
const BALANCE_TYPE_ISSUING = 'issuing';
const BALANCE_TYPE_PAYMENTS = 'payments';
const BALANCE_TYPE_REFUND_AND_DISPUTE_PREFUNDING = 'refund_and_dispute_prefunding';
const TYPE_ADJUSTMENT = 'adjustment';
const TYPE_ADVANCE = 'advance';
const TYPE_ADVANCE_FUNDING = 'advance_funding';
const TYPE_ANTICIPATION_REPAYMENT = 'anticipation_repayment';
const TYPE_APPLICATION_FEE = 'application_fee';
const TYPE_APPLICATION_FEE_REFUND = 'application_fee_refund';
const TYPE_CHARGE = 'charge';
const TYPE_CLIMATE_ORDER_PURCHASE = 'climate_order_purchase';
const TYPE_CLIMATE_ORDER_REFUND = 'climate_order_refund';
const TYPE_CONNECT_COLLECTION_TRANSFER = 'connect_collection_transfer';
const TYPE_CONTRIBUTION = 'contribution';
const TYPE_ISSUING_AUTHORIZATION_HOLD = 'issuing_authorization_hold';
const TYPE_ISSUING_AUTHORIZATION_RELEASE = 'issuing_authorization_release';
const TYPE_ISSUING_DISPUTE = 'issuing_dispute';
const TYPE_ISSUING_TRANSACTION = 'issuing_transaction';
const TYPE_OBLIGATION_OUTBOUND = 'obligation_outbound';
const TYPE_OBLIGATION_REVERSAL_INBOUND = 'obligation_reversal_inbound';
const TYPE_PAYMENT = 'payment';
const TYPE_PAYMENT_FAILURE_REFUND = 'payment_failure_refund';
const TYPE_PAYMENT_NETWORK_RESERVE_HOLD = 'payment_network_reserve_hold';
const TYPE_PAYMENT_NETWORK_RESERVE_RELEASE = 'payment_network_reserve_release';
const TYPE_PAYMENT_REFUND = 'payment_refund';
const TYPE_PAYMENT_REVERSAL = 'payment_reversal';
const TYPE_PAYMENT_UNRECONCILED = 'payment_unreconciled';
const TYPE_PAYOUT = 'payout';
const TYPE_PAYOUT_CANCEL = 'payout_cancel';
const TYPE_PAYOUT_FAILURE = 'payout_failure';
const TYPE_PAYOUT_MINIMUM_BALANCE_HOLD = 'payout_minimum_balance_hold';
const TYPE_PAYOUT_MINIMUM_BALANCE_RELEASE = 'payout_minimum_balance_release';
const TYPE_REFUND = 'refund';
const TYPE_REFUND_FAILURE = 'refund_failure';
const TYPE_RESERVED_FUNDS = 'reserved_funds';
const TYPE_RESERVE_TRANSACTION = 'reserve_transaction';
const TYPE_STRIPE_BALANCE_PAYMENT_DEBIT = 'stripe_balance_payment_debit';
const TYPE_STRIPE_BALANCE_PAYMENT_DEBIT_REVERSAL = 'stripe_balance_payment_debit_reversal';
const TYPE_STRIPE_FEE = 'stripe_fee';
const TYPE_STRIPE_FX_FEE = 'stripe_fx_fee';
const TYPE_TAX_FEE = 'tax_fee';
const TYPE_TOPUP = 'topup';
const TYPE_TOPUP_REVERSAL = 'topup_reversal';
const TYPE_TRANSFER = 'transfer';
const TYPE_TRANSFER_CANCEL = 'transfer_cancel';
const TYPE_TRANSFER_FAILURE = 'transfer_failure';
const TYPE_TRANSFER_REFUND = 'transfer_refund';
/**
* Returns a list of transactions that have contributed to the Stripe account
* balance (e.g., charges, transfers, and so forth). The transactions are returned
* in sorted order, with the most recent transactions appearing first.
*
* Note that this endpoint was previously called “Balance history” and used the
* path <code>/v1/balance/history</code>.
*
* @param null|array{created?: array|int, currency?: string, ending_before?: string, expand?: string[], limit?: int, payout?: string, source?: string, starting_after?: string, type?: string} $params
* @param null|array|string $opts
*
* @return Collection<BalanceTransaction> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the balance transaction with the given ID.
*
* Note that this endpoint previously used the path
* <code>/v1/balance/history/:id</code>.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return BalanceTransaction
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,171 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* These bank accounts are payment methods on <code>Customer</code> objects.
*
* On the other hand <a href="/api#external_accounts">External Accounts</a> are transfer
* destinations on <code>Account</code> objects for connected accounts.
* They can be bank accounts or debit cards as well, and are documented in the links above.
*
* Related guide: <a href="/payments/bank-debits-transfers">Bank debits and transfers</a>
*
* @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|Account|string $account The account this bank account belongs to. Only applicable on Accounts (not customers or recipients) This property is only available when returned as an <a href="/api/external_account_bank_accounts/object">External Account</a> where <a href="/api/accounts/object#account_object-controller-is_controller">controller.is_controller</a> is <code>true</code>.
* @property null|string $account_holder_name The name of the person or business that owns the bank account.
* @property null|string $account_holder_type The type of entity that holds the account. This can be either <code>individual</code> or <code>company</code>.
* @property null|string $account_type The bank account type. This can only be <code>checking</code> or <code>savings</code> in most countries. In Japan, this can only be <code>futsu</code> or <code>toza</code>.
* @property null|string[] $available_payout_methods A set of available payout methods for this bank account. Only values from this set should be passed as the <code>method</code> when creating a payout.
* @property null|string $bank_name Name of the bank associated with the routing number (e.g., <code>WELLS FARGO</code>).
* @property string $country Two-letter ISO code representing the country the bank account is located in.
* @property string $currency Three-letter <a href="https://stripe.com/docs/payouts">ISO code for the currency</a> paid out to the bank account.
* @property null|Customer|string $customer The ID of the customer that the bank account is associated with.
* @property null|bool $default_for_currency Whether this bank account is the default external account for its currency.
* @property null|string $fingerprint Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
* @property null|(object{currently_due: null|string[], errors: null|(object{code: string, reason: string, requirement: string}&StripeObject)[], past_due: null|string[], pending_verification: null|string[]}&StripeObject) $future_requirements Information about the <a href="https://stripe.com/docs/connect/custom-accounts/future-requirements">upcoming new requirements for the bank account</a>, including what information needs to be collected, and by when.
* @property string $last4 The last four digits of the bank account number.
* @property null|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 null|(object{currently_due: null|string[], errors: null|(object{code: string, reason: string, requirement: string}&StripeObject)[], past_due: null|string[], pending_verification: null|string[]}&StripeObject) $requirements Information about the requirements for the bank account, including what information needs to be collected.
* @property null|string $routing_number The routing transit number for the bank account.
* @property string $status <p>For bank accounts, possible values are <code>new</code>, <code>validated</code>, <code>verified</code>, <code>verification_failed</code>, or <code>errored</code>. A bank account that hasn't had any activity or validation performed is <code>new</code>. If Stripe can determine that the bank account exists, its status will be <code>validated</code>. Note that there often isnt enough information to know (e.g., for smaller credit unions), and the validation is not always run. If customer bank account verification has succeeded, the bank account status will be <code>verified</code>. If the verification failed for any reason, such as microdeposit failure, the status will be <code>verification_failed</code>. If a payout sent to this bank account fails, we'll set the status to <code>errored</code> and will not continue to send <a href="https://stripe.com/docs/payouts#payout-schedule">scheduled payouts</a> until the bank details are updated.</p><p>For external accounts, possible values are <code>new</code>, <code>errored</code> and <code>verification_failed</code>. If a payout fails, the status is set to <code>errored</code> and scheduled payouts are stopped until account details are updated. In the US and India, if we can't <a href="https://support.stripe.com/questions/bank-account-ownership-verification">verify the owner of the bank account</a>, we'll set the status to <code>verification_failed</code>. Other validations aren't run against external accounts because they're only used for payouts. This means the other statuses don't apply.</p>
*/
class BankAccount extends ApiResource
{
const OBJECT_NAME = 'bank_account';
/**
* Delete a specified external account for a given account.
*
* @param null|array $params
* @param null|array|string $opts
*
* @return BankAccount the deleted resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* Possible string representations of the bank verification status.
*
* @see https://stripe.com/docs/api/external_account_bank_accounts/object#account_bank_account_object-status
*/
const STATUS_NEW = 'new';
const STATUS_VALIDATED = 'validated';
const STATUS_VERIFIED = 'verified';
const STATUS_VERIFICATION_FAILED = 'verification_failed';
const STATUS_ERRORED = 'errored';
/**
* @return string The instance URL for this resource. It needs to be special
* cased because it doesn't fit into the standard resource pattern.
*/
public function instanceUrl()
{
if ($this['customer']) {
$base = Customer::classUrl();
$parent = $this['customer'];
$path = 'sources';
} elseif ($this['account']) {
$base = Account::classUrl();
$parent = $this['account'];
$path = 'external_accounts';
} else {
$msg = 'Bank accounts cannot be accessed without a customer ID or account ID.';
throw new Exception\UnexpectedValueException($msg, null);
}
$parentExtn = \urlencode(Util\Util::utf8($parent));
$extn = \urlencode(Util\Util::utf8($this['id']));
return "{$base}/{$parentExtn}/{$path}/{$extn}";
}
/**
* @param array|string $_id
* @param null|array|string $_opts
*
* @throws Exception\BadMethodCallException
*/
public static function retrieve($_id, $_opts = null)
{
$msg = 'Bank accounts cannot be retrieved without a customer ID or '
. 'an account ID. Retrieve a bank account using '
. "`Customer::retrieveSource('customer_id', "
. "'bank_account_id')` or `Account::retrieveExternalAccount("
. "'account_id', 'bank_account_id')`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param string $_id
* @param null|array $_params
* @param null|array|string $_options
*
* @throws Exception\BadMethodCallException
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = 'Bank accounts cannot be updated without a customer ID or an '
. 'account ID. Update a bank account using '
. "`Customer::updateSource('customer_id', 'bank_account_id', "
. '$updateParams)` or `Account::updateExternalAccount('
. "'account_id', 'bank_account_id', \$updateParams)`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param null|array|string $opts
*
* @return static the saved resource
*
* @throws Exception\ApiErrorException if the request fails
*
* @deprecated The `save` method is deprecated and will be removed in a
* future major version of the library. Use the static method `update`
* on the resource instead.
*/
public function save($opts = null)
{
$params = $this->serializeParameters();
if (\count($params) > 0) {
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
$this->refreshFrom($response, $opts);
}
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return BankAccount the verified bank account
*
* @throws Exception\ApiErrorException if the request fails
*/
public function verify($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/verify';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@@ -0,0 +1,491 @@
<?php
namespace Stripe;
use Stripe\Util\Util;
class BaseStripeClient implements StripeClientInterface, StripeStreamingClientInterface
{
/** @var string default base URL for Stripe's API */
const DEFAULT_API_BASE = 'https://api.stripe.com';
/** @var string default base URL for Stripe's OAuth API */
const DEFAULT_CONNECT_BASE = 'https://connect.stripe.com';
/** @var string default base URL for Stripe's Files API */
const DEFAULT_FILES_BASE = 'https://files.stripe.com';
/** @var string default base URL for Stripe's Meter Events API */
const DEFAULT_METER_EVENTS_BASE = 'https://meter-events.stripe.com';
/** @var array<string, null|int|string> */
const DEFAULT_CONFIG = [
'api_key' => null,
'app_info' => null,
'client_id' => null,
'stripe_account' => null,
'stripe_context' => null,
'stripe_version' => \Stripe\Util\ApiVersion::CURRENT,
'api_base' => self::DEFAULT_API_BASE,
'connect_base' => self::DEFAULT_CONNECT_BASE,
'files_base' => self::DEFAULT_FILES_BASE,
'meter_events_base' => self::DEFAULT_METER_EVENTS_BASE,
// inherit from global
'max_network_retries' => null,
];
/** @var array<string, mixed> */
private $config;
/** @var \Stripe\Util\RequestOptions */
private $defaultOpts;
/**
* Initializes a new instance of the {@link BaseStripeClient} class.
*
* The constructor takes a single argument. The argument can be a string, in which case it
* should be the API key. It can also be an array with various configuration settings.
*
* Configuration settings include the following options:
*
* - api_key (null|string): the Stripe API key, to be used in regular API requests.
* - app_info (null|array): information to identify a plugin that integrates Stripe using this library.
* Expects: array{name: string, version?: string, url?: string, partner_id?: string}
* - client_id (null|string): the Stripe client ID, to be used in OAuth requests.
* - stripe_account (null|string): a Stripe account ID. If set, all requests sent by the client
* will automatically use the {@code Stripe-Account} header with that account ID.
* - stripe_context (null|string): a Stripe account or compartment ID. If set, all requests sent by the client
* will automatically use the {@code Stripe-Context} header with that ID.
* - stripe_version (null|string): a Stripe API version. If set, all requests sent by the client
* will include the {@code Stripe-Version} header with that API version.
* - max_network_retries (null|int): the number of times this client should retry API failures; defaults to 0.
*
* The following configuration settings are also available, though setting these should rarely be necessary
* (only useful if you want to send requests to a mock server like stripe-mock):
*
* - api_base (string): the base URL for regular API requests. Defaults to
* {@link DEFAULT_API_BASE}.
* - connect_base (string): the base URL for OAuth requests. Defaults to
* {@link DEFAULT_CONNECT_BASE}.
* - files_base (string): the base URL for file creation requests. Defaults to
* {@link DEFAULT_FILES_BASE}.
* - meter_events_base (string): the base URL for high throughput requests. Defaults to
* {@link DEFAULT_METER_EVENTS_BASE}.
*
* @param array<string, mixed>|string $config the API key as a string, or an array containing
* the client configuration settings
*/
public function __construct($config = [])
{
if (\is_string($config)) {
$config = ['api_key' => $config];
} elseif (!\is_array($config)) {
throw new Exception\InvalidArgumentException('$config must be a string or an array');
}
if (!\array_key_exists('max_network_retries', $config)) {
// if no value is passed, inherit the global value at the time of client creation
$config['max_network_retries'] = Stripe::getMaxNetworkRetries();
}
$config = \array_merge(self::DEFAULT_CONFIG, $config);
$this->validateConfig($config);
$this->config = $config;
$this->defaultOpts = \Stripe\Util\RequestOptions::parse([
'stripe_account' => $config['stripe_account'],
'stripe_context' => $config['stripe_context'],
'stripe_version' => $config['stripe_version'],
'max_network_retries' => $config['max_network_retries'],
]);
}
/**
* Gets the API key used by the client to send requests.
*
* @return null|string the API key used by the client to send requests
*/
public function getApiKey()
{
return $this->config['api_key'];
}
/**
* Gets the client ID used by the client in OAuth requests.
*
* @return null|string the client ID used by the client in OAuth requests
*/
public function getClientId()
{
return $this->config['client_id'];
}
/**
* Gets the base URL for Stripe's API.
*
* @return string the base URL for Stripe's API
*/
public function getApiBase()
{
return $this->config['api_base'];
}
/**
* Gets the base URL for Stripe's OAuth API.
*
* @return string the base URL for Stripe's OAuth API
*/
public function getConnectBase()
{
return $this->config['connect_base'];
}
/**
* Gets the base URL for Stripe's Files API.
*
* @return string the base URL for Stripe's Files API
*/
public function getFilesBase()
{
return $this->config['files_base'];
}
/**
* Gets the base URL for Stripe's Meter Events API.
*
* @return string the base URL for Stripe's Meter Events API
*/
public function getMeterEventsBase()
{
return $this->config['meter_events_base'];
}
/**
* Gets the configured number of retries.
*
* @return int the number of times this client will retry failed requests
*/
public function getMaxNetworkRetries()
{
return $this->config['max_network_retries'];
}
/**
* Gets the app info for this client.
*
* @return null|array information to identify a plugin that integrates Stripe using this library
*/
public function getAppInfo()
{
return $this->config['app_info'];
}
/**
* Sends a request to Stripe's API.
*
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
*
* @return StripeObject the object returned by Stripe's API
*/
public function request($method, $path, $params, $opts)
{
$defaultRequestOpts = $this->defaultOpts;
$apiMode = Util::getApiMode($path);
$opts = $defaultRequestOpts->merge($opts, true);
$baseUrl = $opts->apiBase ?: $this->getApiBase();
$requestor = new ApiRequestor($this->apiKeyForRequest($opts), $baseUrl, $this->getAppInfo());
list($response, $opts->apiKey) = $requestor->request($method, $path, $params, $opts->headers, $apiMode, ['stripe_client'], $opts->maxNetworkRetries);
$opts->discardNonPersistentHeaders();
$obj = Util::convertToStripeObject($response->json, $opts, $apiMode);
if (\is_array($obj)) {
// Edge case for v2 endpoints that return empty/void response
// Example: client->v2->billing->meterEventStream->create
$obj = new StripeObject();
}
$obj->setLastResponse($response);
return $obj;
}
/**
* Sends a raw request to Stripe's API. This is the lowest level method for interacting
* with the Stripe API. This method is useful for interacting with endpoints that are not
* covered yet in stripe-php.
*
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param null|array $params the parameters of the request
* @param array $opts the special modifiers of the request
* @param null|int $maxNetworkRetries
*
* @return ApiResponse
*/
public function rawRequest($method, $path, $params = null, $opts = [], $maxNetworkRetries = null)
{
if ('post' !== $method && null !== $params) {
throw new Exception\InvalidArgumentException('Error: rawRequest only supports $params on post requests. Please pass null and add your parameters to $path');
}
$apiMode = Util::getApiMode($path);
$headers = [];
if (\is_array($opts) && \array_key_exists('headers', $opts)) {
$headers = $opts['headers'] ?: [];
unset($opts['headers']);
}
if (\is_array($opts) && \array_key_exists('stripe_context', $opts)) {
$headers['Stripe-Context'] = $opts['stripe_context'];
unset($opts['stripe_context']);
}
$defaultRawRequestOpts = $this->defaultOpts;
$opts = $defaultRawRequestOpts->merge($opts, true);
// Concatenate $headers to $opts->headers, removing duplicates.
$opts->headers = \array_merge($opts->headers, $headers);
$baseUrl = $opts->apiBase ?: $this->getApiBase();
$requestor = new ApiRequestor($this->apiKeyForRequest($opts), $baseUrl);
list($response) = $requestor->request($method, $path, $params, $opts->headers, $apiMode, ['raw_request'], $maxNetworkRetries);
return $response;
}
/**
* Sends a request to Stripe's API, passing chunks of the streamed response
* into a user-provided $readBodyChunkCallable callback.
*
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param callable $readBodyChunkCallable a function that will be called
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
*
* with chunks of bytes from the body if the request is successful
*/
public function requestStream($method, $path, $readBodyChunkCallable, $params, $opts)
{
$opts = $this->defaultOpts->merge($opts, true);
$baseUrl = $opts->apiBase ?: $this->getApiBase();
$requestor = new ApiRequestor($this->apiKeyForRequest($opts), $baseUrl, $this->getAppInfo());
$apiMode = Util::getApiMode($path);
list($response, $opts->apiKey) = $requestor->requestStream($method, $path, $readBodyChunkCallable, $params, $opts->headers, $apiMode, ['stripe_client']);
}
/**
* Sends a request to Stripe's API.
*
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
*
* @return Collection|V2\Collection of ApiResources
*/
public function requestCollection($method, $path, $params, $opts)
{
$obj = $this->request($method, $path, $params, $opts);
$apiMode = Util::getApiMode($path);
if ('v1' === $apiMode) {
if (!$obj instanceof Collection) {
$received_class = \get_class($obj);
$msg = "Expected to receive `Stripe\\Collection` object from Stripe API. Instead received `{$received_class}`.";
throw new Exception\UnexpectedValueException($msg);
}
$obj->setFilters($params);
} else {
if (!$obj instanceof V2\Collection) {
$received_class = \get_class($obj);
$msg = "Expected to receive `Stripe\\V2\\Collection` object from Stripe API. Instead received `{$received_class}`.";
throw new Exception\UnexpectedValueException($msg);
}
}
return $obj;
}
/**
* Sends a request to Stripe's API.
*
* @param 'delete'|'get'|'post' $method the HTTP method
* @param string $path the path of the request
* @param array $params the parameters of the request
* @param array|\Stripe\Util\RequestOptions $opts the special modifiers of the request
*
* @return SearchResult of ApiResources
*/
public function requestSearchResult($method, $path, $params, $opts)
{
$obj = $this->request($method, $path, $params, $opts);
if (!$obj instanceof SearchResult) {
$received_class = \get_class($obj);
$msg = "Expected to receive `Stripe\\SearchResult` object from Stripe API. Instead received `{$received_class}`.";
throw new Exception\UnexpectedValueException($msg);
}
$obj->setFilters($params);
return $obj;
}
/**
* @param \Stripe\Util\RequestOptions $opts
*
* @return string
*
* @throws Exception\AuthenticationException
*/
private function apiKeyForRequest($opts)
{
$apiKey = $opts->apiKey ?: $this->getApiKey();
if (null === $apiKey) {
$msg = 'No API key provided. Set your API key when constructing the '
. 'StripeClient instance, or provide it on a per-request basis '
. 'using the `api_key` key in the $opts argument.';
throw new Exception\AuthenticationException($msg);
}
return $apiKey;
}
/**
* @param array<string, mixed> $config
*
* @throws Exception\InvalidArgumentException
*/
private function validateConfig($config)
{
// api_key
if (null !== $config['api_key'] && !\is_string($config['api_key'])) {
throw new Exception\InvalidArgumentException('api_key must be null or a string');
}
if (null !== $config['api_key'] && ('' === $config['api_key'])) {
$msg = 'api_key cannot be the empty string';
throw new Exception\InvalidArgumentException($msg);
}
if (null !== $config['api_key'] && \preg_match('/\s/', $config['api_key'])) {
$msg = 'api_key cannot contain whitespace';
throw new Exception\InvalidArgumentException($msg);
}
// client_id
if (null !== $config['client_id'] && !\is_string($config['client_id'])) {
throw new Exception\InvalidArgumentException('client_id must be null or a string');
}
// stripe_account
if (null !== $config['stripe_account'] && !\is_string($config['stripe_account'])) {
throw new Exception\InvalidArgumentException('stripe_account must be null or a string');
}
// stripe_context
if (null !== $config['stripe_context'] && !\is_string($config['stripe_context'])) {
throw new Exception\InvalidArgumentException('stripe_context must be null or a string');
}
// stripe_version
if (null !== $config['stripe_version'] && !\is_string($config['stripe_version'])) {
throw new Exception\InvalidArgumentException('stripe_version must be null or a string');
}
// api_base
if (!\is_string($config['api_base'])) {
throw new Exception\InvalidArgumentException('api_base must be a string');
}
// connect_base
if (!\is_string($config['connect_base'])) {
throw new Exception\InvalidArgumentException('connect_base must be a string');
}
// files_base
if (!\is_string($config['files_base'])) {
throw new Exception\InvalidArgumentException('files_base must be a string');
}
// app info
if (null !== $config['app_info'] && !\is_array($config['app_info'])) {
throw new Exception\InvalidArgumentException('app_info must be an array');
}
// max_network_retries
if (!\is_int($config['max_network_retries'])) {
throw new Exception\InvalidArgumentException('max_network_retries must an int');
}
$appInfoKeys = ['name', 'version', 'url', 'partner_id'];
if (null !== $config['app_info'] && array_diff_key($config['app_info'], array_flip($appInfoKeys))) {
$msg = 'app_info must be of type array{name: string, version?: string, url?: string, partner_id?: string}';
throw new Exception\InvalidArgumentException($msg);
}
// check absence of extra keys
$extraConfigKeys = \array_diff(\array_keys($config), \array_keys(self::DEFAULT_CONFIG));
if (!empty($extraConfigKeys)) {
// Wrap in single quote to more easily catch trailing spaces errors
$invalidKeys = "'" . \implode("', '", $extraConfigKeys) . "'";
throw new Exception\InvalidArgumentException('Found unknown key(s) in configuration array: ' . $invalidKeys);
}
}
/**
* Deserializes the raw JSON string returned by rawRequest into a similar class.
*
* @param string $json
* @param 'v1'|'v2' $apiMode
*
* @return StripeObject
* */
public function deserialize($json, $apiMode = 'v1')
{
return Util::convertToStripeObject(\json_decode($json, true), [], $apiMode);
}
/**
* Returns a V2\Events instance using the provided JSON payload. Throws an
* Exception\UnexpectedValueException if the payload is not valid JSON, and
* an Exception\SignatureVerificationException if the signature
* verification fails for any reason.
*
* @param string $payload the payload sent by Stripe
* @param string $sigHeader the contents of the signature header sent by
* Stripe
* @param string $secret secret used to generate the signature
* @param int $tolerance maximum difference allowed between the header's
* timestamp and the current time. Defaults to 300 seconds (5 min)
*
* @return ThinEvent
*
* @throws Exception\SignatureVerificationException if the verification fails
* @throws Exception\UnexpectedValueException if the payload is not valid JSON,
*/
public function parseThinEvent($payload, $sigHeader, $secret, $tolerance = Webhook::DEFAULT_TOLERANCE)
{
$eventData = Util::utf8($payload);
WebhookSignature::verifyHeader($payload, $sigHeader, $secret, $tolerance);
try {
return Util::json_decode_thin_event_object(
$eventData,
'\Stripe\ThinEvent'
);
} catch (\ReflectionException $e) {
// Fail gracefully
return new ThinEvent();
}
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace Stripe;
/**
* Interface for a Stripe client.
*/
interface BaseStripeClientInterface
{
/**
* Gets the API key used by the client to send requests.
*
* @return null|string the API key used by the client to send requests
*/
public function getApiKey();
/**
* Gets the client ID used by the client in OAuth requests.
*
* @return null|string the client ID used by the client in OAuth requests
*/
public function getClientId();
/**
* Gets the base URL for Stripe's API.
*
* @return string the base URL for Stripe's API
*/
public function getApiBase();
/**
* Gets the base URL for Stripe's OAuth API.
*
* @return string the base URL for Stripe's OAuth API
*/
public function getConnectBase();
/**
* Gets the base URL for Stripe's Files API.
*
* @return string the base URL for Stripe's Files API
*/
public function getFilesBase();
/**
* Gets the base URL for Stripe's Meter Events API.
*
* @return string the base URL for Stripe's Meter Events API
*/
public function getMeterEventsBase();
}

View File

@@ -0,0 +1,134 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
*
* @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 string $alert_type Defines the type of the alert.
* @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 null|string $status Status of the alert. This can be active, inactive or archived.
* @property string $title Title of the alert.
* @property null|(object{filters: null|((object{customer: null|string|\Stripe\Customer, type: string}&\Stripe\StripeObject))[], gte: int, meter: Meter|string, recurrence: string}&\Stripe\StripeObject) $usage_threshold Encapsulates configuration of the alert to monitor usage on a specific <a href="https://stripe.com/docs/api/billing/meter">Billing Meter</a>.
*/
class Alert extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.alert';
const STATUS_ACTIVE = 'active';
const STATUS_ARCHIVED = 'archived';
const STATUS_INACTIVE = 'inactive';
/**
* Creates a billing alert.
*
* @param null|array{alert_type: string, expand?: string[], title: string, usage_threshold?: array{filters?: array{customer?: string, type: string}[], gte: int, meter: string, recurrence: string}} $params
* @param null|array|string $options
*
* @return Alert the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Lists billing active and inactive alerts.
*
* @param null|array{alert_type?: string, ending_before?: string, expand?: string[], limit?: int, meter?: string, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Alert> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a billing alert given an ID.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Alert
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Alert the activated alert
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function activate($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/activate';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Alert the archived alert
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function archive($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/archive';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Alert the deactivated alert
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function deactivate($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/deactivate';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@@ -0,0 +1,18 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property Alert $alert A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $customer ID of customer for which the alert triggered
* @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 $value The value triggering the alert
*/
class AlertTriggered extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.alert_triggered';
}

View File

@@ -0,0 +1,36 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* Indicates the billing credit balance for billing credits granted to a customer.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property ((object{available_balance: (object{monetary: null|(object{currency: string, value: int}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject), ledger_balance: (object{monetary: null|(object{currency: string, value: int}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject)}&\Stripe\StripeObject))[] $balances The billing credit balances. One entry per credit grant currency. If a customer only has credit grants in a single currency, then this will have a single balance entry.
* @property string|\Stripe\Customer $customer The customer the balance is for.
* @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 CreditBalanceSummary extends \Stripe\SingletonApiResource
{
const OBJECT_NAME = 'billing.credit_balance_summary';
/**
* Retrieves the credit balance summary for a customer.
*
* @param null|array|string $opts
*
* @return CreditBalanceSummary
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static(null, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,63 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* A credit balance transaction is a resource representing a transaction (either a credit or a debit) against an existing credit grant.
*
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|(object{amount: (object{monetary: null|(object{currency: string, value: int}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject), credits_application_invoice_voided: null|(object{invoice: string|\Stripe\Invoice, invoice_line_item: string}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject) $credit Credit details for this credit balance transaction. Only present if type is <code>credit</code>.
* @property CreditGrant|string $credit_grant The credit grant associated with this credit balance transaction.
* @property null|(object{amount: (object{monetary: null|(object{currency: string, value: int}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject), credits_applied: null|(object{invoice: string|\Stripe\Invoice, invoice_line_item: string}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject) $debit Debit details for this credit balance transaction. Only present if type is <code>debit</code>.
* @property int $effective_at The effective time of this credit balance transaction.
* @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 null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this credit balance transaction belongs to.
* @property null|string $type The type of credit balance transaction (credit or debit).
*/
class CreditBalanceTransaction extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.credit_balance_transaction';
const TYPE_CREDIT = 'credit';
const TYPE_DEBIT = 'debit';
/**
* Retrieve a list of credit balance transactions.
*
* @param null|array{credit_grant?: string, customer: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<CreditBalanceTransaction> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a credit balance transaction.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return CreditBalanceTransaction
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,152 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* A credit grant is an API resource that documents the allocation of some billing credits to a customer.
*
* Related guide: <a href="https://docs.stripe.com/billing/subscriptions/usage-based/billing-credits">Billing credits</a>
*
* @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 (object{monetary: null|(object{currency: string, value: int}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject) $amount
* @property (object{scope: (object{price_type?: string, prices?: ((object{id: null|string}&\Stripe\StripeObject))[]}&\Stripe\StripeObject)}&\Stripe\StripeObject) $applicability_config
* @property string $category The category of this credit grant. This is for tracking purposes and isn't displayed to the customer.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string|\Stripe\Customer $customer ID of the customer receiving the billing credits.
* @property null|int $effective_at The time when the billing credits become effective-when they're eligible for use.
* @property null|int $expires_at The time when the billing credits expire. If not present, the billing credits don't 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.
* @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 null|string $name A descriptive name shown in dashboard.
* @property null|int $priority The priority for applying this credit grant. The highest priority is 0 and the lowest is 100.
* @property null|string|\Stripe\TestHelpers\TestClock $test_clock ID of the test clock this credit grant belongs to.
* @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
* @property null|int $voided_at The time when this credit grant was voided. If not present, the credit grant hasn't been voided.
*/
class CreditGrant extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.credit_grant';
use \Stripe\ApiOperations\Update;
const CATEGORY_PAID = 'paid';
const CATEGORY_PROMOTIONAL = 'promotional';
/**
* Creates a credit grant.
*
* @param null|array{amount: array{monetary?: array{currency: string, value: int}, type: string}, applicability_config: array{scope: array{price_type?: string, prices?: array{id: string}[]}}, category: string, customer: string, effective_at?: int, expand?: string[], expires_at?: int, metadata?: array<string, string>, name?: string, priority?: int} $params
* @param null|array|string $options
*
* @return CreditGrant the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Retrieve a list of credit grants.
*
* @param null|array{customer?: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<CreditGrant> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a credit grant.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return CreditGrant
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates a credit grant.
*
* @param string $id the ID of the resource to update
* @param null|array{expand?: string[], expires_at?: null|int, metadata?: array<string, string>} $params
* @param null|array|string $opts
*
* @return CreditGrant the updated resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $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
*
* @return CreditGrant the expired credit grant
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function expire($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/expire';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return CreditGrant the voided credit grant
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function voidGrant($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/void';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@@ -0,0 +1,169 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* Meters specify how to aggregate meter events over a billing period. Meter events represent the actions that customers take in your system. Meters attach to prices and form the basis of the bill.
*
* Related guide: <a href="https://docs.stripe.com/billing/subscriptions/usage-based">Usage based billing</a>
*
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property (object{event_payload_key: string, type: string}&\Stripe\StripeObject) $customer_mapping
* @property (object{formula: string}&\Stripe\StripeObject) $default_aggregation
* @property string $display_name The meter's name.
* @property string $event_name The name of the meter event to record usage for. Corresponds with the <code>event_name</code> field on meter events.
* @property null|string $event_time_window The time window to pre-aggregate meter events for, if any.
* @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 string $status The meter's status.
* @property (object{deactivated_at: null|int}&\Stripe\StripeObject) $status_transitions
* @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
* @property (object{event_payload_key: string}&\Stripe\StripeObject) $value_settings
*/
class Meter extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.meter';
use \Stripe\ApiOperations\NestedResource;
use \Stripe\ApiOperations\Update;
const EVENT_TIME_WINDOW_DAY = 'day';
const EVENT_TIME_WINDOW_HOUR = 'hour';
const STATUS_ACTIVE = 'active';
const STATUS_INACTIVE = 'inactive';
/**
* Creates a billing meter.
*
* @param null|array{customer_mapping?: array{event_payload_key: string, type: string}, default_aggregation: array{formula: string}, display_name: string, event_name: string, event_time_window?: string, expand?: string[], value_settings?: array{event_payload_key: string}} $params
* @param null|array|string $options
*
* @return Meter the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Retrieve a list of billing meters.
*
* @param null|array{ending_before?: string, expand?: string[], limit?: int, starting_after?: string, status?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Meter> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a billing meter given an ID.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Meter
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates a billing meter.
*
* @param string $id the ID of the resource to update
* @param null|array{display_name?: string, expand?: string[]} $params
* @param null|array|string $opts
*
* @return Meter the updated resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $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
*
* @return Meter the deactivated meter
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function deactivate($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/deactivate';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Meter the reactivated meter
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function reactivate($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/reactivate';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
const PATH_EVENT_SUMMARIES = '/event_summaries';
/**
* @param string $id the ID of the meter on which to retrieve the meter event summaries
* @param null|array $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<MeterEventSummary> the list of meter event summaries
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function allEventSummaries($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_EVENT_SUMMARIES, $params, $opts);
}
}

View File

@@ -0,0 +1,43 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* Meter events represent actions that customers take in your system. You can use meter events to bill a customer based on their usage. Meter events are associated with billing meters, which define both the contents of the events payload and how to aggregate those events.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $event_name The name of the meter event. Corresponds with the <code>event_name</code> field on a meter.
* @property string $identifier A unique identifier for the event.
* @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 $payload The payload of the event. This contains the fields corresponding to a meter's <code>customer_mapping.event_payload_key</code> (default is <code>stripe_customer_id</code>) and <code>value_settings.event_payload_key</code> (default is <code>value</code>). Read more about the <a href="https://stripe.com/docs/billing/subscriptions/usage-based/recording-usage#payload-key-overrides">payload</a>.
* @property int $timestamp The timestamp passed in when creating the event. Measured in seconds since the Unix epoch.
*/
class MeterEvent extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.meter_event';
/**
* Creates a billing meter event.
*
* @param null|array{event_name: string, expand?: string[], identifier?: string, payload: array<string, string>, timestamp?: int} $params
* @param null|array|string $options
*
* @return MeterEvent the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,45 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* A billing meter event adjustment is a resource that allows you to cancel a meter event. For example, you might create a billing meter event adjustment to cancel a meter event that was created in error or attached to the wrong customer.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property null|(object{identifier: null|string}&\Stripe\StripeObject) $cancel Specifies which event to cancel.
* @property string $event_name The name of the meter event. Corresponds with the <code>event_name</code> field on a meter.
* @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 string $status The meter event adjustment's status.
* @property string $type Specifies whether to cancel a single event or a range of events for a time period. Time period cancellation is not supported yet.
*/
class MeterEventAdjustment extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.meter_event_adjustment';
const STATUS_COMPLETE = 'complete';
const STATUS_PENDING = 'pending';
/**
* Creates a billing meter event adjustment.
*
* @param null|array{cancel?: array{identifier?: string}, event_name: string, expand?: string[], type: string} $params
* @param null|array|string $options
*
* @return MeterEventAdjustment the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,24 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Billing;
/**
* A billing meter event summary represents an aggregated view of a customer's billing meter events within a specified timeframe. It indicates how much
* usage was accrued by a customer for that period.
*
* Note: Meters events are aggregated asynchronously so the meter event summaries provide an eventually consistent view of the reported usage.
*
* @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 float $aggregated_value Aggregated value of all the events within <code>start_time</code> (inclusive) and <code>end_time</code> (inclusive). The aggregation strategy is defined on meter via <code>default_aggregation</code>.
* @property int $end_time End timestamp for this event summary (exclusive). Must be aligned with minute boundaries.
* @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 string $meter The meter associated with this event summary.
* @property int $start_time Start timestamp for this event summary (inclusive). Must be aligned with minute boundaries.
*/
class MeterEventSummary extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing.meter_event_summary';
}

View File

@@ -0,0 +1,113 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\BillingPortal;
/**
* A portal configuration describes the functionality and behavior of a portal session.
*
* @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 bool $active Whether the configuration is active and can be used to create portal sessions.
* @property null|string|\Stripe\Application $application ID of the Connect Application that created the configuration.
* @property (object{headline: null|string, privacy_policy_url: null|string, terms_of_service_url: null|string}&\Stripe\StripeObject) $business_profile
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|string $default_return_url The default URL to redirect customers to when they click on the portal's link to return to your website. This can be <a href="https://stripe.com/docs/api/customer_portal/sessions/create#create_portal_session-return_url">overriden</a> when creating the session.
* @property (object{customer_update: (object{allowed_updates: string[], enabled: bool}&\Stripe\StripeObject), invoice_history: (object{enabled: bool}&\Stripe\StripeObject), payment_method_update: (object{enabled: bool}&\Stripe\StripeObject), subscription_cancel: (object{cancellation_reason: (object{enabled: bool, options: string[]}&\Stripe\StripeObject), enabled: bool, mode: string, proration_behavior: string}&\Stripe\StripeObject), subscription_update: (object{default_allowed_updates: string[], enabled: bool, products?: null|(object{prices: string[], product: string}&\Stripe\StripeObject)[], proration_behavior: string, schedule_at_period_end: (object{conditions: (object{type: string}&\Stripe\StripeObject)[]}&\Stripe\StripeObject)}&\Stripe\StripeObject)}&\Stripe\StripeObject) $features
* @property bool $is_default Whether the configuration is the default. If <code>true</code>, this configuration can be managed in the Dashboard and portal sessions will use this configuration unless it is overriden when creating the session.
* @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 (object{enabled: bool, url: null|string}&\Stripe\StripeObject) $login_page
* @property null|\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 int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
*/
class Configuration extends \Stripe\ApiResource
{
const OBJECT_NAME = 'billing_portal.configuration';
use \Stripe\ApiOperations\Update;
/**
* Creates a configuration that describes the functionality and behavior of a
* PortalSession.
*
* @param null|array{business_profile?: array{headline?: null|string, privacy_policy_url?: string, terms_of_service_url?: string}, default_return_url?: null|string, expand?: string[], features: array{customer_update?: array{allowed_updates?: null|string[], enabled: bool}, invoice_history?: array{enabled: bool}, payment_method_update?: array{enabled: bool}, subscription_cancel?: array{cancellation_reason?: array{enabled: bool, options: null|string[]}, enabled: bool, mode?: string, proration_behavior?: string}, subscription_update?: array{default_allowed_updates?: null|string[], enabled: bool, products?: null|array{prices: string[], product: string}[], proration_behavior?: string, schedule_at_period_end?: array{conditions?: array{type: string}[]}}}, login_page?: array{enabled: bool}, metadata?: array<string, string>} $params
* @param null|array|string $options
*
* @return Configuration the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Returns a list of configurations that describe the functionality of the customer
* portal.
*
* @param null|array{active?: bool, ending_before?: string, expand?: string[], is_default?: bool, limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Configuration> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a configuration that describes the functionality of the customer
* portal.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Configuration
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates a configuration that describes the functionality of the customer portal.
*
* @param string $id the ID of the resource to update
* @param null|array{active?: bool, business_profile?: array{headline?: null|string, privacy_policy_url?: null|string, terms_of_service_url?: null|string}, default_return_url?: null|string, expand?: string[], features?: array{customer_update?: array{allowed_updates?: null|string[], enabled?: bool}, invoice_history?: array{enabled: bool}, payment_method_update?: array{enabled: bool}, subscription_cancel?: array{cancellation_reason?: array{enabled: bool, options?: null|string[]}, enabled?: bool, mode?: string, proration_behavior?: string}, subscription_update?: array{default_allowed_updates?: null|string[], enabled?: bool, products?: null|array{prices: string[], product: string}[], proration_behavior?: string, schedule_at_period_end?: array{conditions?: null|array{type: string}[]}}}, login_page?: array{enabled: bool}, metadata?: null|array<string, string>} $params
* @param null|array|string $opts
*
* @return Configuration the updated resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,60 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\BillingPortal;
/**
* The Billing customer portal is a Stripe-hosted UI for subscription and
* billing management.
*
* A portal configuration describes the functionality and features that you
* want to provide to your customers through the portal.
*
* A portal session describes the instantiation of the customer portal for
* a particular customer. By visiting the session's URL, the customer
* can manage their subscriptions and billing details. For security reasons,
* sessions are short-lived and will expire if the customer does not visit the URL.
* Create sessions on-demand when customers intend to manage their subscriptions
* and billing details.
*
* Related guide: <a href="/customer-management">Customer management</a>
*
* @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 Configuration|string $configuration The configuration used by this session, describing the features available.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $customer The ID of the customer for this session.
* @property null|(object{after_completion: (object{hosted_confirmation: null|(object{custom_message: null|string}&\Stripe\StripeObject), redirect: null|(object{return_url: string}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject), subscription_cancel: null|(object{retention: null|(object{coupon_offer: null|(object{coupon: string}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject), subscription: string}&\Stripe\StripeObject), subscription_update: null|(object{subscription: string}&\Stripe\StripeObject), subscription_update_confirm: null|(object{discounts: null|((object{coupon: null|string, promotion_code: null|string}&\Stripe\StripeObject))[], items: ((object{id: null|string, price: null|string, quantity?: int}&\Stripe\StripeObject))[], subscription: string}&\Stripe\StripeObject), type: string}&\Stripe\StripeObject) $flow Information about a specific flow for the customer to go through. See the <a href="https://stripe.com/docs/customer-management/portal-deep-links">docs</a> to learn more about using customer portal deep links and flows.
* @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 null|string $locale The IETF language tag of the locale Customer Portal is displayed in. If blank or auto, the customers <code>preferred_locales</code> or browsers 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 <code>on_behalf_of</code> account appear in the portal. For more information, see the <a href="https://stripe.com/docs/connect/separate-charges-and-transfers#settlement-merchant">docs</a>. Use the <a href="https://stripe.com/docs/api/accounts/object#account_object-settings-branding">Accounts API</a> to modify the <code>on_behalf_of</code> account's branding settings, which the portal displays.
* @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
{
const OBJECT_NAME = 'billing_portal.session';
/**
* Creates a session of the customer portal.
*
* @param null|array{configuration?: string, customer: string, expand?: string[], flow_data?: array{after_completion?: array{hosted_confirmation?: array{custom_message?: string}, redirect?: array{return_url: string}, type: string}, subscription_cancel?: array{retention?: array{coupon_offer: array{coupon: string}, type: string}, subscription: string}, subscription_update?: array{subscription: string}, subscription_update_confirm?: array{discounts?: array{coupon?: string, promotion_code?: string}[], items: array{id: string, price?: string, quantity?: int}[], subscription: string}, type: string}, locale?: string, on_behalf_of?: string, return_url?: string} $params
* @param null|array|string $options
*
* @return Session the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,107 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* This is an object representing a capability for a Stripe account.
*
* Related guide: <a href="https://stripe.com/docs/connect/account-capabilities">Account capabilities</a>
*
* @property string $id The identifier for the capability.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property Account|string $account The account for which the capability enables functionality.
* @property null|(object{alternatives: null|(object{alternative_fields_due: string[], original_fields_due: string[]}&StripeObject)[], current_deadline: null|int, currently_due: string[], disabled_reason: null|string, errors: (object{code: string, reason: string, requirement: string}&StripeObject)[], eventually_due: string[], past_due: string[], pending_verification: string[]}&StripeObject) $future_requirements
* @property bool $requested Whether the capability has been requested.
* @property null|int $requested_at Time at which the capability was requested. Measured in seconds since the Unix epoch.
* @property null|(object{alternatives: null|(object{alternative_fields_due: string[], original_fields_due: string[]}&StripeObject)[], current_deadline: null|int, currently_due: string[], disabled_reason: null|string, errors: (object{code: string, reason: string, requirement: string}&StripeObject)[], eventually_due: string[], past_due: string[], pending_verification: string[]}&StripeObject) $requirements
* @property string $status The status of the capability.
*/
class Capability extends ApiResource
{
const OBJECT_NAME = 'capability';
const STATUS_ACTIVE = 'active';
const STATUS_INACTIVE = 'inactive';
const STATUS_PENDING = 'pending';
const STATUS_UNREQUESTED = 'unrequested';
/**
* @return string the API URL for this Stripe account reversal
*/
public function instanceUrl()
{
$id = $this['id'];
$account = $this['account'];
if (!$id) {
throw new Exception\UnexpectedValueException(
'Could not determine which URL to request: '
. "class instance has invalid ID: {$id}",
null
);
}
$id = Util\Util::utf8($id);
$account = Util\Util::utf8($account);
$base = Account::classUrl();
$accountExtn = \urlencode($account);
$extn = \urlencode($id);
return "{$base}/{$accountExtn}/capabilities/{$extn}";
}
/**
* @param array|string $_id
* @param null|array|string $_opts
*
* @throws Exception\BadMethodCallException
*/
public static function retrieve($_id, $_opts = null)
{
$msg = 'Capabilities cannot be retrieved without an account ID. '
. 'Retrieve a capability using `Account::retrieveCapability('
. "'account_id', 'capability_id')`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param string $_id
* @param null|array $_params
* @param null|array|string $_options
*
* @throws Exception\BadMethodCallException
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = 'Capabilities cannot be updated without an account ID. '
. 'Update a capability using `Account::updateCapability('
. "'account_id', 'capability_id', \$updateParams)`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param null|array|string $opts
*
* @return static the saved resource
*
* @throws Exception\ApiErrorException if the request fails
*
* @deprecated The `save` method is deprecated and will be removed in a
* future major version of the library. Use the static method `update`
* on the resource instead.
*/
public function save($opts = null)
{
$params = $this->serializeParameters();
if (\count($params) > 0) {
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
$this->refreshFrom($response, $opts);
}
return $this;
}
}

188
vendor/stripe/stripe-php/lib/Card.php vendored Normal file
View File

@@ -0,0 +1,188 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* You can store multiple cards on a customer in order to charge the customer
* later. You can also store multiple debit cards on a recipient in order to
* transfer to those cards later.
*
* Related guide: <a href="https://stripe.com/docs/sources/cards">Card payments with Sources</a>
*
* @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|Account|string $account
* @property null|string $address_city City/District/Suburb/Town/Village.
* @property null|string $address_country Billing address country, if provided when creating card.
* @property null|string $address_line1 Address line 1 (Street address/PO Box/Company name).
* @property null|string $address_line1_check If <code>address_line1</code> was provided, results of the check: <code>pass</code>, <code>fail</code>, <code>unavailable</code>, or <code>unchecked</code>.
* @property null|string $address_line2 Address line 2 (Apartment/Suite/Unit/Building).
* @property null|string $address_state State/County/Province/Region.
* @property null|string $address_zip ZIP or postal code.
* @property null|string $address_zip_check If <code>address_zip</code> was provided, results of the check: <code>pass</code>, <code>fail</code>, <code>unavailable</code>, or <code>unchecked</code>.
* @property null|string $allow_redisplay This field indicates whether this payment method can be shown again to its customer in a checkout flow. Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow. The field defaults to “unspecified”.
* @property null|string[] $available_payout_methods A set of available payout methods for this card. Only values from this set should be passed as the <code>method</code> when creating a payout.
* @property string $brand Card brand. Can be <code>American Express</code>, <code>Diners Club</code>, <code>Discover</code>, <code>Eftpos Australia</code>, <code>Girocard</code>, <code>JCB</code>, <code>MasterCard</code>, <code>UnionPay</code>, <code>Visa</code>, or <code>Unknown</code>.
* @property null|string $country Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you've collected.
* @property null|string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO code for currency</a> in lowercase. Must be a <a href="https://docs.stripe.com/currencies">supported currency</a>. Only applicable on accounts (not customers or recipients). The card can be used as a transfer destination for funds in this currency. This property is only available when returned as an <a href="/api/external_account_cards/object">External Account</a> where <a href="/api/accounts/object#account_object-controller-is_controller">controller.is_controller</a> is <code>true</code>.
* @property null|Customer|string $customer The customer that this card belongs to. This attribute will not be in the card object if the card belongs to an account or recipient instead.
* @property null|string $cvc_check If a CVC was provided, results of the check: <code>pass</code>, <code>fail</code>, <code>unavailable</code>, or <code>unchecked</code>. A result of unchecked indicates that CVC was provided but hasn't been checked yet. Checks are typically performed when attaching a card to a Customer object, or when creating a charge. For more details, see <a href="https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge">Check if a card is valid without a charge</a>.
* @property null|bool $default_for_currency Whether this card is the default external account for its currency. This property is only available for accounts where <a href="/api/accounts/object#account_object-controller-requirement_collection">controller.requirement_collection</a> is <code>application</code>, which includes Custom accounts.
* @property null|string $dynamic_last4 (For tokenized numbers only.) The last four digits of the device account number.
* @property int $exp_month Two-digit number representing the card's expiration month.
* @property int $exp_year Four-digit number representing the card's expiration year.
* @property null|string $fingerprint <p>Uniquely identifies this particular card number. You can use this attribute to check whether two customers whove signed up with you are using the same card number, for example. For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number.</p><p><em>As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.</em></p>
* @property string $funding Card funding type. Can be <code>credit</code>, <code>debit</code>, <code>prepaid</code>, or <code>unknown</code>.
* @property string $last4 The last four digits of the card.
* @property null|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 null|string $name Cardholder name.
* @property null|(object{preferred: null|string}&StripeObject) $networks
* @property null|string $regulated_status Status of a card based on the card issuer.
* @property null|string $status For external accounts that are cards, possible values are <code>new</code> and <code>errored</code>. If a payout fails, the status is set to <code>errored</code> and <a href="https://stripe.com/docs/payouts#payout-schedule">scheduled payouts</a> are stopped until account details are updated.
* @property null|string $tokenization_method If the card number is tokenized, this is the method that was used. Can be <code>android_pay</code> (includes Google Pay), <code>apple_pay</code>, <code>masterpass</code>, <code>visa_checkout</code>, or null.
*/
class Card extends ApiResource
{
const OBJECT_NAME = 'card';
const ALLOW_REDISPLAY_ALWAYS = 'always';
const ALLOW_REDISPLAY_LIMITED = 'limited';
const ALLOW_REDISPLAY_UNSPECIFIED = 'unspecified';
const REGULATED_STATUS_REGULATED = 'regulated';
const REGULATED_STATUS_UNREGULATED = 'unregulated';
/**
* Delete a specified external account for a given account.
*
* @param null|array $params
* @param null|array|string $opts
*
* @return Card the deleted resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* Possible string representations of the CVC check status.
*
* @see https://stripe.com/docs/api/cards/object#card_object-cvc_check
*/
const CVC_CHECK_FAIL = 'fail';
const CVC_CHECK_PASS = 'pass';
const CVC_CHECK_UNAVAILABLE = 'unavailable';
const CVC_CHECK_UNCHECKED = 'unchecked';
/**
* Possible string representations of the funding of the card.
*
* @see https://stripe.com/docs/api/cards/object#card_object-funding
*/
const FUNDING_CREDIT = 'credit';
const FUNDING_DEBIT = 'debit';
const FUNDING_PREPAID = 'prepaid';
const FUNDING_UNKNOWN = 'unknown';
/**
* Possible string representations of the tokenization method when using Apple Pay or Google Pay.
*
* @see https://stripe.com/docs/api/cards/object#card_object-tokenization_method
*/
const TOKENIZATION_METHOD_APPLE_PAY = 'apple_pay';
const TOKENIZATION_METHOD_GOOGLE_PAY = 'google_pay';
/**
* @return string The instance URL for this resource. It needs to be special
* cased because cards are nested resources that may belong to different
* top-level resources.
*/
public function instanceUrl()
{
if ($this['customer']) {
$base = Customer::classUrl();
$parent = $this['customer'];
$path = 'sources';
} elseif ($this['account']) {
$base = Account::classUrl();
$parent = $this['account'];
$path = 'external_accounts';
} else {
$msg = 'Cards cannot be accessed without a customer ID, or account ID.';
throw new Exception\UnexpectedValueException($msg);
}
$parentExtn = \urlencode(Util\Util::utf8($parent));
$extn = \urlencode(Util\Util::utf8($this['id']));
return "{$base}/{$parentExtn}/{$path}/{$extn}";
}
/**
* @param array|string $_id
* @param null|array|string $_opts
*
* @throws Exception\BadMethodCallException
*/
public static function retrieve($_id, $_opts = null)
{
$msg = 'Cards cannot be retrieved without a customer ID or an '
. 'account ID. Retrieve a card using '
. "`Customer::retrieveSource('customer_id', 'card_id')` or "
. "`Account::retrieveExternalAccount('account_id', 'card_id')`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param string $_id
* @param null|array $_params
* @param null|array|string $_options
*
* @throws Exception\BadMethodCallException
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = 'Cards cannot be updated without a customer ID or an '
. 'account ID. Update a card using '
. "`Customer::updateSource('customer_id', 'card_id', "
. '$updateParams)` or `Account::updateExternalAccount('
. "'account_id', 'card_id', \$updateParams)`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param null|array|string $opts
*
* @return static the saved resource
*
* @throws Exception\ApiErrorException if the request fails
*
* @deprecated The `save` method is deprecated and will be removed in a
* future major version of the library. Use the static method `update`
* on the resource instead.
*/
public function save($opts = null)
{
$params = $this->serializeParameters();
if (\count($params) > 0) {
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('post', $url, $params, $opts, ['save']);
$this->refreshFrom($response, $opts);
}
return $this;
}
}

View File

@@ -0,0 +1,64 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* A customer's <code>Cash balance</code> represents real funds. Customers can add funds to their cash balance by sending a bank transfer. These funds can be used for payment and can eventually be paid out to your bank account.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property null|StripeObject $available A hash of all cash balances available to this customer. You cannot delete a customer with any cash balances, even if the balance is 0. Amounts are represented in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>.
* @property string $customer The ID of the customer whose cash balance this object represents.
* @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 (object{reconciliation_mode: string, using_merchant_default: bool}&StripeObject) $settings
*/
class CashBalance extends ApiResource
{
const OBJECT_NAME = 'cash_balance';
/**
* @return string the API URL for this balance transaction
*/
public function instanceUrl()
{
$customer = $this['customer'];
$customer = Util\Util::utf8($customer);
$base = Customer::classUrl();
$customerExtn = \urlencode($customer);
return "{$base}/{$customerExtn}/cash_balance";
}
/**
* @param array|string $_id
* @param null|array|string $_opts
*
* @throws Exception\BadMethodCallException
*/
public static function retrieve($_id, $_opts = null)
{
$msg = 'Customer Cash Balance cannot be retrieved without a '
. 'customer ID. Retrieve a Customer Cash Balance using '
. "`Customer::retrieveCashBalance('customer_id')`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param string $_id
* @param null|array $_params
* @param null|array|string $_options
*
* @throws Exception\BadMethodCallException
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = 'Customer Cash Balance cannot be updated without a '
. 'customer ID. Retrieve a Customer Cash Balance using '
. "`Customer::updateCashBalance('customer_id')`.";
throw new Exception\BadMethodCallException($msg);
}
}

277
vendor/stripe/stripe-php/lib/Charge.php vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,150 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Climate;
/**
* Orders represent your intent to purchase a particular Climate product. When you create an order, the
* payment is deducted from your merchant 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_fees Total amount of <a href="https://frontierclimate.com/">Frontier</a>'s service fees in the currency's smallest unit.
* @property int $amount_subtotal Total amount of the carbon removal in the currency's smallest unit.
* @property int $amount_total Total amount of the order including fees in the currency's smallest unit.
* @property null|(object{public_name: string}&\Stripe\StripeObject) $beneficiary
* @property null|int $canceled_at Time at which the order was canceled. Measured in seconds since the Unix epoch.
* @property null|string $cancellation_reason Reason for the cancellation of this order.
* @property null|string $certificate For delivered orders, a URL to a delivery certificate for the order.
* @property null|int $confirmed_at Time at which the order was confirmed. Measured in seconds since the Unix epoch.
* @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, representing the currency for this order.
* @property null|int $delayed_at Time at which the order's expected_delivery_year was delayed. Measured in seconds since the Unix epoch.
* @property null|int $delivered_at Time at which the order was delivered. Measured in seconds since the Unix epoch.
* @property ((object{delivered_at: int, location: null|(object{city: null|string, country: string, latitude: null|float, longitude: null|float, region: null|string}&\Stripe\StripeObject), metric_tons: string, registry_url: null|string, supplier: Supplier}&\Stripe\StripeObject))[] $delivery_details Details about the delivery of carbon removal for this order.
* @property int $expected_delivery_year The year this order is expected to be delivered.
* @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 string $metric_tons Quantity of carbon removal that is included in this order.
* @property Product|string $product Unique ID for the Climate <code>Product</code> this order is purchasing.
* @property null|int $product_substituted_at Time at which the order's product was substituted for a different product. Measured in seconds since the Unix epoch.
* @property string $status The current status of this order.
*/
class Order extends \Stripe\ApiResource
{
const OBJECT_NAME = 'climate.order';
use \Stripe\ApiOperations\Update;
const CANCELLATION_REASON_EXPIRED = 'expired';
const CANCELLATION_REASON_PRODUCT_UNAVAILABLE = 'product_unavailable';
const CANCELLATION_REASON_REQUESTED = 'requested';
const STATUS_AWAITING_FUNDS = 'awaiting_funds';
const STATUS_CANCELED = 'canceled';
const STATUS_CONFIRMED = 'confirmed';
const STATUS_DELIVERED = 'delivered';
const STATUS_OPEN = 'open';
/**
* Creates a Climate order object for a given Climate product. The order will be
* processed immediately after creation and payment will be deducted your Stripe
* balance.
*
* @param null|array{amount?: int, beneficiary?: array{public_name: string}, currency?: string, expand?: string[], metadata?: array<string, string>, metric_tons?: string, product: string} $params
* @param null|array|string $options
*
* @return Order the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Lists all Climate order objects. The orders are returned sorted by creation
* date, with the most recently created orders appearing first.
*
* @param null|array{ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Order> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves the details of a Climate order object with the given ID.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Order
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates the specified order by setting the values of the parameters passed.
*
* @param string $id the ID of the resource to update
* @param null|array{beneficiary?: null|array{public_name: null|string}, expand?: string[], metadata?: array<string, string>} $params
* @param null|array|string $opts
*
* @return Order the updated resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $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
*
* @return Order the canceled order
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
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;
}
}

View File

@@ -0,0 +1,60 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Climate;
/**
* A Climate product represents a type of carbon removal unit available for reservation.
* You can retrieve it to see the current price and availability.
*
* @property string $id Unique identifier for the object. For convenience, Climate product IDs are human-readable strings that start with <code>climsku_</code>. See <a href="https://stripe.com/docs/climate/orders/carbon-removal-inventory">carbon removal inventory</a> for a list of available carbon removal products.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property \Stripe\StripeObject $current_prices_per_metric_ton Current prices for a metric ton of carbon removal in a currency's smallest unit.
* @property null|int $delivery_year The year in which the carbon removal is expected to be delivered.
* @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 string $metric_tons_available The quantity of metric tons available for reservation.
* @property string $name The Climate product's name.
* @property Supplier[] $suppliers The carbon removal suppliers that fulfill orders for this Climate product.
*/
class Product extends \Stripe\ApiResource
{
const OBJECT_NAME = 'climate.product';
/**
* Lists all available Climate product objects.
*
* @param null|array{ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Product> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves the details of a Climate product with the given ID.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Product
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,61 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Climate;
/**
* A supplier of carbon removal.
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the objects type. Objects of the same type share the same value.
* @property string $info_url Link to a webpage to learn more about the supplier.
* @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 ((object{city: null|string, country: string, latitude: null|float, longitude: null|float, region: null|string}&\Stripe\StripeObject))[] $locations The locations in which this supplier operates.
* @property string $name Name of this carbon removal supplier.
* @property string $removal_pathway The scientific pathway used for carbon removal.
*/
class Supplier extends \Stripe\ApiResource
{
const OBJECT_NAME = 'climate.supplier';
const REMOVAL_PATHWAY_BIOMASS_CARBON_REMOVAL_AND_STORAGE = 'biomass_carbon_removal_and_storage';
const REMOVAL_PATHWAY_DIRECT_AIR_CAPTURE = 'direct_air_capture';
const REMOVAL_PATHWAY_ENHANCED_WEATHERING = 'enhanced_weathering';
/**
* Lists all available Climate supplier objects.
*
* @param null|array{ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Supplier> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a Climate supplier object.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Supplier
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,322 @@
<?php
namespace Stripe;
/**
* Class Collection.
*
* @template TStripeObject of StripeObject
*
* @template-implements \IteratorAggregate<TStripeObject>
*
* @property string $object
* @property string $url
* @property bool $has_more
* @property TStripeObject[] $data
*/
class Collection extends StripeObject implements \Countable, \IteratorAggregate
{
const OBJECT_NAME = 'list';
use ApiOperations\Request;
/** @var array */
protected $filters = [];
/**
* @return string the base URL for the given class
*/
public static function baseUrl()
{
return Stripe::$apiBase;
}
/**
* Returns the filters.
*
* @return array the filters
*/
public function getFilters()
{
return $this->filters;
}
/**
* Sets the filters, removing paging options.
*
* @param array $filters the filters
*/
public function setFilters($filters)
{
$this->filters = $filters;
}
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($k)
{
if (\is_string($k)) {
return parent::offsetGet($k);
}
$msg = "You tried to access the {$k} index, but Collection "
. 'types only support string keys. (HINT: List calls '
. 'return an object with a `data` (which is the data '
. "array). You likely want to call ->data[{$k}])";
throw new Exception\InvalidArgumentException($msg);
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<TStripeObject>
*
* @throws Exception\ApiErrorException
*/
public function all($params = null, $opts = null)
{
self::_validateParams($params);
list($url, $params) = $this->extractPathAndUpdateParams($params);
list($response, $opts) = $this->_request('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response, $opts);
if (!$obj instanceof Collection) {
throw new Exception\UnexpectedValueException(
'Expected type ' . Collection::class . ', got "' . \get_class($obj) . '" instead.'
);
}
$obj->setFilters($params);
return $obj;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return TStripeObject
*
* @throws Exception\ApiErrorException
*/
public function create($params = null, $opts = null)
{
self::_validateParams($params);
list($url, $params) = $this->extractPathAndUpdateParams($params);
list($response, $opts) = $this->_request('post', $url, $params, $opts);
return Util\Util::convertToStripeObject($response, $opts);
}
/**
* @param string $id
* @param null|array $params
* @param null|array|string $opts
*
* @return TStripeObject
*
* @throws Exception\ApiErrorException
*/
public function retrieve($id, $params = null, $opts = null)
{
self::_validateParams($params);
list($url, $params) = $this->extractPathAndUpdateParams($params);
$id = Util\Util::utf8($id);
$extn = \urlencode($id);
list($response, $opts) = $this->_request(
'get',
"{$url}/{$extn}",
$params,
$opts
);
return Util\Util::convertToStripeObject($response, $opts);
}
/**
* @return int the number of objects in the current page
*/
#[\ReturnTypeWillChange]
public function count()
{
return \count($this->data);
}
/**
* @return \ArrayIterator an iterator that can be used to iterate
* across objects in the current page
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new \ArrayIterator($this->data);
}
/**
* @return \ArrayIterator an iterator that can be used to iterate
* backwards across objects in the current page
*/
public function getReverseIterator()
{
return new \ArrayIterator(\array_reverse($this->data));
}
/**
* @return \Generator|TStripeObject[] A generator that can be used to
* iterate across all objects across all pages. As page boundaries are
* encountered, the next page will be fetched automatically for
* continued iteration.
*
* @throws Exception\ApiErrorException
*/
public function autoPagingIterator()
{
$page = $this;
while (true) {
$filters = $this->filters ?: [];
if (\array_key_exists('ending_before', $filters)
&& !\array_key_exists('starting_after', $filters)) {
foreach ($page->getReverseIterator() as $item) {
yield $item;
}
$page = $page->previousPage();
} else {
foreach ($page as $item) {
yield $item;
}
$page = $page->nextPage();
}
if ($page->isEmpty()) {
break;
}
}
}
/**
* Returns an empty collection. This is returned from {@see nextPage()}
* when we know that there isn't a next page in order to replicate the
* behavior of the API when it attempts to return a page beyond the last.
*
* @param null|array|string $opts
*
* @return Collection
*/
public static function emptyCollection($opts = null)
{
return Collection::constructFrom(['data' => []], $opts);
}
/**
* Returns true if the page object contains no element.
*
* @return bool
*/
public function isEmpty()
{
return empty($this->data);
}
/**
* Fetches the next page in the resource list (if there is one).
*
* This method will try to respect the limit of the current page. If none
* was given, the default limit will be fetched again.
*
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<TStripeObject>
*
* @throws Exception\ApiErrorException
*/
public function nextPage($params = null, $opts = null)
{
if (!$this->has_more) {
return static::emptyCollection($opts);
}
$lastId = \end($this->data)->id;
$params = \array_merge(
$this->filters ?: [],
['starting_after' => $lastId],
$params ?: []
);
return $this->all($params, $opts);
}
/**
* Fetches the previous page in the resource list (if there is one).
*
* This method will try to respect the limit of the current page. If none
* was given, the default limit will be fetched again.
*
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<TStripeObject>
*
* @throws Exception\ApiErrorException
*/
public function previousPage($params = null, $opts = null)
{
if (!$this->has_more) {
return static::emptyCollection($opts);
}
$firstId = $this->data[0]->id;
$params = \array_merge(
$this->filters ?: [],
['ending_before' => $firstId],
$params ?: []
);
return $this->all($params, $opts);
}
/**
* Gets the first item from the current page. Returns `null` if the current page is empty.
*
* @return null|TStripeObject
*/
public function first()
{
return \count($this->data) > 0 ? $this->data[0] : null;
}
/**
* Gets the last item from the current page. Returns `null` if the current page is empty.
*
* @return null|TStripeObject
*/
public function last()
{
return \count($this->data) > 0 ? $this->data[\count($this->data) - 1] : null;
}
private function extractPathAndUpdateParams($params)
{
$url = \parse_url($this->url);
if (!isset($url['path'])) {
throw new Exception\UnexpectedValueException("Could not parse list url into parts: {$url}");
}
if (isset($url['query'])) {
// If the URL contains a query param, parse it out into $params so they
// don't interact weirdly with each other.
$query = [];
\parse_str($url['query'], $query);
$params = \array_merge($params ?: [], $query);
}
return [$url['path'], $params];
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,18 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* @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 transferred, in cents (or local equivalent).
* @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 Account|string $destination ID of the account that funds are being collected for.
* @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 ConnectCollectionTransfer extends ApiResource
{
const OBJECT_NAME = 'connect_collection_transfer';
}

View File

@@ -0,0 +1,63 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* Stripe needs to collect certain pieces of information about each account
* created. These requirements can differ depending on the account's country. The
* Country Specs API makes these rules available to your integration.
*
* You can also view the information from this API call as <a href="/docs/connect/required-verification-information">an online
* guide</a>.
*
* @property string $id Unique identifier for the object. Represented as the ISO country code for this country.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property string $default_currency The default currency for this country. This applies to both payment methods and bank accounts.
* @property StripeObject $supported_bank_account_currencies Currencies that can be accepted in the specific country (for transfers).
* @property string[] $supported_payment_currencies Currencies that can be accepted in the specified country (for payments).
* @property string[] $supported_payment_methods Payment methods available in the specified country. You may need to enable some payment methods (e.g., <a href="https://stripe.com/docs/ach">ACH</a>) on your account before they appear in this list. The <code>stripe</code> payment method refers to <a href="https://stripe.com/docs/connect/destination-charges">charging through your platform</a>.
* @property string[] $supported_transfer_countries Countries that can accept transfers from the specified country.
* @property (object{company: (object{additional: string[], minimum: string[]}&StripeObject), individual: (object{additional: string[], minimum: string[]}&StripeObject)}&StripeObject) $verification_fields
*/
class CountrySpec extends ApiResource
{
const OBJECT_NAME = 'country_spec';
/**
* Lists all Country Spec objects available in the API.
*
* @param null|array{ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<CountrySpec> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Returns a Country Spec for a given Country code.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return CountrySpec
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

159
vendor/stripe/stripe-php/lib/Coupon.php vendored Normal file
View File

@@ -0,0 +1,159 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* A coupon contains information about a percent-off or amount-off discount you
* might want to apply to a customer. Coupons may be applied to <a href="https://stripe.com/docs/api#subscriptions">subscriptions</a>, <a href="https://stripe.com/docs/api#invoices">invoices</a>,
* <a href="https://stripe.com/docs/api/checkout/sessions">checkout sessions</a>, <a href="https://stripe.com/docs/api#quotes">quotes</a>, and more. Coupons do not work with conventional one-off <a href="https://stripe.com/docs/api#create_charge">charges</a> or <a href="https://stripe.com/docs/api/payment_intents">payment intents</a>.
*
* @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|int $amount_off Amount (in the <code>currency</code> specified) that will be taken off the subtotal of any invoices for this customer.
* @property null|(object{products: string[]}&StripeObject) $applies_to
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|string $currency If <code>amount_off</code> has been set, the three-letter <a href="https://stripe.com/docs/currencies">ISO code for the currency</a> of the amount to take off.
* @property null|StripeObject $currency_options Coupons defined in each available currency option. Each key must be a three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a> and a <a href="https://stripe.com/docs/currencies">supported currency</a>.
* @property string $duration One of <code>forever</code>, <code>once</code>, or <code>repeating</code>. Describes how long a customer who applies this coupon will get the discount.
* @property null|int $duration_in_months If <code>duration</code> is <code>repeating</code>, the number of months the coupon applies. Null if coupon <code>duration</code> is <code>forever</code> or <code>once</code>.
* @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 null|int $max_redemptions Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid.
* @property null|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 null|string $name Name of the coupon displayed to customers on for instance invoices or receipts.
* @property null|float $percent_off Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a $ (or local equivalent)100 invoice $ (or local equivalent)50 instead.
* @property null|int $redeem_by Date after which the coupon can no longer be redeemed.
* @property int $times_redeemed Number of times this coupon has been applied to a customer.
* @property bool $valid Taking account of the above properties, whether this coupon can still be applied to a customer.
*/
class Coupon extends ApiResource
{
const OBJECT_NAME = 'coupon';
use ApiOperations\Update;
const DURATION_FOREVER = 'forever';
const DURATION_ONCE = 'once';
const DURATION_REPEATING = 'repeating';
/**
* You can create coupons easily via the <a
* href="https://dashboard.stripe.com/coupons">coupon management</a> page of the
* Stripe dashboard. Coupon creation is also accessible via the API if you need to
* create coupons on the fly.
*
* A coupon has either a <code>percent_off</code> or an <code>amount_off</code> and
* <code>currency</code>. If you set an <code>amount_off</code>, that amount will
* be subtracted from any invoices subtotal. For example, an invoice with a
* subtotal of <currency>100</currency> will have a final total of
* <currency>0</currency> if a coupon with an <code>amount_off</code> of
* <amount>200</amount> is applied to it and an invoice with a subtotal of
* <currency>300</currency> will have a final total of <currency>100</currency> if
* a coupon with an <code>amount_off</code> of <amount>200</amount> is applied to
* it.
*
* @param null|array{amount_off?: int, applies_to?: array{products?: string[]}, currency?: string, currency_options?: array<string, array{amount_off: int}>, duration?: string, duration_in_months?: int, expand?: string[], id?: string, max_redemptions?: int, metadata?: null|array<string, string>, name?: string, percent_off?: float, redeem_by?: int} $params
* @param null|array|string $options
*
* @return Coupon the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* You can delete coupons via the <a
* href="https://dashboard.stripe.com/coupons">coupon management</a> page of the
* Stripe dashboard. However, deleting a coupon does not affect any customers who
* have already applied the coupon; it means that new customers cant redeem the
* coupon. You can also delete coupons via the API.
*
* @param null|array $params
* @param null|array|string $opts
*
* @return Coupon the deleted resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* Returns a list of your coupons.
*
* @param null|array{created?: array|int, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<Coupon> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the coupon with the given ID.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Coupon
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates the metadata of a coupon. Other coupon details (currency, duration,
* amount_off) are, by design, not editable.
*
* @param string $id the ID of the resource to update
* @param null|array{currency_options?: array<string, array{amount_off: int}>, expand?: string[], metadata?: null|array<string, string>, name?: string} $params
* @param null|array|string $opts
*
* @return Coupon the updated resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,234 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* Issue a credit note to adjust an invoice's amount after the invoice is finalized.
*
* Related guide: <a href="https://stripe.com/docs/billing/invoices/credit-notes">Credit notes</a>
*
* @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 The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax.
* @property int $amount_shipping This is the sum of all the shipping amounts.
* @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 Customer|string $customer ID of the customer.
* @property null|CustomerBalanceTransaction|string $customer_balance_transaction Customer balance transaction related to this credit note.
* @property int $discount_amount The integer amount in cents (or local equivalent) representing the total amount of discount that was credited.
* @property ((object{amount: int, discount: Discount|string}&StripeObject))[] $discount_amounts The aggregate amounts calculated per discount for all line items.
* @property null|int $effective_at The date when this credit note is in effect. Same as <code>created</code> unless overwritten. When defined, this value replaces the system-generated 'Date of issue' printed on the credit note PDF.
* @property Invoice|string $invoice ID of the invoice.
* @property Collection<CreditNoteLineItem> $lines Line items that make up the credit note
* @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 null|string $memo Customer-facing text that appears on the credit note PDF.
* @property null|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 string $number A unique number that identifies this particular credit note and appears on the PDF of the credit note and its associated invoice.
* @property null|int $out_of_band_amount Amount that was credited outside of Stripe.
* @property string $pdf The link to download the PDF of the credit note.
* @property int $post_payment_amount The amount of the credit note that was refunded to the customer, credited to the customer's balance, credited outside of Stripe, or any combination thereof.
* @property int $pre_payment_amount The amount of the credit note by which the invoice's <code>amount_remaining</code> and <code>amount_due</code> were reduced.
* @property ((object{amount: int, credit_balance_transaction?: Billing\CreditBalanceTransaction|string, discount?: Discount|string, type: string}&StripeObject))[] $pretax_credit_amounts The pretax credit amounts (ex: discount, credit grants, etc) for all line items.
* @property null|string $reason Reason for issuing this credit note, one of <code>duplicate</code>, <code>fraudulent</code>, <code>order_change</code>, or <code>product_unsatisfactory</code>
* @property ((object{amount_refunded: int, refund: Refund|string}&StripeObject))[] $refunds Refunds related to this credit note.
* @property null|(object{amount_subtotal: int, amount_tax: int, amount_total: int, shipping_rate: null|ShippingRate|string, taxes?: ((object{amount: int, rate: TaxRate, taxability_reason: null|string, taxable_amount: null|int}&StripeObject))[]}&StripeObject) $shipping_cost The details of the cost of shipping, including the ShippingRate applied to the invoice.
* @property string $status Status of this credit note, one of <code>issued</code> or <code>void</code>. Learn more about <a href="https://stripe.com/docs/billing/invoices/credit-notes#voiding">voiding credit notes</a>.
* @property int $subtotal The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding exclusive tax and invoice level discounts.
* @property null|int $subtotal_excluding_tax The integer amount in cents (or local equivalent) representing the amount of the credit note, excluding all tax and invoice level discounts.
* @property int $total The integer amount in cents (or local equivalent) representing the total amount of the credit note, including tax and all discount.
* @property null|int $total_excluding_tax The integer amount in cents (or local equivalent) representing the total amount of the credit note, excluding tax, but including discounts.
* @property null|((object{amount: int, tax_behavior: string, tax_rate_details: null|(object{tax_rate: string}&StripeObject), taxability_reason: string, taxable_amount: null|int, type: string}&StripeObject))[] $total_taxes The aggregate tax information for all line items.
* @property string $type Type of this credit note, one of <code>pre_payment</code> or <code>post_payment</code>. A <code>pre_payment</code> credit note means it was issued when the invoice was open. A <code>post_payment</code> credit note means it was issued when the invoice was paid.
* @property null|int $voided_at The time that the credit note was voided.
*/
class CreditNote extends ApiResource
{
const OBJECT_NAME = 'credit_note';
use ApiOperations\NestedResource;
use ApiOperations\Update;
const REASON_DUPLICATE = 'duplicate';
const REASON_FRAUDULENT = 'fraudulent';
const REASON_ORDER_CHANGE = 'order_change';
const REASON_PRODUCT_UNSATISFACTORY = 'product_unsatisfactory';
const STATUS_ISSUED = 'issued';
const STATUS_VOID = 'void';
const TYPE_MIXED = 'mixed';
const TYPE_POST_PAYMENT = 'post_payment';
const TYPE_PRE_PAYMENT = 'pre_payment';
/**
* Issue a credit note to adjust the amount of a finalized invoice. A credit note
* will first reduce the invoices <code>amount_remaining</code> (and
* <code>amount_due</code>), but not below zero. This amount is indicated by the
* credit notes <code>pre_payment_amount</code>. The excess amount is indicated by
* <code>post_payment_amount</code>, and it can result in any combination of the
* following:
*
* <ul> <li>Refunds: create a new refund (using <code>refund_amount</code>) or link
* existing refunds (using <code>refunds</code>).</li> <li>Customer balance credit:
* credit the customers balance (using <code>credit_amount</code>) which will be
* automatically applied to their next invoice when its finalized.</li>
* <li>Outside of Stripe credit: record the amount that is or will be credited
* outside of Stripe (using <code>out_of_band_amount</code>).</li> </ul>
*
* The sum of refunds, customer balance credits, and outside of Stripe credits must
* equal the <code>post_payment_amount</code>.
*
* You may issue multiple credit notes for an invoice. Each credit note may
* increment the invoices <code>pre_payment_credit_notes_amount</code>,
* <code>post_payment_credit_notes_amount</code>, or both, depending on the
* invoices <code>amount_remaining</code> at the time of credit note creation.
*
* @param null|array{amount?: int, credit_amount?: int, effective_at?: int, email_type?: string, expand?: string[], invoice: string, lines?: (array{amount?: int, description?: string, invoice_line_item?: string, quantity?: int, tax_amounts?: null|array{amount: int, tax_rate: string, taxable_amount: int}[], tax_rates?: null|string[], type: string, unit_amount?: int, unit_amount_decimal?: string})[], memo?: string, metadata?: array<string, string>, out_of_band_amount?: int, reason?: string, refund_amount?: int, refunds?: array{amount_refunded?: int, refund?: string}[], shipping_cost?: array{shipping_rate?: string}} $params
* @param null|array|string $options
*
* @return CreditNote the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Returns a list of credit notes.
*
* @param null|array{created?: array|int, customer?: string, ending_before?: string, expand?: string[], invoice?: string, limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<CreditNote> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the credit note object with the given identifier.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return CreditNote
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates an existing credit note.
*
* @param string $id the ID of the resource to update
* @param null|array{expand?: string[], memo?: string, metadata?: array<string, string>} $params
* @param null|array|string $opts
*
* @return CreditNote the updated resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return CreditNote the previewed credit note
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function preview($params = null, $opts = null)
{
$url = static::classUrl() . '/preview';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<CreditNoteLineItem> list of credit note line items
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function previewLines($params = null, $opts = null)
{
$url = static::classUrl() . '/preview/lines';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return CreditNote the voided credit note
*
* @throws Exception\ApiErrorException if the request fails
*/
public function voidCreditNote($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/void';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
const PATH_LINES = '/lines';
/**
* @param string $id the ID of the credit note on which to retrieve the credit note line items
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<CreditNoteLineItem> the list of credit note line items
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function allLines($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_LINES, $params, $opts);
}
}

View File

@@ -0,0 +1,29 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* The credit note line item object.
*
* @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 The integer amount in cents (or local equivalent) representing the gross amount being credited for this line item, excluding (exclusive) tax and discounts.
* @property null|string $description Description of the item being credited.
* @property int $discount_amount The integer amount in cents (or local equivalent) representing the discount being credited for this line item.
* @property ((object{amount: int, discount: Discount|string}&StripeObject))[] $discount_amounts The amount of discount calculated per discount for this line item
* @property null|string $invoice_line_item ID of the invoice line item being credited
* @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 ((object{amount: int, credit_balance_transaction?: Billing\CreditBalanceTransaction|string, discount?: Discount|string, type: string}&StripeObject))[] $pretax_credit_amounts The pretax credit amounts (ex: discount, credit grants, etc) for this line item.
* @property null|int $quantity The number of units of product being credited.
* @property TaxRate[] $tax_rates The tax rates which apply to the line item.
* @property null|((object{amount: int, tax_behavior: string, tax_rate_details: null|(object{tax_rate: string}&StripeObject), taxability_reason: string, taxable_amount: null|int, type: string}&StripeObject))[] $taxes The tax information of the line item.
* @property string $type The type of the credit note line item, one of <code>invoice_line_item</code> or <code>custom_line_item</code>. When the type is <code>invoice_line_item</code> there is an additional <code>invoice_line_item</code> property on the resource the value of which is the id of the credited line item on the invoice.
* @property null|int $unit_amount The cost of each unit of product being credited.
* @property null|string $unit_amount_decimal Same as <code>unit_amount</code>, but contains a decimal value with at most 12 decimal places.
*/
class CreditNoteLineItem extends ApiResource
{
const OBJECT_NAME = 'credit_note_line_item';
}

View File

@@ -0,0 +1,500 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* This object represents a customer of your business. Use it to <a href="https://stripe.com/docs/invoicing/customer">create recurring charges</a>, <a href="https://stripe.com/docs/payments/save-during-payment">save payment</a> and contact information,
* and track payments that belong to the same 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 null|(object{city: null|string, country: null|string, line1: null|string, line2: null|string, postal_code: null|string, state: null|string}&StripeObject) $address The customer's address.
* @property null|int $balance The current balance, if any, that's stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that's added to their next invoice. The balance only considers amounts that Stripe hasn't successfully applied to any invoice. It doesn't reflect unpaid invoices. This balance is only taken into account after invoices finalize.
* @property null|CashBalance $cash_balance The current funds being held by Stripe on behalf of the customer. You can apply these funds towards payment intents when the source is &quot;cash_balance&quot;. The <code>settings[reconciliation_mode]</code> field describes if these funds apply to these payment intents manually or automatically.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|string $currency Three-letter <a href="https://stripe.com/docs/currencies">ISO code for the currency</a> the customer can be charged in for recurring billing purposes.
* @property null|Account|BankAccount|Card|Source|string $default_source <p>ID of the default payment source for the customer.</p><p>If you use payment methods created through the PaymentMethods API, see the <a href="https://stripe.com/docs/api/customers/object#customer_object-invoice_settings-default_payment_method">invoice_settings.default_payment_method</a> field instead.</p>
* @property null|bool $delinquent <p>Tracks the most recent state change on any invoice belonging to the customer. Paying an invoice or marking it uncollectible via the API will set this field to false. An automatic payment failure or passing the <code>invoice.due_date</code> will set this field to <code>true</code>.</p><p>If an invoice becomes uncollectible by <a href="https://stripe.com/docs/billing/automatic-collection">dunning</a>, <code>delinquent</code> doesn't reset to <code>false</code>.</p><p>If you care whether the customer has paid their most recent subscription invoice, use <code>subscription.status</code> instead. Paying or marking uncollectible any customer invoice regardless of whether it is the latest invoice for a subscription will always set this field to <code>false</code>.</p>
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
* @property null|Discount $discount Describes the current discount active on the customer, if there is one.
* @property null|string $email The customer's email address.
* @property null|StripeObject $invoice_credit_balance The current multi-currency balances, if any, that's stored on the customer. If positive in a currency, the customer has a credit to apply to their next invoice denominated in that currency. If negative, the customer has an amount owed that's added to their next invoice denominated in that currency. These balances don't apply to unpaid invoices. They solely track amounts that Stripe hasn't successfully applied to any invoice. Stripe only applies a balance in a specific currency to an invoice after that invoice (which is in the same currency) finalizes.
* @property null|string $invoice_prefix The prefix for the customer used to generate unique invoice numbers.
* @property null|(object{custom_fields: null|(object{name: string, value: string}&StripeObject)[], default_payment_method: null|PaymentMethod|string, footer: null|string, rendering_options: null|(object{amount_tax_display: null|string, template: null|string}&StripeObject)}&StripeObject) $invoice_settings
* @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 null|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 null|string $name The customer's full name or business name.
* @property null|int $next_invoice_sequence The suffix of the customer's next invoice number (for example, 0001). When the account uses account level sequencing, this parameter is ignored in API requests and the field omitted in API responses.
* @property null|string $phone The customer's phone number.
* @property null|string[] $preferred_locales The customer's preferred locales (languages), ordered by preference.
* @property null|(object{address?: (object{city: null|string, country: null|string, line1: null|string, line2: null|string, postal_code: null|string, state: null|string}&StripeObject), carrier?: null|string, name?: string, phone?: null|string, tracking_number?: null|string}&StripeObject) $shipping Mailing and shipping address for the customer. Appears on invoices emailed to this customer.
* @property null|Collection<Account|BankAccount|Card|Source> $sources The customer's payment sources, if any.
* @property null|Collection<Subscription> $subscriptions The customer's current subscriptions, if any.
* @property null|(object{automatic_tax: string, ip_address: null|string, location: null|(object{country: string, source: string, state: null|string}&StripeObject)}&StripeObject) $tax
* @property null|string $tax_exempt Describes the customer's tax exemption status, which is <code>none</code>, <code>exempt</code>, or <code>reverse</code>. When set to <code>reverse</code>, invoice and receipt PDFs include the following text: <strong>&quot;Reverse charge&quot;</strong>.
* @property null|Collection<TaxId> $tax_ids The customer's tax IDs.
* @property null|string|TestHelpers\TestClock $test_clock ID of the test clock that this customer belongs to.
*/
class Customer extends ApiResource
{
const OBJECT_NAME = 'customer';
use ApiOperations\NestedResource;
use ApiOperations\Update;
const TAX_EXEMPT_EXEMPT = 'exempt';
const TAX_EXEMPT_NONE = 'none';
const TAX_EXEMPT_REVERSE = 'reverse';
/**
* Creates a new customer object.
*
* @param null|array{address?: null|array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, balance?: int, cash_balance?: array{settings?: array{reconciliation_mode?: string}}, description?: string, email?: string, expand?: string[], invoice_prefix?: string, invoice_settings?: array{custom_fields?: null|array{name: string, value: string}[], default_payment_method?: string, footer?: string, rendering_options?: null|array{amount_tax_display?: null|string, template?: string}}, metadata?: null|array<string, string>, name?: string, next_invoice_sequence?: int, payment_method?: string, phone?: string, preferred_locales?: string[], shipping?: null|array{address: array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, name: string, phone?: string}, source?: string, tax?: array{ip_address?: null|string, validate_location?: string}, tax_exempt?: null|string, tax_id_data?: array{type: string, value: string}[], test_clock?: string, validate?: bool} $params
* @param null|array|string $options
*
* @return Customer the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Permanently deletes a customer. It cannot be undone. Also immediately cancels
* any active subscriptions on the customer.
*
* @param null|array $params
* @param null|array|string $opts
*
* @return Customer the deleted resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* Returns a list of your customers. The customers are returned sorted by creation
* date, with the most recent customers appearing first.
*
* @param null|array{created?: array|int, email?: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string, test_clock?: string} $params
* @param null|array|string $opts
*
* @return Collection<Customer> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves a Customer object.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Customer
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates the specified customer by setting the values of the parameters passed.
* Any parameters not provided will be left unchanged. For example, if you pass the
* <strong>source</strong> parameter, that becomes the customers active source
* (e.g., a card) to be used for all charges in the future. When you update a
* customer to a new valid card source by passing the <strong>source</strong>
* parameter: for each of the customers current subscriptions, if the subscription
* bills automatically and is in the <code>past_due</code> state, then the latest
* open invoice for the subscription with automatic collection enabled will be
* retried. This retry will not count as an automatic retry, and will not affect
* the next regularly scheduled payment for the invoice. Changing the
* <strong>default_source</strong> for a customer will not trigger this behavior.
*
* This request accepts mostly the same arguments as the customer creation call.
*
* @param string $id the ID of the resource to update
* @param null|array{address?: null|array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, balance?: int, cash_balance?: array{settings?: array{reconciliation_mode?: string}}, default_source?: string, description?: string, email?: string, expand?: string[], invoice_prefix?: string, invoice_settings?: array{custom_fields?: null|array{name: string, value: string}[], default_payment_method?: string, footer?: string, rendering_options?: null|array{amount_tax_display?: null|string, template?: string}}, metadata?: null|array<string, string>, name?: string, next_invoice_sequence?: int, phone?: string, preferred_locales?: string[], shipping?: null|array{address: array{city?: string, country?: string, line1?: string, line2?: string, postal_code?: string, state?: string}, name: string, phone?: string}, source?: string, tax?: array{ip_address?: null|string, validate_location?: string}, tax_exempt?: null|string, validate?: bool} $params
* @param null|array|string $opts
*
* @return Customer the updated resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
public static function getSavedNestedResources()
{
static $savedNestedResources = null;
if (null === $savedNestedResources) {
$savedNestedResources = new Util\Set([
'source',
]);
}
return $savedNestedResources;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Customer the updated customer
*/
public function deleteDiscount($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/discount';
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom(['discount' => null], $opts, true);
return $this;
}
/**
* @param string $id
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<PaymentMethod> list of payment methods
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function allPaymentMethods($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/payment_methods';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param string $payment_method
* @param null|array $params
* @param null|array|string $opts
*
* @return PaymentMethod the retrieved payment method
*
* @throws Exception\ApiErrorException if the request fails
*/
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 = Util\Util::convertToStripeObject($response, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return SearchResult<Customer> the customer search results
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function search($params = null, $opts = null)
{
$url = '/v1/customers/search';
return static::_requestPage($url, SearchResult::class, $params, $opts);
}
const PATH_CASH_BALANCE = '/cash_balance';
/**
* @param string $id the ID of the customer to which the cash balance belongs
* @param null|array $params
* @param null|array|string $opts
* @param mixed $cashBalanceId
*
* @return CashBalance
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieveCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the cash balance belongs
* @param null|array $params
* @param null|array|string $opts
* @param mixed $cashBalanceId
*
* @return CashBalance
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function updateCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_CASH_BALANCE, $params, $opts);
}
const PATH_BALANCE_TRANSACTIONS = '/balance_transactions';
/**
* @param string $id the ID of the customer on which to retrieve the customer balance transactions
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<CustomerBalanceTransaction> the list of customer balance transactions
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function allBalanceTransactions($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
}
/**
* @param string $id the ID of the customer on which to create the customer balance transaction
* @param null|array $params
* @param null|array|string $opts
*
* @return CustomerBalanceTransaction
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function createBalanceTransaction($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the customer balance transaction belongs
* @param string $balanceTransactionId the ID of the customer balance transaction to retrieve
* @param null|array $params
* @param null|array|string $opts
*
* @return CustomerBalanceTransaction
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieveBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_BALANCE_TRANSACTIONS, $balanceTransactionId, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the customer balance transaction belongs
* @param string $balanceTransactionId the ID of the customer balance transaction to update
* @param null|array $params
* @param null|array|string $opts
*
* @return CustomerBalanceTransaction
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function updateBalanceTransaction($id, $balanceTransactionId, $params = null, $opts = null)
{
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
*
* @return Collection<CustomerCashBalanceTransaction> the list of customer cash balance transactions
*
* @throws Exception\ApiErrorException if the request fails
*/
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
*
* @return CustomerCashBalanceTransaction
*
* @throws Exception\ApiErrorException if the request fails
*/
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';
/**
* @param string $id the ID of the customer on which to retrieve the payment sources
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<BankAccount|Card|Source> the list of payment sources (BankAccount, Card or Source)
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function allSources($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_SOURCES, $params, $opts);
}
/**
* @param string $id the ID of the customer on which to create the payment source
* @param null|array $params
* @param null|array|string $opts
*
* @return BankAccount|Card|Source
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function createSource($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_SOURCES, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the payment source belongs
* @param string $sourceId the ID of the payment source to delete
* @param null|array $params
* @param null|array|string $opts
*
* @return BankAccount|Card|Source
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function deleteSource($id, $sourceId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the payment source belongs
* @param string $sourceId the ID of the payment source to retrieve
* @param null|array $params
* @param null|array|string $opts
*
* @return BankAccount|Card|Source
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieveSource($id, $sourceId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the payment source belongs
* @param string $sourceId the ID of the payment source to update
* @param null|array $params
* @param null|array|string $opts
*
* @return BankAccount|Card|Source
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function updateSource($id, $sourceId, $params = null, $opts = null)
{
return self::_updateNestedResource($id, static::PATH_SOURCES, $sourceId, $params, $opts);
}
const PATH_TAX_IDS = '/tax_ids';
/**
* @param string $id the ID of the customer on which to retrieve the tax ids
* @param null|array $params
* @param null|array|string $opts
*
* @return Collection<TaxId> the list of tax ids
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function allTaxIds($id, $params = null, $opts = null)
{
return self::_allNestedResources($id, static::PATH_TAX_IDS, $params, $opts);
}
/**
* @param string $id the ID of the customer on which to create the tax id
* @param null|array $params
* @param null|array|string $opts
*
* @return TaxId
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function createTaxId($id, $params = null, $opts = null)
{
return self::_createNestedResource($id, static::PATH_TAX_IDS, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the tax id belongs
* @param string $taxIdId the ID of the tax id to delete
* @param null|array $params
* @param null|array|string $opts
*
* @return TaxId
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function deleteTaxId($id, $taxIdId, $params = null, $opts = null)
{
return self::_deleteNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
}
/**
* @param string $id the ID of the customer to which the tax id belongs
* @param string $taxIdId the ID of the tax id to retrieve
* @param null|array $params
* @param null|array|string $opts
*
* @return TaxId
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieveTaxId($id, $taxIdId, $params = null, $opts = null)
{
return self::_retrieveNestedResource($id, static::PATH_TAX_IDS, $taxIdId, $params, $opts);
}
}

View File

@@ -0,0 +1,102 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* Each customer has a <a href="https://stripe.com/docs/api/customers/object#customer_object-balance">Balance</a> value,
* which denotes a debit or credit that's automatically applied to their next invoice upon finalization.
* You may modify the value directly by using the <a href="https://stripe.com/docs/api/customers/update">update customer API</a>,
* or by creating a Customer Balance Transaction, which increments or decrements the customer's <code>balance</code> by the specified <code>amount</code>.
*
* Related guide: <a href="https://stripe.com/docs/billing/customer/balance">Customer balance</a>
*
* @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 The amount of the transaction. A negative value is a credit for the customer's balance, and a positive value is a debit to the customer's <code>balance</code>.
* @property null|Checkout\Session|string $checkout_session The ID of the checkout session (if any) that created the transaction.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|CreditNote|string $credit_note The ID of the credit note (if any) related to the transaction.
* @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 Customer|string $customer The ID of the customer the transaction belongs to.
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
* @property int $ending_balance The customer's <code>balance</code> after the transaction was applied. A negative value decreases the amount due on the customer's next invoice. A positive value increases the amount due on the customer's next invoice.
* @property null|Invoice|string $invoice The ID of the invoice (if any) related to the transaction.
* @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 null|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 string $type Transaction type: <code>adjustment</code>, <code>applied_to_invoice</code>, <code>credit_note</code>, <code>initial</code>, <code>invoice_overpaid</code>, <code>invoice_too_large</code>, <code>invoice_too_small</code>, <code>unspent_receiver_credit</code>, <code>unapplied_from_invoice</code>, <code>checkout_session_subscription_payment</code>, or <code>checkout_session_subscription_payment_canceled</code>. See the <a href="https://stripe.com/docs/billing/customer/balance#types">Customer Balance page</a> to learn more about transaction types.
*/
class CustomerBalanceTransaction extends ApiResource
{
const OBJECT_NAME = 'customer_balance_transaction';
const TYPE_ADJUSTMENT = 'adjustment';
const TYPE_APPLIED_TO_INVOICE = 'applied_to_invoice';
const TYPE_CHECKOUT_SESSION_SUBSCRIPTION_PAYMENT = 'checkout_session_subscription_payment';
const TYPE_CHECKOUT_SESSION_SUBSCRIPTION_PAYMENT_CANCELED = 'checkout_session_subscription_payment_canceled';
const TYPE_CREDIT_NOTE = 'credit_note';
const TYPE_INITIAL = 'initial';
const TYPE_INVOICE_OVERPAID = 'invoice_overpaid';
const TYPE_INVOICE_TOO_LARGE = 'invoice_too_large';
const TYPE_INVOICE_TOO_SMALL = 'invoice_too_small';
const TYPE_UNSPENT_RECEIVER_CREDIT = 'unspent_receiver_credit';
const TYPE_ADJUSTEMENT = 'adjustment';
/**
* @return string the API URL for this balance transaction
*/
public function instanceUrl()
{
$id = $this['id'];
$customer = $this['customer'];
if (!$id) {
throw new Exception\UnexpectedValueException(
"Could not determine which URL to request: class instance has invalid ID: {$id}",
null
);
}
$id = Util\Util::utf8($id);
$customer = Util\Util::utf8($customer);
$base = Customer::classUrl();
$customerExtn = \urlencode($customer);
$extn = \urlencode($id);
return "{$base}/{$customerExtn}/balance_transactions/{$extn}";
}
/**
* @param array|string $_id
* @param null|array|string $_opts
*
* @throws Exception\BadMethodCallException
*/
public static function retrieve($_id, $_opts = null)
{
$msg = 'Customer Balance Transactions cannot be retrieved without a '
. 'customer ID. Retrieve a Customer Balance Transaction using '
. "`Customer::retrieveBalanceTransaction('customer_id', "
. "'balance_transaction_id')`.";
throw new Exception\BadMethodCallException($msg);
}
/**
* @param string $_id
* @param null|array $_params
* @param null|array|string $_options
*
* @throws Exception\BadMethodCallException
*/
public static function update($_id, $_params = null, $_options = null)
{
$msg = 'Customer Balance Transactions cannot be updated without a '
. 'customer ID. Update a Customer Balance Transaction using '
. "`Customer::updateBalanceTransaction('customer_id', "
. "'balance_transaction_id', \$updateParams)`.";
throw new Exception\BadMethodCallException($msg);
}
}

View File

@@ -0,0 +1,42 @@
<?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 null|(object{balance_transaction: BalanceTransaction|string, linked_transaction: CustomerCashBalanceTransaction|string}&StripeObject) $adjusted_for_overdraft
* @property null|(object{payment_intent: PaymentIntent|string}&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 Customer|string $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 null|(object{bank_transfer: (object{eu_bank_transfer?: (object{bic: null|string, iban_last4: null|string, sender_name: null|string}&StripeObject), gb_bank_transfer?: (object{account_number_last4: null|string, sender_name: null|string, sort_code: null|string}&StripeObject), jp_bank_transfer?: (object{sender_bank: null|string, sender_branch: null|string, sender_name: null|string}&StripeObject), reference: null|string, type: string, us_bank_transfer?: (object{network?: string, sender_name: null|string}&StripeObject)}&StripeObject)}&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 null|(object{refund: Refund|string}&StripeObject) $refunded_from_payment
* @property null|(object{balance_transaction: BalanceTransaction|string}&StripeObject) $transferred_to_balance
* @property string $type The type of the cash balance transaction. 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 null|(object{payment_intent: PaymentIntent|string}&StripeObject) $unapplied_from_payment
*/
class CustomerCashBalanceTransaction extends ApiResource
{
const OBJECT_NAME = 'customer_cash_balance_transaction';
const TYPE_ADJUSTED_FOR_OVERDRAFT = 'adjusted_for_overdraft';
const TYPE_APPLIED_TO_PAYMENT = 'applied_to_payment';
const TYPE_FUNDED = 'funded';
const TYPE_FUNDING_REVERSED = 'funding_reversed';
const TYPE_REFUNDED_FROM_PAYMENT = 'refunded_from_payment';
const TYPE_RETURN_CANCELED = 'return_canceled';
const TYPE_RETURN_INITIATED = 'return_initiated';
const TYPE_TRANSFERRED_TO_BALANCE = 'transferred_to_balance';
const TYPE_UNAPPLIED_FROM_PAYMENT = 'unapplied_from_payment';
}

View File

@@ -0,0 +1,50 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* A Customer Session allows you to grant Stripe's frontend SDKs (like Stripe.js) client-side access
* control over a Customer.
*
* Related guides: <a href="/payments/accept-a-payment-deferred?platform=web&amp;type=payment#save-payment-methods">Customer Session with the Payment Element</a>,
* <a href="/payments/checkout/pricing-table#customer-session">Customer Session with the Pricing Table</a>,
* <a href="/payment-links/buy-button#pass-an-existing-customer">Customer Session with the Buy Button</a>.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property string $client_secret <p>The client secret of this Customer Session. Used on the client to set up secure access to the given <code>customer</code>.</p><p>The client secret can be used to provide access to <code>customer</code> from your frontend. It should not be stored, logged, or exposed to anyone other than the relevant customer. Make sure that you have TLS enabled on any page that includes the client secret.</p>
* @property null|(object{buy_button: (object{enabled: bool}&StripeObject), payment_element: (object{enabled: bool, features: null|(object{payment_method_allow_redisplay_filters: string[], payment_method_redisplay: string, payment_method_redisplay_limit: null|int, payment_method_remove: string, payment_method_save: string, payment_method_save_usage: null|string}&StripeObject)}&StripeObject), pricing_table: (object{enabled: bool}&StripeObject)}&StripeObject) $components Configuration for the components supported by this Customer Session.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property Customer|string $customer The Customer the Customer Session was created for.
* @property int $expires_at The timestamp at which this Customer Session 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 CustomerSession extends ApiResource
{
const OBJECT_NAME = 'customer_session';
/**
* Creates a Customer Session object that includes a single-use client secret that
* you can use on your front-end to grant client-side API access for certain
* customer resources.
*
* @param null|array{components: array{buy_button?: array{enabled: bool}, payment_element?: array{enabled: bool, features?: array{payment_method_allow_redisplay_filters?: string[], payment_method_redisplay?: string, payment_method_redisplay_limit?: int, payment_method_remove?: string, payment_method_save?: string, payment_method_save_usage?: string}}, pricing_table?: array{enabled: bool}}, customer: string, expand?: string[]} $params
* @param null|array|string $options
*
* @return CustomerSession the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,29 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* A discount represents the actual application of a <a href="https://stripe.com/docs/api#coupons">coupon</a> or <a href="https://stripe.com/docs/api#promotion_codes">promotion code</a>.
* It contains information about when the discount began, when it will end, and what it is applied to.
*
* Related guide: <a href="https://stripe.com/docs/billing/subscriptions/discounts">Applying discounts to subscriptions</a>
*
* @property string $id The ID of the discount object. Discounts cannot be fetched by ID. Use <code>expand[]=discounts</code> in API calls to expand discount IDs in an array.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property null|string $checkout_session The Checkout session that this coupon is applied to, if it is applied to a particular session in payment mode. Will not be present for subscription mode.
* @property Coupon $coupon A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer. Coupons may be applied to <a href="https://stripe.com/docs/api#subscriptions">subscriptions</a>, <a href="https://stripe.com/docs/api#invoices">invoices</a>, <a href="https://stripe.com/docs/api/checkout/sessions">checkout sessions</a>, <a href="https://stripe.com/docs/api#quotes">quotes</a>, and more. Coupons do not work with conventional one-off <a href="https://stripe.com/docs/api#create_charge">charges</a> or <a href="https://stripe.com/docs/api/payment_intents">payment intents</a>.
* @property null|Customer|string $customer The ID of the customer associated with this discount.
* @property null|int $end If the coupon has a duration of <code>repeating</code>, the date that this discount will end. If the coupon has a duration of <code>once</code> or <code>forever</code>, this attribute will be null.
* @property null|string $invoice The invoice that the discount's coupon was applied to, if it was applied directly to a particular invoice.
* @property null|string $invoice_item The invoice item <code>id</code> (or invoice line item <code>id</code> for invoice line items of type='subscription') that the discount's coupon was applied to, if it was applied directly to a particular invoice item or invoice line item.
* @property null|PromotionCode|string $promotion_code The promotion code applied to create this discount.
* @property int $start Date that the coupon was applied.
* @property null|string $subscription The subscription that this coupon is applied to, if it is applied to a particular subscription.
* @property null|string $subscription_item The subscription item that this coupon is applied to, if it is applied to a particular subscription item.
*/
class Discount extends ApiResource
{
const OBJECT_NAME = 'discount';
}

145
vendor/stripe/stripe-php/lib/Dispute.php vendored Normal file
View File

@@ -0,0 +1,145 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* A dispute occurs when a customer questions your charge with their card issuer.
* When this happens, you have the opportunity to respond to the dispute with
* evidence that shows that the charge is legitimate.
*
* Related guide: <a href="https://stripe.com/docs/disputes">Disputes and fraud</a>
*
* @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 Disputed amount. Usually the amount of the charge, but it can differ (usually because of currency fluctuation or because only part of the order is disputed).
* @property BalanceTransaction[] $balance_transactions List of zero, one, or two balance transactions that show funds withdrawn and reinstated to your Stripe account as a result of this dispute.
* @property Charge|string $charge ID of the charge that's disputed.
* @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[] $enhanced_eligibility_types List of eligibility types that are included in <code>enhanced_evidence</code>.
* @property (object{access_activity_log: null|string, billing_address: null|string, cancellation_policy: null|File|string, cancellation_policy_disclosure: null|string, cancellation_rebuttal: null|string, customer_communication: null|File|string, customer_email_address: null|string, customer_name: null|string, customer_purchase_ip: null|string, customer_signature: null|File|string, duplicate_charge_documentation: null|File|string, duplicate_charge_explanation: null|string, duplicate_charge_id: null|string, enhanced_evidence: (object{visa_compelling_evidence_3?: (object{disputed_transaction: null|(object{customer_account_id: null|string, customer_device_fingerprint: null|string, customer_device_id: null|string, customer_email_address: null|string, customer_purchase_ip: null|string, merchandise_or_services: null|string, product_description: null|string, shipping_address: null|(object{city: null|string, country: null|string, line1: null|string, line2: null|string, postal_code: null|string, state: null|string}&StripeObject)}&StripeObject), prior_undisputed_transactions: ((object{charge: string, customer_account_id: null|string, customer_device_fingerprint: null|string, customer_device_id: null|string, customer_email_address: null|string, customer_purchase_ip: null|string, product_description: null|string, shipping_address: null|(object{city: null|string, country: null|string, line1: null|string, line2: null|string, postal_code: null|string, state: null|string}&StripeObject)}&StripeObject))[]}&StripeObject), visa_compliance?: (object{fee_acknowledged: bool}&StripeObject)}&StripeObject), product_description: null|string, receipt: null|File|string, refund_policy: null|File|string, refund_policy_disclosure: null|string, refund_refusal_explanation: null|string, service_date: null|string, service_documentation: null|File|string, shipping_address: null|string, shipping_carrier: null|string, shipping_date: null|string, shipping_documentation: null|File|string, shipping_tracking_number: null|string, uncategorized_file: null|File|string, uncategorized_text: null|string}&StripeObject) $evidence
* @property (object{due_by: null|int, enhanced_eligibility: (object{visa_compelling_evidence_3?: (object{required_actions: string[], status: string}&StripeObject), visa_compliance?: (object{status: string}&StripeObject)}&StripeObject), has_evidence: bool, past_due: bool, submission_count: int}&StripeObject) $evidence_details
* @property bool $is_charge_refundable If true, it's still possible to refund the disputed payment. After the payment has been fully refunded, no further funds are withdrawn from your Stripe account as a result of this dispute.
* @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 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 null|string $network_reason_code Network-dependent reason code for the dispute.
* @property null|PaymentIntent|string $payment_intent ID of the PaymentIntent that's disputed.
* @property null|(object{amazon_pay?: (object{dispute_type: null|string}&StripeObject), card?: (object{brand: string, case_type: string, network_reason_code: null|string}&StripeObject), klarna?: (object{reason_code: null|string}&StripeObject), paypal?: (object{case_id: null|string, reason_code: null|string}&StripeObject), type: string}&StripeObject) $payment_method_details
* @property string $reason Reason given by cardholder for dispute. Possible values are <code>bank_cannot_process</code>, <code>check_returned</code>, <code>credit_not_processed</code>, <code>customer_initiated</code>, <code>debit_not_authorized</code>, <code>duplicate</code>, <code>fraudulent</code>, <code>general</code>, <code>incorrect_account_details</code>, <code>insufficient_funds</code>, <code>noncompliant</code>, <code>product_not_received</code>, <code>product_unacceptable</code>, <code>subscription_canceled</code>, or <code>unrecognized</code>. Learn more about <a href="https://stripe.com/docs/disputes/categories">dispute reasons</a>.
* @property string $status Current status of dispute. Possible values are <code>warning_needs_response</code>, <code>warning_under_review</code>, <code>warning_closed</code>, <code>needs_response</code>, <code>under_review</code>, <code>won</code>, or <code>lost</code>.
*/
class Dispute extends ApiResource
{
const OBJECT_NAME = 'dispute';
use ApiOperations\Update;
const REASON_BANK_CANNOT_PROCESS = 'bank_cannot_process';
const REASON_CHECK_RETURNED = 'check_returned';
const REASON_CREDIT_NOT_PROCESSED = 'credit_not_processed';
const REASON_CUSTOMER_INITIATED = 'customer_initiated';
const REASON_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized';
const REASON_DUPLICATE = 'duplicate';
const REASON_FRAUDULENT = 'fraudulent';
const REASON_GENERAL = 'general';
const REASON_INCORRECT_ACCOUNT_DETAILS = 'incorrect_account_details';
const REASON_INSUFFICIENT_FUNDS = 'insufficient_funds';
const REASON_PRODUCT_NOT_RECEIVED = 'product_not_received';
const REASON_PRODUCT_UNACCEPTABLE = 'product_unacceptable';
const REASON_SUBSCRIPTION_CANCELED = 'subscription_canceled';
const REASON_UNRECOGNIZED = 'unrecognized';
const STATUS_LOST = 'lost';
const STATUS_NEEDS_RESPONSE = 'needs_response';
const STATUS_UNDER_REVIEW = 'under_review';
const STATUS_WARNING_CLOSED = 'warning_closed';
const STATUS_WARNING_NEEDS_RESPONSE = 'warning_needs_response';
const STATUS_WARNING_UNDER_REVIEW = 'warning_under_review';
const STATUS_WON = 'won';
/**
* Returns a list of your disputes.
*
* @param null|array{charge?: string, created?: array|int, ending_before?: string, expand?: string[], limit?: int, payment_intent?: string, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<Dispute> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the dispute with the given ID.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Dispute
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* When you get a dispute, contacting your customer is always the best first step.
* If that doesnt work, you can submit evidence to help us resolve the dispute in
* your favor. You can do this in your <a
* href="https://dashboard.stripe.com/disputes">dashboard</a>, but if you prefer,
* you can use the API to submit evidence programmatically.
*
* Depending on your dispute type, different evidence fields will give you a better
* chance of winning your dispute. To figure out which evidence fields to provide,
* see our <a href="/docs/disputes/categories">guide to dispute types</a>.
*
* @param string $id the ID of the resource to update
* @param null|array{evidence?: array{access_activity_log?: string, billing_address?: string, cancellation_policy?: string, cancellation_policy_disclosure?: string, cancellation_rebuttal?: string, customer_communication?: string, customer_email_address?: string, customer_name?: string, customer_purchase_ip?: string, customer_signature?: string, duplicate_charge_documentation?: string, duplicate_charge_explanation?: string, duplicate_charge_id?: string, enhanced_evidence?: null|array{visa_compelling_evidence_3?: array{disputed_transaction?: array{customer_account_id?: null|string, customer_device_fingerprint?: null|string, customer_device_id?: null|string, customer_email_address?: null|string, customer_purchase_ip?: null|string, merchandise_or_services?: string, product_description?: null|string, shipping_address?: array{city?: null|string, country?: null|string, line1?: null|string, line2?: null|string, postal_code?: null|string, state?: null|string}}, prior_undisputed_transactions?: (array{charge: string, customer_account_id?: null|string, customer_device_fingerprint?: null|string, customer_device_id?: null|string, customer_email_address?: null|string, customer_purchase_ip?: null|string, product_description?: null|string, shipping_address?: array{city?: null|string, country?: null|string, line1?: null|string, line2?: null|string, postal_code?: null|string, state?: null|string}})[]}, visa_compliance?: array{fee_acknowledged?: bool}}, product_description?: string, receipt?: string, refund_policy?: string, refund_policy_disclosure?: string, refund_refusal_explanation?: string, service_date?: string, service_documentation?: string, shipping_address?: string, shipping_carrier?: string, shipping_date?: string, shipping_documentation?: string, shipping_tracking_number?: string, uncategorized_file?: string, uncategorized_text?: string}, expand?: string[], metadata?: null|array<string, string>, submit?: bool} $params
* @param null|array|string $opts
*
* @return Dispute the updated resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Dispute the closed dispute
*
* @throws Exception\ApiErrorException if the request fails
*/
public function close($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/close';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@@ -0,0 +1,55 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Entitlements;
/**
* An active entitlement describes access to a feature for a 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 Feature|string $feature The <a href="https://stripe.com/docs/api/entitlements/feature">Feature</a> that the customer is entitled to.
* @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 string $lookup_key A unique key you provide as your own system identifier. This may be up to 80 characters.
*/
class ActiveEntitlement extends \Stripe\ApiResource
{
const OBJECT_NAME = 'entitlements.active_entitlement';
/**
* Retrieve a list of active entitlements for a customer.
*
* @param null|array{customer: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<ActiveEntitlement> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieve an active entitlement.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return ActiveEntitlement
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,18 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Entitlements;
/**
* A summary of a customer's active entitlements.
*
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property string $customer The customer that is entitled to this feature.
* @property \Stripe\Collection<ActiveEntitlement> $entitlements The list of entitlements this customer has.
* @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 ActiveEntitlementSummary extends \Stripe\ApiResource
{
const OBJECT_NAME = 'entitlements.active_entitlement_summary';
}

View File

@@ -0,0 +1,105 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Entitlements;
/**
* A feature represents a monetizable ability or functionality in your system.
* Features can be assigned to products, and when those products are purchased, Stripe will create an entitlement to the feature for the purchasing 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 bool $active Inactive features cannot be attached to new products and will not be returned from the features list endpoint.
* @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 string $lookup_key A unique key you provide as your own system identifier. This may be up to 80 characters.
* @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 $name The feature's name, for your own purpose, not meant to be displayable to the customer.
*/
class Feature extends \Stripe\ApiResource
{
const OBJECT_NAME = 'entitlements.feature';
use \Stripe\ApiOperations\Update;
/**
* Creates a feature.
*
* @param null|array{expand?: string[], lookup_key: string, metadata?: array<string, string>, name: string} $params
* @param null|array|string $options
*
* @return Feature the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Retrieve a list of features.
*
* @param null|array{archived?: bool, ending_before?: string, expand?: string[], limit?: int, lookup_key?: string, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Feature> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a feature.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Feature
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Update a features metadata or permanently deactivate it.
*
* @param string $id the ID of the resource to update
* @param null|array{active?: bool, expand?: string[], metadata?: null|array<string, string>, name?: string} $params
* @param null|array|string $opts
*
* @return Feature the updated resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,61 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property int $expires Time at which the key will expire. Measured in seconds since the Unix epoch.
* @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 null|string $secret The key's secret. You can use this value to make authorized requests to the Stripe API.
*/
class EphemeralKey extends ApiResource
{
const OBJECT_NAME = 'ephemeral_key';
/**
* Invalidates a short-lived API key for a given resource.
*
* @param null|array{expand?: string[]} $params
* @param null|array|string $opts
*
* @return EphemeralKey the deleted resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public function delete($params = null, $opts = null)
{
self::_validateParams($params);
$url = $this->instanceUrl();
list($response, $opts) = $this->_request('delete', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
use ApiOperations\Create {
create as protected _create;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return EphemeralKey the created key
*
* @throws Exception\InvalidArgumentException if stripe_version is missing
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $opts = null)
{
if (!$opts || !isset($opts['stripe_version'])) {
throw new Exception\InvalidArgumentException('stripe_version must be specified to create an ephemeral key');
}
return self::_create($params, $opts);
}
}

View File

@@ -0,0 +1,252 @@
<?php
namespace Stripe;
/**
* Class ErrorObject.
*
* @property string $charge For card errors, the ID of the failed charge.
* @property string $code For some errors that could be handled
* programmatically, a short string indicating the error code reported.
* @property string $decline_code For card errors resulting from a card issuer
* decline, a short string indicating the card issuer's reason for the
* decline if they provide one.
* @property string $doc_url A URL to more information about the error code
* reported.
* @property string $message A human-readable message providing more details
* about the error. For card errors, these messages can be shown to your
* users.
* @property string $param If the error is parameter-specific, the parameter
* related to the error. For example, you can use this to display a message
* near the correct form field.
* @property PaymentIntent $payment_intent The PaymentIntent object for errors
* returned on a request involving a PaymentIntent.
* @property PaymentMethod $payment_method The PaymentMethod object for errors
* returned on a request involving a PaymentMethod.
* @property string $payment_method_type If the error is specific to the type
* of payment method, the payment method type that had a problem. This
* field is only populated for invoice-related errors.
* @property string $request_log_url A URL to the request log entry in your
* dashboard.
* @property SetupIntent $setup_intent The SetupIntent object for errors
* returned on a request involving a SetupIntent.
* @property StripeObject $source The source object for errors returned on a
* request involving a source.
* @property string $type The type of error returned. One of `api_error`,
* `card_error`, `idempotency_error`, or `invalid_request_error`.
*/
class ErrorObject extends StripeObject
{
/**
* Possible string representations of an error's code.
*
* @see https://stripe.com/docs/error-codes
*/
// The beginning of the section generated from our OpenAPI spec
const CODE_ACCOUNT_CLOSED = 'account_closed';
const CODE_ACCOUNT_COUNTRY_INVALID_ADDRESS = 'account_country_invalid_address';
const CODE_ACCOUNT_ERROR_COUNTRY_CHANGE_REQUIRES_ADDITIONAL_STEPS = 'account_error_country_change_requires_additional_steps';
const CODE_ACCOUNT_INFORMATION_MISMATCH = 'account_information_mismatch';
const CODE_ACCOUNT_INVALID = 'account_invalid';
const CODE_ACCOUNT_NUMBER_INVALID = 'account_number_invalid';
const CODE_ACSS_DEBIT_SESSION_INCOMPLETE = 'acss_debit_session_incomplete';
const CODE_ALIPAY_UPGRADE_REQUIRED = 'alipay_upgrade_required';
const CODE_AMOUNT_TOO_LARGE = 'amount_too_large';
const CODE_AMOUNT_TOO_SMALL = 'amount_too_small';
const CODE_API_KEY_EXPIRED = 'api_key_expired';
const CODE_APPLICATION_FEES_NOT_ALLOWED = 'application_fees_not_allowed';
const CODE_AUTHENTICATION_REQUIRED = 'authentication_required';
const CODE_BALANCE_INSUFFICIENT = 'balance_insufficient';
const CODE_BALANCE_INVALID_PARAMETER = 'balance_invalid_parameter';
const CODE_BANK_ACCOUNT_BAD_ROUTING_NUMBERS = 'bank_account_bad_routing_numbers';
const CODE_BANK_ACCOUNT_DECLINED = 'bank_account_declined';
const CODE_BANK_ACCOUNT_EXISTS = 'bank_account_exists';
const CODE_BANK_ACCOUNT_RESTRICTED = 'bank_account_restricted';
const CODE_BANK_ACCOUNT_UNUSABLE = 'bank_account_unusable';
const CODE_BANK_ACCOUNT_UNVERIFIED = 'bank_account_unverified';
const CODE_BANK_ACCOUNT_VERIFICATION_FAILED = 'bank_account_verification_failed';
const CODE_BILLING_INVALID_MANDATE = 'billing_invalid_mandate';
const CODE_BITCOIN_UPGRADE_REQUIRED = 'bitcoin_upgrade_required';
const CODE_CAPTURE_CHARGE_AUTHORIZATION_EXPIRED = 'capture_charge_authorization_expired';
const CODE_CAPTURE_UNAUTHORIZED_PAYMENT = 'capture_unauthorized_payment';
const CODE_CARD_DECLINE_RATE_LIMIT_EXCEEDED = 'card_decline_rate_limit_exceeded';
const CODE_CARD_DECLINED = 'card_declined';
const CODE_CARDHOLDER_PHONE_NUMBER_REQUIRED = 'cardholder_phone_number_required';
const CODE_CHARGE_ALREADY_CAPTURED = 'charge_already_captured';
const CODE_CHARGE_ALREADY_REFUNDED = 'charge_already_refunded';
const CODE_CHARGE_DISPUTED = 'charge_disputed';
const CODE_CHARGE_EXCEEDS_SOURCE_LIMIT = 'charge_exceeds_source_limit';
const CODE_CHARGE_EXCEEDS_TRANSACTION_LIMIT = 'charge_exceeds_transaction_limit';
const CODE_CHARGE_EXPIRED_FOR_CAPTURE = 'charge_expired_for_capture';
const CODE_CHARGE_INVALID_PARAMETER = 'charge_invalid_parameter';
const CODE_CHARGE_NOT_REFUNDABLE = 'charge_not_refundable';
const CODE_CLEARING_CODE_UNSUPPORTED = 'clearing_code_unsupported';
const CODE_COUNTRY_CODE_INVALID = 'country_code_invalid';
const CODE_COUNTRY_UNSUPPORTED = 'country_unsupported';
const CODE_COUPON_EXPIRED = 'coupon_expired';
const CODE_CUSTOMER_MAX_PAYMENT_METHODS = 'customer_max_payment_methods';
const CODE_CUSTOMER_MAX_SUBSCRIPTIONS = 'customer_max_subscriptions';
const CODE_CUSTOMER_TAX_LOCATION_INVALID = 'customer_tax_location_invalid';
const CODE_DEBIT_NOT_AUTHORIZED = 'debit_not_authorized';
const CODE_EMAIL_INVALID = 'email_invalid';
const CODE_EXPIRED_CARD = 'expired_card';
const CODE_FINANCIAL_CONNECTIONS_ACCOUNT_INACTIVE = 'financial_connections_account_inactive';
const CODE_FINANCIAL_CONNECTIONS_NO_SUCCESSFUL_TRANSACTION_REFRESH = 'financial_connections_no_successful_transaction_refresh';
const CODE_FORWARDING_API_INACTIVE = 'forwarding_api_inactive';
const CODE_FORWARDING_API_INVALID_PARAMETER = 'forwarding_api_invalid_parameter';
const CODE_FORWARDING_API_RETRYABLE_UPSTREAM_ERROR = 'forwarding_api_retryable_upstream_error';
const CODE_FORWARDING_API_UPSTREAM_CONNECTION_ERROR = 'forwarding_api_upstream_connection_error';
const CODE_FORWARDING_API_UPSTREAM_CONNECTION_TIMEOUT = 'forwarding_api_upstream_connection_timeout';
const CODE_FORWARDING_API_UPSTREAM_ERROR = 'forwarding_api_upstream_error';
const CODE_IDEMPOTENCY_KEY_IN_USE = 'idempotency_key_in_use';
const CODE_INCORRECT_ADDRESS = 'incorrect_address';
const CODE_INCORRECT_CVC = 'incorrect_cvc';
const CODE_INCORRECT_NUMBER = 'incorrect_number';
const CODE_INCORRECT_ZIP = 'incorrect_zip';
const CODE_INSTANT_PAYOUTS_CONFIG_DISABLED = 'instant_payouts_config_disabled';
const CODE_INSTANT_PAYOUTS_CURRENCY_DISABLED = 'instant_payouts_currency_disabled';
const CODE_INSTANT_PAYOUTS_LIMIT_EXCEEDED = 'instant_payouts_limit_exceeded';
const CODE_INSTANT_PAYOUTS_UNSUPPORTED = 'instant_payouts_unsupported';
const CODE_INSUFFICIENT_FUNDS = 'insufficient_funds';
const CODE_INTENT_INVALID_STATE = 'intent_invalid_state';
const CODE_INTENT_VERIFICATION_METHOD_MISSING = 'intent_verification_method_missing';
const CODE_INVALID_CARD_TYPE = 'invalid_card_type';
const CODE_INVALID_CHARACTERS = 'invalid_characters';
const CODE_INVALID_CHARGE_AMOUNT = 'invalid_charge_amount';
const CODE_INVALID_CVC = 'invalid_cvc';
const CODE_INVALID_EXPIRY_MONTH = 'invalid_expiry_month';
const CODE_INVALID_EXPIRY_YEAR = 'invalid_expiry_year';
const CODE_INVALID_MANDATE_REFERENCE_PREFIX_FORMAT = 'invalid_mandate_reference_prefix_format';
const CODE_INVALID_NUMBER = 'invalid_number';
const CODE_INVALID_SOURCE_USAGE = 'invalid_source_usage';
const CODE_INVALID_TAX_LOCATION = 'invalid_tax_location';
const CODE_INVOICE_NO_CUSTOMER_LINE_ITEMS = 'invoice_no_customer_line_items';
const CODE_INVOICE_NO_PAYMENT_METHOD_TYPES = 'invoice_no_payment_method_types';
const CODE_INVOICE_NO_SUBSCRIPTION_LINE_ITEMS = 'invoice_no_subscription_line_items';
const CODE_INVOICE_NOT_EDITABLE = 'invoice_not_editable';
const CODE_INVOICE_ON_BEHALF_OF_NOT_EDITABLE = 'invoice_on_behalf_of_not_editable';
const CODE_INVOICE_PAYMENT_INTENT_REQUIRES_ACTION = 'invoice_payment_intent_requires_action';
const CODE_INVOICE_UPCOMING_NONE = 'invoice_upcoming_none';
const CODE_LIVEMODE_MISMATCH = 'livemode_mismatch';
const CODE_LOCK_TIMEOUT = 'lock_timeout';
const CODE_MISSING = 'missing';
const CODE_NO_ACCOUNT = 'no_account';
const CODE_NOT_ALLOWED_ON_STANDARD_ACCOUNT = 'not_allowed_on_standard_account';
const CODE_OUT_OF_INVENTORY = 'out_of_inventory';
const CODE_OWNERSHIP_DECLARATION_NOT_ALLOWED = 'ownership_declaration_not_allowed';
const CODE_PARAMETER_INVALID_EMPTY = 'parameter_invalid_empty';
const CODE_PARAMETER_INVALID_INTEGER = 'parameter_invalid_integer';
const CODE_PARAMETER_INVALID_STRING_BLANK = 'parameter_invalid_string_blank';
const CODE_PARAMETER_INVALID_STRING_EMPTY = 'parameter_invalid_string_empty';
const CODE_PARAMETER_MISSING = 'parameter_missing';
const CODE_PARAMETER_UNKNOWN = 'parameter_unknown';
const CODE_PARAMETERS_EXCLUSIVE = 'parameters_exclusive';
const CODE_PAYMENT_INTENT_ACTION_REQUIRED = 'payment_intent_action_required';
const CODE_PAYMENT_INTENT_AUTHENTICATION_FAILURE = 'payment_intent_authentication_failure';
const CODE_PAYMENT_INTENT_INCOMPATIBLE_PAYMENT_METHOD = 'payment_intent_incompatible_payment_method';
const CODE_PAYMENT_INTENT_INVALID_PARAMETER = 'payment_intent_invalid_parameter';
const CODE_PAYMENT_INTENT_KONBINI_REJECTED_CONFIRMATION_NUMBER = 'payment_intent_konbini_rejected_confirmation_number';
const CODE_PAYMENT_INTENT_MANDATE_INVALID = 'payment_intent_mandate_invalid';
const CODE_PAYMENT_INTENT_PAYMENT_ATTEMPT_EXPIRED = 'payment_intent_payment_attempt_expired';
const CODE_PAYMENT_INTENT_PAYMENT_ATTEMPT_FAILED = 'payment_intent_payment_attempt_failed';
const CODE_PAYMENT_INTENT_UNEXPECTED_STATE = 'payment_intent_unexpected_state';
const CODE_PAYMENT_METHOD_BANK_ACCOUNT_ALREADY_VERIFIED = 'payment_method_bank_account_already_verified';
const CODE_PAYMENT_METHOD_BANK_ACCOUNT_BLOCKED = 'payment_method_bank_account_blocked';
const CODE_PAYMENT_METHOD_BILLING_DETAILS_ADDRESS_MISSING = 'payment_method_billing_details_address_missing';
const CODE_PAYMENT_METHOD_CONFIGURATION_FAILURES = 'payment_method_configuration_failures';
const CODE_PAYMENT_METHOD_CURRENCY_MISMATCH = 'payment_method_currency_mismatch';
const CODE_PAYMENT_METHOD_CUSTOMER_DECLINE = 'payment_method_customer_decline';
const CODE_PAYMENT_METHOD_INVALID_PARAMETER = 'payment_method_invalid_parameter';
const CODE_PAYMENT_METHOD_INVALID_PARAMETER_TESTMODE = 'payment_method_invalid_parameter_testmode';
const CODE_PAYMENT_METHOD_MICRODEPOSIT_FAILED = 'payment_method_microdeposit_failed';
const CODE_PAYMENT_METHOD_MICRODEPOSIT_VERIFICATION_AMOUNTS_INVALID = 'payment_method_microdeposit_verification_amounts_invalid';
const CODE_PAYMENT_METHOD_MICRODEPOSIT_VERIFICATION_AMOUNTS_MISMATCH = 'payment_method_microdeposit_verification_amounts_mismatch';
const CODE_PAYMENT_METHOD_MICRODEPOSIT_VERIFICATION_ATTEMPTS_EXCEEDED = 'payment_method_microdeposit_verification_attempts_exceeded';
const CODE_PAYMENT_METHOD_MICRODEPOSIT_VERIFICATION_DESCRIPTOR_CODE_MISMATCH = 'payment_method_microdeposit_verification_descriptor_code_mismatch';
const CODE_PAYMENT_METHOD_MICRODEPOSIT_VERIFICATION_TIMEOUT = 'payment_method_microdeposit_verification_timeout';
const CODE_PAYMENT_METHOD_NOT_AVAILABLE = 'payment_method_not_available';
const CODE_PAYMENT_METHOD_PROVIDER_DECLINE = 'payment_method_provider_decline';
const CODE_PAYMENT_METHOD_PROVIDER_TIMEOUT = 'payment_method_provider_timeout';
const CODE_PAYMENT_METHOD_UNACTIVATED = 'payment_method_unactivated';
const CODE_PAYMENT_METHOD_UNEXPECTED_STATE = 'payment_method_unexpected_state';
const CODE_PAYMENT_METHOD_UNSUPPORTED_TYPE = 'payment_method_unsupported_type';
const CODE_PAYOUT_RECONCILIATION_NOT_READY = 'payout_reconciliation_not_ready';
const CODE_PAYOUTS_LIMIT_EXCEEDED = 'payouts_limit_exceeded';
const CODE_PAYOUTS_NOT_ALLOWED = 'payouts_not_allowed';
const CODE_PLATFORM_ACCOUNT_REQUIRED = 'platform_account_required';
const CODE_PLATFORM_API_KEY_EXPIRED = 'platform_api_key_expired';
const CODE_POSTAL_CODE_INVALID = 'postal_code_invalid';
const CODE_PROCESSING_ERROR = 'processing_error';
const CODE_PRODUCT_INACTIVE = 'product_inactive';
const CODE_PROGRESSIVE_ONBOARDING_LIMIT_EXCEEDED = 'progressive_onboarding_limit_exceeded';
const CODE_RATE_LIMIT = 'rate_limit';
const CODE_REFER_TO_CUSTOMER = 'refer_to_customer';
const CODE_REFUND_DISPUTED_PAYMENT = 'refund_disputed_payment';
const CODE_RESOURCE_ALREADY_EXISTS = 'resource_already_exists';
const CODE_RESOURCE_MISSING = 'resource_missing';
const CODE_RETURN_INTENT_ALREADY_PROCESSED = 'return_intent_already_processed';
const CODE_ROUTING_NUMBER_INVALID = 'routing_number_invalid';
const CODE_SECRET_KEY_REQUIRED = 'secret_key_required';
const CODE_SEPA_UNSUPPORTED_ACCOUNT = 'sepa_unsupported_account';
const CODE_SETUP_ATTEMPT_FAILED = 'setup_attempt_failed';
const CODE_SETUP_INTENT_AUTHENTICATION_FAILURE = 'setup_intent_authentication_failure';
const CODE_SETUP_INTENT_INVALID_PARAMETER = 'setup_intent_invalid_parameter';
const CODE_SETUP_INTENT_MANDATE_INVALID = 'setup_intent_mandate_invalid';
const CODE_SETUP_INTENT_MOBILE_WALLET_UNSUPPORTED = 'setup_intent_mobile_wallet_unsupported';
const CODE_SETUP_INTENT_SETUP_ATTEMPT_EXPIRED = 'setup_intent_setup_attempt_expired';
const CODE_SETUP_INTENT_UNEXPECTED_STATE = 'setup_intent_unexpected_state';
const CODE_SHIPPING_ADDRESS_INVALID = 'shipping_address_invalid';
const CODE_SHIPPING_CALCULATION_FAILED = 'shipping_calculation_failed';
const CODE_SKU_INACTIVE = 'sku_inactive';
const CODE_STATE_UNSUPPORTED = 'state_unsupported';
const CODE_STATUS_TRANSITION_INVALID = 'status_transition_invalid';
const CODE_STRIPE_TAX_INACTIVE = 'stripe_tax_inactive';
const CODE_TAX_ID_INVALID = 'tax_id_invalid';
const CODE_TAX_ID_PROHIBITED = 'tax_id_prohibited';
const CODE_TAXES_CALCULATION_FAILED = 'taxes_calculation_failed';
const CODE_TERMINAL_LOCATION_COUNTRY_UNSUPPORTED = 'terminal_location_country_unsupported';
const CODE_TERMINAL_READER_BUSY = 'terminal_reader_busy';
const CODE_TERMINAL_READER_HARDWARE_FAULT = 'terminal_reader_hardware_fault';
const CODE_TERMINAL_READER_INVALID_LOCATION_FOR_ACTIVATION = 'terminal_reader_invalid_location_for_activation';
const CODE_TERMINAL_READER_INVALID_LOCATION_FOR_PAYMENT = 'terminal_reader_invalid_location_for_payment';
const CODE_TERMINAL_READER_OFFLINE = 'terminal_reader_offline';
const CODE_TERMINAL_READER_TIMEOUT = 'terminal_reader_timeout';
const CODE_TESTMODE_CHARGES_ONLY = 'testmode_charges_only';
const CODE_TLS_VERSION_UNSUPPORTED = 'tls_version_unsupported';
const CODE_TOKEN_ALREADY_USED = 'token_already_used';
const CODE_TOKEN_CARD_NETWORK_INVALID = 'token_card_network_invalid';
const CODE_TOKEN_IN_USE = 'token_in_use';
const CODE_TRANSFER_SOURCE_BALANCE_PARAMETERS_MISMATCH = 'transfer_source_balance_parameters_mismatch';
const CODE_TRANSFERS_NOT_ALLOWED = 'transfers_not_allowed';
const CODE_URL_INVALID = 'url_invalid';
// The end of the section generated from our OpenAPI spec
/**
* Refreshes this object using the provided values.
*
* @param array $values
* @param null|array|string|Util\RequestOptions $opts
* @param bool $partial defaults to false
* @param 'v1'|'v2' $apiMode
*/
public function refreshFrom($values, $opts, $partial = false, $apiMode = 'v1')
{
// Unlike most other API resources, the API will omit attributes in
// error objects when they have a null value. We manually set default
// values here to facilitate generic error handling.
$values = \array_merge([
'charge' => null,
'code' => null,
'decline_code' => null,
'doc_url' => null,
'message' => null,
'param' => null,
'payment_intent' => null,
'payment_method' => null,
'setup_intent' => null,
'source' => null,
'type' => null,
], $values);
parent::refreshFrom($values, $opts, $partial);
}
}

596
vendor/stripe/stripe-php/lib/Event.php vendored Normal file
View File

@@ -0,0 +1,596 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* Events are our way of letting you know when something interesting happens in
* your account. When an interesting event occurs, we create a new <code>Event</code>
* object. For example, when a charge succeeds, we create a <code>charge.succeeded</code>
* event, and when an invoice payment attempt fails, we create an
* <code>invoice.payment_failed</code> event. Certain API requests might create multiple
* events. For example, if you create a new subscription for a
* customer, you receive both a <code>customer.subscription.created</code> event and a
* <code>charge.succeeded</code> event.
*
* Events occur when the state of another API resource changes. The event's data
* field embeds the resource's state at the time of the change. For
* example, a <code>charge.succeeded</code> event contains a charge, and an
* <code>invoice.payment_failed</code> event contains an invoice.
*
* As with other API resources, you can use endpoints to retrieve an
* <a href="https://stripe.com/docs/api#retrieve_event">individual event</a> or a <a href="https://stripe.com/docs/api#list_events">list of events</a>
* from the API. We also have a separate
* <a href="http://en.wikipedia.org/wiki/Webhook">webhooks</a> system for sending the
* <code>Event</code> objects directly to an endpoint on your server. You can manage
* webhooks in your
* <a href="https://dashboard.stripe.com/account/webhooks">account settings</a>. Learn how
* to <a href="https://docs.stripe.com/webhooks">listen for events</a>
* so that your integration can automatically trigger reactions.
*
* When using <a href="https://docs.stripe.com/connect">Connect</a>, you can also receive event notifications
* that occur in connected accounts. For these events, there's an
* additional <code>account</code> attribute in the received <code>Event</code> object.
*
* We only guarantee access to events through the <a href="https://stripe.com/docs/api#retrieve_event">Retrieve Event API</a>
* for 30 days.
*
* This class includes constants for the possible string representations of
* event types. See https://stripe.com/docs/api#event_types for more details.
*
* @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 $account The connected account that originates the event.
* @property null|string $api_version The Stripe API version used to render <code>data</code>. This property is populated only for events on or after October 31, 2014.
* @property null|string $context Authentication context needed to fetch the event or related object.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property (object{object: StripeObject, previous_attributes?: StripeObject}&StripeObject) $data
* @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 $pending_webhooks Number of webhooks that haven't been successfully delivered (for example, to return a 20x response) to the URLs you specify.
* @property null|(object{id: null|string, idempotency_key: null|string}&StripeObject) $request Information on the API request that triggers the event.
* @property string $type Description of the event (for example, <code>invoice.created</code> or <code>charge.refunded</code>).
*/
class Event extends ApiResource
{
const OBJECT_NAME = 'event';
const ACCOUNT_APPLICATION_AUTHORIZED = 'account.application.authorized';
const ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized';
const ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created';
const ACCOUNT_EXTERNAL_ACCOUNT_DELETED = 'account.external_account.deleted';
const ACCOUNT_EXTERNAL_ACCOUNT_UPDATED = 'account.external_account.updated';
const ACCOUNT_UPDATED = 'account.updated';
const APPLICATION_FEE_CREATED = 'application_fee.created';
const APPLICATION_FEE_REFUNDED = 'application_fee.refunded';
const APPLICATION_FEE_REFUND_UPDATED = 'application_fee.refund.updated';
const BALANCE_AVAILABLE = 'balance.available';
const BILLING_ALERT_TRIGGERED = 'billing.alert.triggered';
const BILLING_CREDIT_BALANCE_TRANSACTION_CREATED = 'billing.credit_balance_transaction.created';
const BILLING_CREDIT_GRANT_CREATED = 'billing.credit_grant.created';
const BILLING_CREDIT_GRANT_UPDATED = 'billing.credit_grant.updated';
const BILLING_METER_CREATED = 'billing.meter.created';
const BILLING_METER_DEACTIVATED = 'billing.meter.deactivated';
const BILLING_METER_REACTIVATED = 'billing.meter.reactivated';
const BILLING_METER_UPDATED = 'billing.meter.updated';
const BILLING_PORTAL_CONFIGURATION_CREATED = 'billing_portal.configuration.created';
const BILLING_PORTAL_CONFIGURATION_UPDATED = 'billing_portal.configuration.updated';
const BILLING_PORTAL_SESSION_CREATED = 'billing_portal.session.created';
const CAPABILITY_UPDATED = 'capability.updated';
const CASH_BALANCE_FUNDS_AVAILABLE = 'cash_balance.funds_available';
const CHARGE_CAPTURED = 'charge.captured';
const CHARGE_DISPUTE_CLOSED = 'charge.dispute.closed';
const CHARGE_DISPUTE_CREATED = 'charge.dispute.created';
const CHARGE_DISPUTE_FUNDS_REINSTATED = 'charge.dispute.funds_reinstated';
const CHARGE_DISPUTE_FUNDS_WITHDRAWN = 'charge.dispute.funds_withdrawn';
const CHARGE_DISPUTE_UPDATED = 'charge.dispute.updated';
const CHARGE_EXPIRED = 'charge.expired';
const CHARGE_FAILED = 'charge.failed';
const CHARGE_PENDING = 'charge.pending';
const CHARGE_REFUNDED = 'charge.refunded';
const CHARGE_REFUND_UPDATED = 'charge.refund.updated';
const CHARGE_SUCCEEDED = 'charge.succeeded';
const CHARGE_UPDATED = 'charge.updated';
const CHECKOUT_SESSION_ASYNC_PAYMENT_FAILED = 'checkout.session.async_payment_failed';
const CHECKOUT_SESSION_ASYNC_PAYMENT_SUCCEEDED = 'checkout.session.async_payment_succeeded';
const CHECKOUT_SESSION_COMPLETED = 'checkout.session.completed';
const CHECKOUT_SESSION_EXPIRED = 'checkout.session.expired';
const CLIMATE_ORDER_CANCELED = 'climate.order.canceled';
const CLIMATE_ORDER_CREATED = 'climate.order.created';
const CLIMATE_ORDER_DELAYED = 'climate.order.delayed';
const CLIMATE_ORDER_DELIVERED = 'climate.order.delivered';
const CLIMATE_ORDER_PRODUCT_SUBSTITUTED = 'climate.order.product_substituted';
const CLIMATE_PRODUCT_CREATED = 'climate.product.created';
const CLIMATE_PRODUCT_PRICING_UPDATED = 'climate.product.pricing_updated';
const COUPON_CREATED = 'coupon.created';
const COUPON_DELETED = 'coupon.deleted';
const COUPON_UPDATED = 'coupon.updated';
const CREDIT_NOTE_CREATED = 'credit_note.created';
const CREDIT_NOTE_UPDATED = 'credit_note.updated';
const CREDIT_NOTE_VOIDED = 'credit_note.voided';
const CUSTOMER_CASH_BALANCE_TRANSACTION_CREATED = 'customer_cash_balance_transaction.created';
const CUSTOMER_CREATED = 'customer.created';
const CUSTOMER_DELETED = 'customer.deleted';
const CUSTOMER_DISCOUNT_CREATED = 'customer.discount.created';
const CUSTOMER_DISCOUNT_DELETED = 'customer.discount.deleted';
const CUSTOMER_DISCOUNT_UPDATED = 'customer.discount.updated';
const CUSTOMER_SOURCE_CREATED = 'customer.source.created';
const CUSTOMER_SOURCE_DELETED = 'customer.source.deleted';
const CUSTOMER_SOURCE_EXPIRING = 'customer.source.expiring';
const CUSTOMER_SOURCE_UPDATED = 'customer.source.updated';
const CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created';
const CUSTOMER_SUBSCRIPTION_DELETED = 'customer.subscription.deleted';
const CUSTOMER_SUBSCRIPTION_PAUSED = 'customer.subscription.paused';
const CUSTOMER_SUBSCRIPTION_PENDING_UPDATE_APPLIED = 'customer.subscription.pending_update_applied';
const CUSTOMER_SUBSCRIPTION_PENDING_UPDATE_EXPIRED = 'customer.subscription.pending_update_expired';
const CUSTOMER_SUBSCRIPTION_RESUMED = 'customer.subscription.resumed';
const CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END = 'customer.subscription.trial_will_end';
const CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated';
const CUSTOMER_TAX_ID_CREATED = 'customer.tax_id.created';
const CUSTOMER_TAX_ID_DELETED = 'customer.tax_id.deleted';
const CUSTOMER_TAX_ID_UPDATED = 'customer.tax_id.updated';
const CUSTOMER_UPDATED = 'customer.updated';
const ENTITLEMENTS_ACTIVE_ENTITLEMENT_SUMMARY_UPDATED = 'entitlements.active_entitlement_summary.updated';
const FILE_CREATED = 'file.created';
const FINANCIAL_CONNECTIONS_ACCOUNT_CREATED = 'financial_connections.account.created';
const FINANCIAL_CONNECTIONS_ACCOUNT_DEACTIVATED = 'financial_connections.account.deactivated';
const FINANCIAL_CONNECTIONS_ACCOUNT_DISCONNECTED = 'financial_connections.account.disconnected';
const FINANCIAL_CONNECTIONS_ACCOUNT_REACTIVATED = 'financial_connections.account.reactivated';
const FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_BALANCE = 'financial_connections.account.refreshed_balance';
const FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_OWNERSHIP = 'financial_connections.account.refreshed_ownership';
const FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_TRANSACTIONS = 'financial_connections.account.refreshed_transactions';
const IDENTITY_VERIFICATION_SESSION_CANCELED = 'identity.verification_session.canceled';
const IDENTITY_VERIFICATION_SESSION_CREATED = 'identity.verification_session.created';
const IDENTITY_VERIFICATION_SESSION_PROCESSING = 'identity.verification_session.processing';
const IDENTITY_VERIFICATION_SESSION_REDACTED = 'identity.verification_session.redacted';
const IDENTITY_VERIFICATION_SESSION_REQUIRES_INPUT = 'identity.verification_session.requires_input';
const IDENTITY_VERIFICATION_SESSION_VERIFIED = 'identity.verification_session.verified';
const INVOICEITEM_CREATED = 'invoiceitem.created';
const INVOICEITEM_DELETED = 'invoiceitem.deleted';
const INVOICE_CREATED = 'invoice.created';
const INVOICE_DELETED = 'invoice.deleted';
const INVOICE_FINALIZATION_FAILED = 'invoice.finalization_failed';
const INVOICE_FINALIZED = 'invoice.finalized';
const INVOICE_MARKED_UNCOLLECTIBLE = 'invoice.marked_uncollectible';
const INVOICE_OVERDUE = 'invoice.overdue';
const INVOICE_OVERPAID = 'invoice.overpaid';
const INVOICE_PAID = 'invoice.paid';
const INVOICE_PAYMENT_ACTION_REQUIRED = 'invoice.payment_action_required';
const INVOICE_PAYMENT_FAILED = 'invoice.payment_failed';
const INVOICE_PAYMENT_PAID = 'invoice_payment.paid';
const INVOICE_PAYMENT_SUCCEEDED = 'invoice.payment_succeeded';
const INVOICE_SENT = 'invoice.sent';
const INVOICE_UPCOMING = 'invoice.upcoming';
const INVOICE_UPDATED = 'invoice.updated';
const INVOICE_VOIDED = 'invoice.voided';
const INVOICE_WILL_BE_DUE = 'invoice.will_be_due';
const ISSUING_AUTHORIZATION_CREATED = 'issuing_authorization.created';
const ISSUING_AUTHORIZATION_REQUEST = 'issuing_authorization.request';
const ISSUING_AUTHORIZATION_UPDATED = 'issuing_authorization.updated';
const ISSUING_CARDHOLDER_CREATED = 'issuing_cardholder.created';
const ISSUING_CARDHOLDER_UPDATED = 'issuing_cardholder.updated';
const ISSUING_CARD_CREATED = 'issuing_card.created';
const ISSUING_CARD_UPDATED = 'issuing_card.updated';
const ISSUING_DISPUTE_CLOSED = 'issuing_dispute.closed';
const ISSUING_DISPUTE_CREATED = 'issuing_dispute.created';
const ISSUING_DISPUTE_FUNDS_REINSTATED = 'issuing_dispute.funds_reinstated';
const ISSUING_DISPUTE_FUNDS_RESCINDED = 'issuing_dispute.funds_rescinded';
const ISSUING_DISPUTE_SUBMITTED = 'issuing_dispute.submitted';
const ISSUING_DISPUTE_UPDATED = 'issuing_dispute.updated';
const ISSUING_PERSONALIZATION_DESIGN_ACTIVATED = 'issuing_personalization_design.activated';
const ISSUING_PERSONALIZATION_DESIGN_DEACTIVATED = 'issuing_personalization_design.deactivated';
const ISSUING_PERSONALIZATION_DESIGN_REJECTED = 'issuing_personalization_design.rejected';
const ISSUING_PERSONALIZATION_DESIGN_UPDATED = 'issuing_personalization_design.updated';
const ISSUING_TOKEN_CREATED = 'issuing_token.created';
const ISSUING_TOKEN_UPDATED = 'issuing_token.updated';
const ISSUING_TRANSACTION_CREATED = 'issuing_transaction.created';
const ISSUING_TRANSACTION_PURCHASE_DETAILS_RECEIPT_UPDATED = 'issuing_transaction.purchase_details_receipt_updated';
const ISSUING_TRANSACTION_UPDATED = 'issuing_transaction.updated';
const MANDATE_UPDATED = 'mandate.updated';
const PAYMENT_INTENT_AMOUNT_CAPTURABLE_UPDATED = 'payment_intent.amount_capturable_updated';
const PAYMENT_INTENT_CANCELED = 'payment_intent.canceled';
const PAYMENT_INTENT_CREATED = 'payment_intent.created';
const PAYMENT_INTENT_PARTIALLY_FUNDED = 'payment_intent.partially_funded';
const PAYMENT_INTENT_PAYMENT_FAILED = 'payment_intent.payment_failed';
const PAYMENT_INTENT_PROCESSING = 'payment_intent.processing';
const PAYMENT_INTENT_REQUIRES_ACTION = 'payment_intent.requires_action';
const PAYMENT_INTENT_SUCCEEDED = 'payment_intent.succeeded';
const PAYMENT_LINK_CREATED = 'payment_link.created';
const PAYMENT_LINK_UPDATED = 'payment_link.updated';
const PAYMENT_METHOD_ATTACHED = 'payment_method.attached';
const PAYMENT_METHOD_AUTOMATICALLY_UPDATED = 'payment_method.automatically_updated';
const PAYMENT_METHOD_DETACHED = 'payment_method.detached';
const PAYMENT_METHOD_UPDATED = 'payment_method.updated';
const PAYOUT_CANCELED = 'payout.canceled';
const PAYOUT_CREATED = 'payout.created';
const PAYOUT_FAILED = 'payout.failed';
const PAYOUT_PAID = 'payout.paid';
const PAYOUT_RECONCILIATION_COMPLETED = 'payout.reconciliation_completed';
const PAYOUT_UPDATED = 'payout.updated';
const PERSON_CREATED = 'person.created';
const PERSON_DELETED = 'person.deleted';
const PERSON_UPDATED = 'person.updated';
const PLAN_CREATED = 'plan.created';
const PLAN_DELETED = 'plan.deleted';
const PLAN_UPDATED = 'plan.updated';
const PRICE_CREATED = 'price.created';
const PRICE_DELETED = 'price.deleted';
const PRICE_UPDATED = 'price.updated';
const PRODUCT_CREATED = 'product.created';
const PRODUCT_DELETED = 'product.deleted';
const PRODUCT_UPDATED = 'product.updated';
const PROMOTION_CODE_CREATED = 'promotion_code.created';
const PROMOTION_CODE_UPDATED = 'promotion_code.updated';
const QUOTE_ACCEPTED = 'quote.accepted';
const QUOTE_CANCELED = 'quote.canceled';
const QUOTE_CREATED = 'quote.created';
const QUOTE_FINALIZED = 'quote.finalized';
const RADAR_EARLY_FRAUD_WARNING_CREATED = 'radar.early_fraud_warning.created';
const RADAR_EARLY_FRAUD_WARNING_UPDATED = 'radar.early_fraud_warning.updated';
const REFUND_CREATED = 'refund.created';
const REFUND_FAILED = 'refund.failed';
const REFUND_UPDATED = 'refund.updated';
const REPORTING_REPORT_RUN_FAILED = 'reporting.report_run.failed';
const REPORTING_REPORT_RUN_SUCCEEDED = 'reporting.report_run.succeeded';
const REPORTING_REPORT_TYPE_UPDATED = 'reporting.report_type.updated';
const REVIEW_CLOSED = 'review.closed';
const REVIEW_OPENED = 'review.opened';
const SETUP_INTENT_CANCELED = 'setup_intent.canceled';
const SETUP_INTENT_CREATED = 'setup_intent.created';
const SETUP_INTENT_REQUIRES_ACTION = 'setup_intent.requires_action';
const SETUP_INTENT_SETUP_FAILED = 'setup_intent.setup_failed';
const SETUP_INTENT_SUCCEEDED = 'setup_intent.succeeded';
const SIGMA_SCHEDULED_QUERY_RUN_CREATED = 'sigma.scheduled_query_run.created';
const SOURCE_CANCELED = 'source.canceled';
const SOURCE_CHARGEABLE = 'source.chargeable';
const SOURCE_FAILED = 'source.failed';
const SOURCE_MANDATE_NOTIFICATION = 'source.mandate_notification';
const SOURCE_REFUND_ATTRIBUTES_REQUIRED = 'source.refund_attributes_required';
const SOURCE_TRANSACTION_CREATED = 'source.transaction.created';
const SOURCE_TRANSACTION_UPDATED = 'source.transaction.updated';
const SUBSCRIPTION_SCHEDULE_ABORTED = 'subscription_schedule.aborted';
const SUBSCRIPTION_SCHEDULE_CANCELED = 'subscription_schedule.canceled';
const SUBSCRIPTION_SCHEDULE_COMPLETED = 'subscription_schedule.completed';
const SUBSCRIPTION_SCHEDULE_CREATED = 'subscription_schedule.created';
const SUBSCRIPTION_SCHEDULE_EXPIRING = 'subscription_schedule.expiring';
const SUBSCRIPTION_SCHEDULE_RELEASED = 'subscription_schedule.released';
const SUBSCRIPTION_SCHEDULE_UPDATED = 'subscription_schedule.updated';
const TAX_RATE_CREATED = 'tax_rate.created';
const TAX_RATE_UPDATED = 'tax_rate.updated';
const TAX_SETTINGS_UPDATED = 'tax.settings.updated';
const TERMINAL_READER_ACTION_FAILED = 'terminal.reader.action_failed';
const TERMINAL_READER_ACTION_SUCCEEDED = 'terminal.reader.action_succeeded';
const TEST_HELPERS_TEST_CLOCK_ADVANCING = 'test_helpers.test_clock.advancing';
const TEST_HELPERS_TEST_CLOCK_CREATED = 'test_helpers.test_clock.created';
const TEST_HELPERS_TEST_CLOCK_DELETED = 'test_helpers.test_clock.deleted';
const TEST_HELPERS_TEST_CLOCK_INTERNAL_FAILURE = 'test_helpers.test_clock.internal_failure';
const TEST_HELPERS_TEST_CLOCK_READY = 'test_helpers.test_clock.ready';
const TOPUP_CANCELED = 'topup.canceled';
const TOPUP_CREATED = 'topup.created';
const TOPUP_FAILED = 'topup.failed';
const TOPUP_REVERSED = 'topup.reversed';
const TOPUP_SUCCEEDED = 'topup.succeeded';
const TRANSFER_CREATED = 'transfer.created';
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_PAYMENT_TRACKING_DETAILS_UPDATED = 'treasury.outbound_payment.tracking_details_updated';
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_OUTBOUND_TRANSFER_TRACKING_DETAILS_UPDATED = 'treasury.outbound_transfer.tracking_details_updated';
const TREASURY_RECEIVED_CREDIT_CREATED = 'treasury.received_credit.created';
const TREASURY_RECEIVED_CREDIT_FAILED = 'treasury.received_credit.failed';
const TREASURY_RECEIVED_CREDIT_SUCCEEDED = 'treasury.received_credit.succeeded';
const TREASURY_RECEIVED_DEBIT_CREATED = 'treasury.received_debit.created';
const TYPE_ACCOUNT_APPLICATION_AUTHORIZED = 'account.application.authorized';
const TYPE_ACCOUNT_APPLICATION_DEAUTHORIZED = 'account.application.deauthorized';
const TYPE_ACCOUNT_EXTERNAL_ACCOUNT_CREATED = 'account.external_account.created';
const TYPE_ACCOUNT_EXTERNAL_ACCOUNT_DELETED = 'account.external_account.deleted';
const TYPE_ACCOUNT_EXTERNAL_ACCOUNT_UPDATED = 'account.external_account.updated';
const TYPE_ACCOUNT_UPDATED = 'account.updated';
const TYPE_APPLICATION_FEE_CREATED = 'application_fee.created';
const TYPE_APPLICATION_FEE_REFUNDED = 'application_fee.refunded';
const TYPE_APPLICATION_FEE_REFUND_UPDATED = 'application_fee.refund.updated';
const TYPE_BALANCE_AVAILABLE = 'balance.available';
const TYPE_BILLING_ALERT_TRIGGERED = 'billing.alert.triggered';
const TYPE_BILLING_CREDIT_BALANCE_TRANSACTION_CREATED = 'billing.credit_balance_transaction.created';
const TYPE_BILLING_CREDIT_GRANT_CREATED = 'billing.credit_grant.created';
const TYPE_BILLING_CREDIT_GRANT_UPDATED = 'billing.credit_grant.updated';
const TYPE_BILLING_METER_CREATED = 'billing.meter.created';
const TYPE_BILLING_METER_DEACTIVATED = 'billing.meter.deactivated';
const TYPE_BILLING_METER_REACTIVATED = 'billing.meter.reactivated';
const TYPE_BILLING_METER_UPDATED = 'billing.meter.updated';
const TYPE_BILLING_PORTAL_CONFIGURATION_CREATED = 'billing_portal.configuration.created';
const TYPE_BILLING_PORTAL_CONFIGURATION_UPDATED = 'billing_portal.configuration.updated';
const TYPE_BILLING_PORTAL_SESSION_CREATED = 'billing_portal.session.created';
const TYPE_CAPABILITY_UPDATED = 'capability.updated';
const TYPE_CASH_BALANCE_FUNDS_AVAILABLE = 'cash_balance.funds_available';
const TYPE_CHARGE_CAPTURED = 'charge.captured';
const TYPE_CHARGE_DISPUTE_CLOSED = 'charge.dispute.closed';
const TYPE_CHARGE_DISPUTE_CREATED = 'charge.dispute.created';
const TYPE_CHARGE_DISPUTE_FUNDS_REINSTATED = 'charge.dispute.funds_reinstated';
const TYPE_CHARGE_DISPUTE_FUNDS_WITHDRAWN = 'charge.dispute.funds_withdrawn';
const TYPE_CHARGE_DISPUTE_UPDATED = 'charge.dispute.updated';
const TYPE_CHARGE_EXPIRED = 'charge.expired';
const TYPE_CHARGE_FAILED = 'charge.failed';
const TYPE_CHARGE_PENDING = 'charge.pending';
const TYPE_CHARGE_REFUNDED = 'charge.refunded';
const TYPE_CHARGE_REFUND_UPDATED = 'charge.refund.updated';
const TYPE_CHARGE_SUCCEEDED = 'charge.succeeded';
const TYPE_CHARGE_UPDATED = 'charge.updated';
const TYPE_CHECKOUT_SESSION_ASYNC_PAYMENT_FAILED = 'checkout.session.async_payment_failed';
const TYPE_CHECKOUT_SESSION_ASYNC_PAYMENT_SUCCEEDED = 'checkout.session.async_payment_succeeded';
const TYPE_CHECKOUT_SESSION_COMPLETED = 'checkout.session.completed';
const TYPE_CHECKOUT_SESSION_EXPIRED = 'checkout.session.expired';
const TYPE_CLIMATE_ORDER_CANCELED = 'climate.order.canceled';
const TYPE_CLIMATE_ORDER_CREATED = 'climate.order.created';
const TYPE_CLIMATE_ORDER_DELAYED = 'climate.order.delayed';
const TYPE_CLIMATE_ORDER_DELIVERED = 'climate.order.delivered';
const TYPE_CLIMATE_ORDER_PRODUCT_SUBSTITUTED = 'climate.order.product_substituted';
const TYPE_CLIMATE_PRODUCT_CREATED = 'climate.product.created';
const TYPE_CLIMATE_PRODUCT_PRICING_UPDATED = 'climate.product.pricing_updated';
const TYPE_COUPON_CREATED = 'coupon.created';
const TYPE_COUPON_DELETED = 'coupon.deleted';
const TYPE_COUPON_UPDATED = 'coupon.updated';
const TYPE_CREDIT_NOTE_CREATED = 'credit_note.created';
const TYPE_CREDIT_NOTE_UPDATED = 'credit_note.updated';
const TYPE_CREDIT_NOTE_VOIDED = 'credit_note.voided';
const TYPE_CUSTOMER_CASH_BALANCE_TRANSACTION_CREATED = 'customer_cash_balance_transaction.created';
const TYPE_CUSTOMER_CREATED = 'customer.created';
const TYPE_CUSTOMER_DELETED = 'customer.deleted';
const TYPE_CUSTOMER_DISCOUNT_CREATED = 'customer.discount.created';
const TYPE_CUSTOMER_DISCOUNT_DELETED = 'customer.discount.deleted';
const TYPE_CUSTOMER_DISCOUNT_UPDATED = 'customer.discount.updated';
const TYPE_CUSTOMER_SOURCE_CREATED = 'customer.source.created';
const TYPE_CUSTOMER_SOURCE_DELETED = 'customer.source.deleted';
const TYPE_CUSTOMER_SOURCE_EXPIRING = 'customer.source.expiring';
const TYPE_CUSTOMER_SOURCE_UPDATED = 'customer.source.updated';
const TYPE_CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created';
const TYPE_CUSTOMER_SUBSCRIPTION_DELETED = 'customer.subscription.deleted';
const TYPE_CUSTOMER_SUBSCRIPTION_PAUSED = 'customer.subscription.paused';
const TYPE_CUSTOMER_SUBSCRIPTION_PENDING_UPDATE_APPLIED = 'customer.subscription.pending_update_applied';
const TYPE_CUSTOMER_SUBSCRIPTION_PENDING_UPDATE_EXPIRED = 'customer.subscription.pending_update_expired';
const TYPE_CUSTOMER_SUBSCRIPTION_RESUMED = 'customer.subscription.resumed';
const TYPE_CUSTOMER_SUBSCRIPTION_TRIAL_WILL_END = 'customer.subscription.trial_will_end';
const TYPE_CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated';
const TYPE_CUSTOMER_TAX_ID_CREATED = 'customer.tax_id.created';
const TYPE_CUSTOMER_TAX_ID_DELETED = 'customer.tax_id.deleted';
const TYPE_CUSTOMER_TAX_ID_UPDATED = 'customer.tax_id.updated';
const TYPE_CUSTOMER_UPDATED = 'customer.updated';
const TYPE_ENTITLEMENTS_ACTIVE_ENTITLEMENT_SUMMARY_UPDATED = 'entitlements.active_entitlement_summary.updated';
const TYPE_FILE_CREATED = 'file.created';
const TYPE_FINANCIAL_CONNECTIONS_ACCOUNT_CREATED = 'financial_connections.account.created';
const TYPE_FINANCIAL_CONNECTIONS_ACCOUNT_DEACTIVATED = 'financial_connections.account.deactivated';
const TYPE_FINANCIAL_CONNECTIONS_ACCOUNT_DISCONNECTED = 'financial_connections.account.disconnected';
const TYPE_FINANCIAL_CONNECTIONS_ACCOUNT_REACTIVATED = 'financial_connections.account.reactivated';
const TYPE_FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_BALANCE = 'financial_connections.account.refreshed_balance';
const TYPE_FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_OWNERSHIP = 'financial_connections.account.refreshed_ownership';
const TYPE_FINANCIAL_CONNECTIONS_ACCOUNT_REFRESHED_TRANSACTIONS = 'financial_connections.account.refreshed_transactions';
const TYPE_IDENTITY_VERIFICATION_SESSION_CANCELED = 'identity.verification_session.canceled';
const TYPE_IDENTITY_VERIFICATION_SESSION_CREATED = 'identity.verification_session.created';
const TYPE_IDENTITY_VERIFICATION_SESSION_PROCESSING = 'identity.verification_session.processing';
const TYPE_IDENTITY_VERIFICATION_SESSION_REDACTED = 'identity.verification_session.redacted';
const TYPE_IDENTITY_VERIFICATION_SESSION_REQUIRES_INPUT = 'identity.verification_session.requires_input';
const TYPE_IDENTITY_VERIFICATION_SESSION_VERIFIED = 'identity.verification_session.verified';
const TYPE_INVOICEITEM_CREATED = 'invoiceitem.created';
const TYPE_INVOICEITEM_DELETED = 'invoiceitem.deleted';
const TYPE_INVOICE_CREATED = 'invoice.created';
const TYPE_INVOICE_DELETED = 'invoice.deleted';
const TYPE_INVOICE_FINALIZATION_FAILED = 'invoice.finalization_failed';
const TYPE_INVOICE_FINALIZED = 'invoice.finalized';
const TYPE_INVOICE_MARKED_UNCOLLECTIBLE = 'invoice.marked_uncollectible';
const TYPE_INVOICE_OVERDUE = 'invoice.overdue';
const TYPE_INVOICE_OVERPAID = 'invoice.overpaid';
const TYPE_INVOICE_PAID = 'invoice.paid';
const TYPE_INVOICE_PAYMENT_ACTION_REQUIRED = 'invoice.payment_action_required';
const TYPE_INVOICE_PAYMENT_FAILED = 'invoice.payment_failed';
const TYPE_INVOICE_PAYMENT_PAID = 'invoice_payment.paid';
const TYPE_INVOICE_PAYMENT_SUCCEEDED = 'invoice.payment_succeeded';
const TYPE_INVOICE_SENT = 'invoice.sent';
const TYPE_INVOICE_UPCOMING = 'invoice.upcoming';
const TYPE_INVOICE_UPDATED = 'invoice.updated';
const TYPE_INVOICE_VOIDED = 'invoice.voided';
const TYPE_INVOICE_WILL_BE_DUE = 'invoice.will_be_due';
const TYPE_ISSUING_AUTHORIZATION_CREATED = 'issuing_authorization.created';
const TYPE_ISSUING_AUTHORIZATION_REQUEST = 'issuing_authorization.request';
const TYPE_ISSUING_AUTHORIZATION_UPDATED = 'issuing_authorization.updated';
const TYPE_ISSUING_CARDHOLDER_CREATED = 'issuing_cardholder.created';
const TYPE_ISSUING_CARDHOLDER_UPDATED = 'issuing_cardholder.updated';
const TYPE_ISSUING_CARD_CREATED = 'issuing_card.created';
const TYPE_ISSUING_CARD_UPDATED = 'issuing_card.updated';
const TYPE_ISSUING_DISPUTE_CLOSED = 'issuing_dispute.closed';
const TYPE_ISSUING_DISPUTE_CREATED = 'issuing_dispute.created';
const TYPE_ISSUING_DISPUTE_FUNDS_REINSTATED = 'issuing_dispute.funds_reinstated';
const TYPE_ISSUING_DISPUTE_FUNDS_RESCINDED = 'issuing_dispute.funds_rescinded';
const TYPE_ISSUING_DISPUTE_SUBMITTED = 'issuing_dispute.submitted';
const TYPE_ISSUING_DISPUTE_UPDATED = 'issuing_dispute.updated';
const TYPE_ISSUING_PERSONALIZATION_DESIGN_ACTIVATED = 'issuing_personalization_design.activated';
const TYPE_ISSUING_PERSONALIZATION_DESIGN_DEACTIVATED = 'issuing_personalization_design.deactivated';
const TYPE_ISSUING_PERSONALIZATION_DESIGN_REJECTED = 'issuing_personalization_design.rejected';
const TYPE_ISSUING_PERSONALIZATION_DESIGN_UPDATED = 'issuing_personalization_design.updated';
const TYPE_ISSUING_TOKEN_CREATED = 'issuing_token.created';
const TYPE_ISSUING_TOKEN_UPDATED = 'issuing_token.updated';
const TYPE_ISSUING_TRANSACTION_CREATED = 'issuing_transaction.created';
const TYPE_ISSUING_TRANSACTION_PURCHASE_DETAILS_RECEIPT_UPDATED = 'issuing_transaction.purchase_details_receipt_updated';
const TYPE_ISSUING_TRANSACTION_UPDATED = 'issuing_transaction.updated';
const TYPE_MANDATE_UPDATED = 'mandate.updated';
const TYPE_PAYMENT_INTENT_AMOUNT_CAPTURABLE_UPDATED = 'payment_intent.amount_capturable_updated';
const TYPE_PAYMENT_INTENT_CANCELED = 'payment_intent.canceled';
const TYPE_PAYMENT_INTENT_CREATED = 'payment_intent.created';
const TYPE_PAYMENT_INTENT_PARTIALLY_FUNDED = 'payment_intent.partially_funded';
const TYPE_PAYMENT_INTENT_PAYMENT_FAILED = 'payment_intent.payment_failed';
const TYPE_PAYMENT_INTENT_PROCESSING = 'payment_intent.processing';
const TYPE_PAYMENT_INTENT_REQUIRES_ACTION = 'payment_intent.requires_action';
const TYPE_PAYMENT_INTENT_SUCCEEDED = 'payment_intent.succeeded';
const TYPE_PAYMENT_LINK_CREATED = 'payment_link.created';
const TYPE_PAYMENT_LINK_UPDATED = 'payment_link.updated';
const TYPE_PAYMENT_METHOD_ATTACHED = 'payment_method.attached';
const TYPE_PAYMENT_METHOD_AUTOMATICALLY_UPDATED = 'payment_method.automatically_updated';
const TYPE_PAYMENT_METHOD_DETACHED = 'payment_method.detached';
const TYPE_PAYMENT_METHOD_UPDATED = 'payment_method.updated';
const TYPE_PAYOUT_CANCELED = 'payout.canceled';
const TYPE_PAYOUT_CREATED = 'payout.created';
const TYPE_PAYOUT_FAILED = 'payout.failed';
const TYPE_PAYOUT_PAID = 'payout.paid';
const TYPE_PAYOUT_RECONCILIATION_COMPLETED = 'payout.reconciliation_completed';
const TYPE_PAYOUT_UPDATED = 'payout.updated';
const TYPE_PERSON_CREATED = 'person.created';
const TYPE_PERSON_DELETED = 'person.deleted';
const TYPE_PERSON_UPDATED = 'person.updated';
const TYPE_PLAN_CREATED = 'plan.created';
const TYPE_PLAN_DELETED = 'plan.deleted';
const TYPE_PLAN_UPDATED = 'plan.updated';
const TYPE_PRICE_CREATED = 'price.created';
const TYPE_PRICE_DELETED = 'price.deleted';
const TYPE_PRICE_UPDATED = 'price.updated';
const TYPE_PRODUCT_CREATED = 'product.created';
const TYPE_PRODUCT_DELETED = 'product.deleted';
const TYPE_PRODUCT_UPDATED = 'product.updated';
const TYPE_PROMOTION_CODE_CREATED = 'promotion_code.created';
const TYPE_PROMOTION_CODE_UPDATED = 'promotion_code.updated';
const TYPE_QUOTE_ACCEPTED = 'quote.accepted';
const TYPE_QUOTE_CANCELED = 'quote.canceled';
const TYPE_QUOTE_CREATED = 'quote.created';
const TYPE_QUOTE_FINALIZED = 'quote.finalized';
const TYPE_RADAR_EARLY_FRAUD_WARNING_CREATED = 'radar.early_fraud_warning.created';
const TYPE_RADAR_EARLY_FRAUD_WARNING_UPDATED = 'radar.early_fraud_warning.updated';
const TYPE_REFUND_CREATED = 'refund.created';
const TYPE_REFUND_FAILED = 'refund.failed';
const TYPE_REFUND_UPDATED = 'refund.updated';
const TYPE_REPORTING_REPORT_RUN_FAILED = 'reporting.report_run.failed';
const TYPE_REPORTING_REPORT_RUN_SUCCEEDED = 'reporting.report_run.succeeded';
const TYPE_REPORTING_REPORT_TYPE_UPDATED = 'reporting.report_type.updated';
const TYPE_REVIEW_CLOSED = 'review.closed';
const TYPE_REVIEW_OPENED = 'review.opened';
const TYPE_SETUP_INTENT_CANCELED = 'setup_intent.canceled';
const TYPE_SETUP_INTENT_CREATED = 'setup_intent.created';
const TYPE_SETUP_INTENT_REQUIRES_ACTION = 'setup_intent.requires_action';
const TYPE_SETUP_INTENT_SETUP_FAILED = 'setup_intent.setup_failed';
const TYPE_SETUP_INTENT_SUCCEEDED = 'setup_intent.succeeded';
const TYPE_SIGMA_SCHEDULED_QUERY_RUN_CREATED = 'sigma.scheduled_query_run.created';
const TYPE_SOURCE_CANCELED = 'source.canceled';
const TYPE_SOURCE_CHARGEABLE = 'source.chargeable';
const TYPE_SOURCE_FAILED = 'source.failed';
const TYPE_SOURCE_MANDATE_NOTIFICATION = 'source.mandate_notification';
const TYPE_SOURCE_REFUND_ATTRIBUTES_REQUIRED = 'source.refund_attributes_required';
const TYPE_SOURCE_TRANSACTION_CREATED = 'source.transaction.created';
const TYPE_SOURCE_TRANSACTION_UPDATED = 'source.transaction.updated';
const TYPE_SUBSCRIPTION_SCHEDULE_ABORTED = 'subscription_schedule.aborted';
const TYPE_SUBSCRIPTION_SCHEDULE_CANCELED = 'subscription_schedule.canceled';
const TYPE_SUBSCRIPTION_SCHEDULE_COMPLETED = 'subscription_schedule.completed';
const TYPE_SUBSCRIPTION_SCHEDULE_CREATED = 'subscription_schedule.created';
const TYPE_SUBSCRIPTION_SCHEDULE_EXPIRING = 'subscription_schedule.expiring';
const TYPE_SUBSCRIPTION_SCHEDULE_RELEASED = 'subscription_schedule.released';
const TYPE_SUBSCRIPTION_SCHEDULE_UPDATED = 'subscription_schedule.updated';
const TYPE_TAX_RATE_CREATED = 'tax_rate.created';
const TYPE_TAX_RATE_UPDATED = 'tax_rate.updated';
const TYPE_TAX_SETTINGS_UPDATED = 'tax.settings.updated';
const TYPE_TERMINAL_READER_ACTION_FAILED = 'terminal.reader.action_failed';
const TYPE_TERMINAL_READER_ACTION_SUCCEEDED = 'terminal.reader.action_succeeded';
const TYPE_TEST_HELPERS_TEST_CLOCK_ADVANCING = 'test_helpers.test_clock.advancing';
const TYPE_TEST_HELPERS_TEST_CLOCK_CREATED = 'test_helpers.test_clock.created';
const TYPE_TEST_HELPERS_TEST_CLOCK_DELETED = 'test_helpers.test_clock.deleted';
const TYPE_TEST_HELPERS_TEST_CLOCK_INTERNAL_FAILURE = 'test_helpers.test_clock.internal_failure';
const TYPE_TEST_HELPERS_TEST_CLOCK_READY = 'test_helpers.test_clock.ready';
const TYPE_TOPUP_CANCELED = 'topup.canceled';
const TYPE_TOPUP_CREATED = 'topup.created';
const TYPE_TOPUP_FAILED = 'topup.failed';
const TYPE_TOPUP_REVERSED = 'topup.reversed';
const TYPE_TOPUP_SUCCEEDED = 'topup.succeeded';
const TYPE_TRANSFER_CREATED = 'transfer.created';
const TYPE_TRANSFER_REVERSED = 'transfer.reversed';
const TYPE_TRANSFER_UPDATED = 'transfer.updated';
const TYPE_TREASURY_CREDIT_REVERSAL_CREATED = 'treasury.credit_reversal.created';
const TYPE_TREASURY_CREDIT_REVERSAL_POSTED = 'treasury.credit_reversal.posted';
const TYPE_TREASURY_DEBIT_REVERSAL_COMPLETED = 'treasury.debit_reversal.completed';
const TYPE_TREASURY_DEBIT_REVERSAL_CREATED = 'treasury.debit_reversal.created';
const TYPE_TREASURY_DEBIT_REVERSAL_INITIAL_CREDIT_GRANTED = 'treasury.debit_reversal.initial_credit_granted';
const TYPE_TREASURY_FINANCIAL_ACCOUNT_CLOSED = 'treasury.financial_account.closed';
const TYPE_TREASURY_FINANCIAL_ACCOUNT_CREATED = 'treasury.financial_account.created';
const TYPE_TREASURY_FINANCIAL_ACCOUNT_FEATURES_STATUS_UPDATED = 'treasury.financial_account.features_status_updated';
const TYPE_TREASURY_INBOUND_TRANSFER_CANCELED = 'treasury.inbound_transfer.canceled';
const TYPE_TREASURY_INBOUND_TRANSFER_CREATED = 'treasury.inbound_transfer.created';
const TYPE_TREASURY_INBOUND_TRANSFER_FAILED = 'treasury.inbound_transfer.failed';
const TYPE_TREASURY_INBOUND_TRANSFER_SUCCEEDED = 'treasury.inbound_transfer.succeeded';
const TYPE_TREASURY_OUTBOUND_PAYMENT_CANCELED = 'treasury.outbound_payment.canceled';
const TYPE_TREASURY_OUTBOUND_PAYMENT_CREATED = 'treasury.outbound_payment.created';
const TYPE_TREASURY_OUTBOUND_PAYMENT_EXPECTED_ARRIVAL_DATE_UPDATED = 'treasury.outbound_payment.expected_arrival_date_updated';
const TYPE_TREASURY_OUTBOUND_PAYMENT_FAILED = 'treasury.outbound_payment.failed';
const TYPE_TREASURY_OUTBOUND_PAYMENT_POSTED = 'treasury.outbound_payment.posted';
const TYPE_TREASURY_OUTBOUND_PAYMENT_RETURNED = 'treasury.outbound_payment.returned';
const TYPE_TREASURY_OUTBOUND_PAYMENT_TRACKING_DETAILS_UPDATED = 'treasury.outbound_payment.tracking_details_updated';
const TYPE_TREASURY_OUTBOUND_TRANSFER_CANCELED = 'treasury.outbound_transfer.canceled';
const TYPE_TREASURY_OUTBOUND_TRANSFER_CREATED = 'treasury.outbound_transfer.created';
const TYPE_TREASURY_OUTBOUND_TRANSFER_EXPECTED_ARRIVAL_DATE_UPDATED = 'treasury.outbound_transfer.expected_arrival_date_updated';
const TYPE_TREASURY_OUTBOUND_TRANSFER_FAILED = 'treasury.outbound_transfer.failed';
const TYPE_TREASURY_OUTBOUND_TRANSFER_POSTED = 'treasury.outbound_transfer.posted';
const TYPE_TREASURY_OUTBOUND_TRANSFER_RETURNED = 'treasury.outbound_transfer.returned';
const TYPE_TREASURY_OUTBOUND_TRANSFER_TRACKING_DETAILS_UPDATED = 'treasury.outbound_transfer.tracking_details_updated';
const TYPE_TREASURY_RECEIVED_CREDIT_CREATED = 'treasury.received_credit.created';
const TYPE_TREASURY_RECEIVED_CREDIT_FAILED = 'treasury.received_credit.failed';
const TYPE_TREASURY_RECEIVED_CREDIT_SUCCEEDED = 'treasury.received_credit.succeeded';
const TYPE_TREASURY_RECEIVED_DEBIT_CREATED = 'treasury.received_debit.created';
/**
* List events, going back up to 30 days. Each event data is rendered according to
* Stripe API version at its creation time, specified in <a
* href="https://docs.stripe.com/api/events/object">event object</a>
* <code>api_version</code> attribute (not according to your current Stripe API
* version or <code>Stripe-Version</code> header).
*
* @param null|array{created?: array|int, delivery_success?: bool, ending_before?: string, expand?: string[], limit?: int, starting_after?: string, type?: string, types?: string[]} $params
* @param null|array|string $opts
*
* @return Collection<Event> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the details of an event if it was created in the last 30 days. Supply
* the unique identifier of the event, which you might have received in a webhook.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Event
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,13 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\EventData;
/**
* @property string $developer_message_summary Extra field included in the event's <code>data</code> when fetched from /v2/events.
* @property (object{error_count: int, error_types: (object{code: string, error_count: int, sample_errors: (object{error_message: string, request: (object{identifier: string}&\Stripe\StripeObject)}&\Stripe\StripeObject)[]}&\Stripe\StripeObject)[]}&\Stripe\StripeObject) $reason This contains information about why meter error happens.
* @property int $validation_end The end of the window that is encapsulated by this summary.
* @property int $validation_start The start of the window that is encapsulated by this summary.
*/
class V1BillingMeterErrorReportTriggeredEventData extends \Stripe\StripeObject {}

View File

@@ -0,0 +1,13 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\EventData;
/**
* @property string $developer_message_summary Extra field included in the event's <code>data</code> when fetched from /v2/events.
* @property (object{error_count: int, error_types: (object{code: string, error_count: int, sample_errors: (object{error_message: string, request: (object{identifier: string}&\Stripe\StripeObject)}&\Stripe\StripeObject)[]}&\Stripe\StripeObject)[]}&\Stripe\StripeObject) $reason This contains information about why meter error happens.
* @property int $validation_end The end of the window that is encapsulated by this summary.
* @property int $validation_start The start of the window that is encapsulated by this summary.
*/
class V1BillingMeterNoMeterFoundEventData extends \Stripe\StripeObject {}

View File

@@ -0,0 +1,46 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Events;
/**
* @property \Stripe\RelatedObject $related_object Object containing the reference to API resource relevant to the event
* @property \Stripe\EventData\V1BillingMeterErrorReportTriggeredEventData $data data associated with the event
*/
class V1BillingMeterErrorReportTriggeredEvent extends \Stripe\V2\Event
{
const LOOKUP_TYPE = 'v1.billing.meter.error_report_triggered';
/**
* Retrieves the related object from the API. Make an API request on every call.
*
* @return \Stripe\Billing\Meter
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function fetchRelatedObject()
{
$apiMode = \Stripe\Util\Util::getApiMode($this->related_object->url);
list($object, $options) = $this->_request(
'get',
$this->related_object->url,
[],
['stripe_account' => $this->context],
[],
$apiMode
);
return \Stripe\Util\Util::convertToStripeObject($object, $options, $apiMode);
}
public static function constructFrom($values, $opts = null, $apiMode = 'v2')
{
$evt = parent::constructFrom($values, $opts, $apiMode);
if (null !== $evt->data) {
$evt->data = \Stripe\EventData\V1BillingMeterErrorReportTriggeredEventData::constructFrom($evt->data, $opts, $apiMode);
}
return $evt;
}
}

View File

@@ -0,0 +1,23 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Events;
/**
* @property \Stripe\EventData\V1BillingMeterNoMeterFoundEventData $data data associated with the event
*/
class V1BillingMeterNoMeterFoundEvent extends \Stripe\V2\Event
{
const LOOKUP_TYPE = 'v1.billing.meter.no_meter_found';
public static function constructFrom($values, $opts = null, $apiMode = 'v2')
{
$evt = parent::constructFrom($values, $opts, $apiMode);
if (null !== $evt->data) {
$evt->data = \Stripe\EventData\V1BillingMeterNoMeterFoundEventData::constructFrom($evt->data, $opts, $apiMode);
}
return $evt;
}
}

View File

@@ -0,0 +1,35 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Events;
/**
* @property \Stripe\RelatedObject $related_object Object containing the reference to API resource relevant to the event
*/
class V2CoreEventDestinationPingEvent extends \Stripe\V2\Event
{
const LOOKUP_TYPE = 'v2.core.event_destination.ping';
/**
* Retrieves the related object from the API. Make an API request on every call.
*
* @return \Stripe\V2\EventDestination
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function fetchRelatedObject()
{
$apiMode = \Stripe\Util\Util::getApiMode($this->related_object->url);
list($object, $options) = $this->_request(
'get',
$this->related_object->url,
[],
['stripe_account' => $this->context],
[],
$apiMode
);
return \Stripe\Util\Util::convertToStripeObject($object, $options, $apiMode);
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Stripe\Exception;
/**
* ApiConnection is thrown in the event that the SDK can't connect to Stripe's
* servers. That can be for a variety of different reasons from a downed
* network to a bad TLS certificate.
*/
class ApiConnectionException extends ApiErrorException {}

View File

@@ -0,0 +1,220 @@
<?php
namespace Stripe\Exception;
/**
* Implements properties and methods common to all (non-SPL) Stripe exceptions.
*/
abstract class ApiErrorException extends \Exception implements ExceptionInterface
{
protected $error;
protected $httpBody;
protected $httpHeaders;
protected $httpStatus;
protected $jsonBody;
protected $requestId;
protected $stripeCode;
/**
* Creates a new API error exception.
*
* @param string $message the exception message
* @param null|int $httpStatus the HTTP status code
* @param null|string $httpBody the HTTP body as a string
* @param null|array $jsonBody the JSON deserialized body
* @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders the HTTP headers array
* @param null|string $stripeCode the Stripe error code
*
* @return static
*/
public static function factory(
$message,
$httpStatus = null,
$httpBody = null,
$jsonBody = null,
$httpHeaders = null,
$stripeCode = null
) {
$instance = new static($message);
$instance->setHttpStatus($httpStatus);
$instance->setHttpBody($httpBody);
$instance->setJsonBody($jsonBody);
$instance->setHttpHeaders($httpHeaders);
$instance->setStripeCode($stripeCode);
$instance->setRequestId(null);
if ($httpHeaders && isset($httpHeaders['Request-Id'])) {
$instance->setRequestId($httpHeaders['Request-Id']);
}
$instance->setError($instance->constructErrorObject());
return $instance;
}
/**
* Gets the Stripe error object.
*
* @return null|\Stripe\ErrorObject
*/
public function getError()
{
return $this->error;
}
/**
* Sets the Stripe error object.
*
* @param null|\Stripe\ErrorObject $error
*/
public function setError($error)
{
$this->error = $error;
}
/**
* Gets the HTTP body as a string.
*
* @return null|string
*/
public function getHttpBody()
{
return $this->httpBody;
}
/**
* Sets the HTTP body as a string.
*
* @param null|string $httpBody
*/
public function setHttpBody($httpBody)
{
$this->httpBody = $httpBody;
}
/**
* Gets the HTTP headers array.
*
* @return null|array|\Stripe\Util\CaseInsensitiveArray
*/
public function getHttpHeaders()
{
return $this->httpHeaders;
}
/**
* Sets the HTTP headers array.
*
* @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders
*/
public function setHttpHeaders($httpHeaders)
{
$this->httpHeaders = $httpHeaders;
}
/**
* Gets the HTTP status code.
*
* @return null|int
*/
public function getHttpStatus()
{
return $this->httpStatus;
}
/**
* Sets the HTTP status code.
*
* @param null|int $httpStatus
*/
public function setHttpStatus($httpStatus)
{
$this->httpStatus = $httpStatus;
}
/**
* Gets the JSON deserialized body.
*
* @return null|array<string, mixed>
*/
public function getJsonBody()
{
return $this->jsonBody;
}
/**
* Sets the JSON deserialized body.
*
* @param null|array<string, mixed> $jsonBody
*/
public function setJsonBody($jsonBody)
{
$this->jsonBody = $jsonBody;
}
/**
* Gets the Stripe request ID.
*
* @return null|string
*/
public function getRequestId()
{
return $this->requestId;
}
/**
* Sets the Stripe request ID.
*
* @param null|string $requestId
*/
public function setRequestId($requestId)
{
$this->requestId = $requestId;
}
/**
* Gets the Stripe error code.
*
* Cf. the `CODE_*` constants on {@see \Stripe\ErrorObject} for possible
* values.
*
* @return null|string
*/
public function getStripeCode()
{
return $this->stripeCode;
}
/**
* Sets the Stripe error code.
*
* @param null|string $stripeCode
*/
public function setStripeCode($stripeCode)
{
$this->stripeCode = $stripeCode;
}
/**
* Returns the string representation of the exception.
*
* @return string
*/
public function __toString()
{
$parentStr = parent::__toString();
$statusStr = (null === $this->getHttpStatus()) ? '' : "(Status {$this->getHttpStatus()}) ";
$idStr = (null === $this->getRequestId()) ? '' : "(Request {$this->getRequestId()}) ";
return "Error sending request to Stripe: {$statusStr}{$idStr}{$this->getMessage()}\n{$parentStr}";
}
protected function constructErrorObject()
{
if (null === $this->jsonBody || !\array_key_exists('error', $this->jsonBody)) {
return null;
}
return \Stripe\ErrorObject::constructFrom($this->jsonBody['error']);
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Stripe\Exception;
/**
* AuthenticationException is thrown when invalid credentials are used to
* connect to Stripe's servers.
*/
class AuthenticationException extends ApiErrorException {}

View File

@@ -0,0 +1,5 @@
<?php
namespace Stripe\Exception;
class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface {}

View File

@@ -0,0 +1,84 @@
<?php
namespace Stripe\Exception;
/**
* CardException is thrown when a user enters a card that can't be charged for
* some reason.
*/
class CardException extends ApiErrorException
{
protected $declineCode;
protected $stripeParam;
/**
* Creates a new CardException exception.
*
* @param string $message the exception message
* @param null|int $httpStatus the HTTP status code
* @param null|string $httpBody the HTTP body as a string
* @param null|array $jsonBody the JSON deserialized body
* @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders the HTTP headers array
* @param null|string $stripeCode the Stripe error code
* @param null|string $declineCode the decline code
* @param null|string $stripeParam the parameter related to the error
*
* @return CardException
*/
public static function factory(
$message,
$httpStatus = null,
$httpBody = null,
$jsonBody = null,
$httpHeaders = null,
$stripeCode = null,
$declineCode = null,
$stripeParam = null
) {
$instance = parent::factory($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders, $stripeCode);
$instance->setDeclineCode($declineCode);
$instance->setStripeParam($stripeParam);
return $instance;
}
/**
* Gets the decline code.
*
* @return null|string
*/
public function getDeclineCode()
{
return $this->declineCode;
}
/**
* Sets the decline code.
*
* @param null|string $declineCode
*/
public function setDeclineCode($declineCode)
{
$this->declineCode = $declineCode;
}
/**
* Gets the parameter related to the error.
*
* @return null|string
*/
public function getStripeParam()
{
return $this->stripeParam;
}
/**
* Sets the parameter related to the error.
*
* @param null|string $stripeParam
*/
public function setStripeParam($stripeParam)
{
$this->stripeParam = $stripeParam;
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Stripe\Exception;
// TODO: remove this check once we drop support for PHP 5
if (\interface_exists(\Throwable::class, false)) {
/**
* The base interface for all Stripe exceptions.
*/
interface ExceptionInterface extends \Throwable {}
} else {
/**
* The base interface for all Stripe exceptions.
*/
// phpcs:disable PSR1.Classes.ClassDeclaration.MultipleClasses
interface ExceptionInterface {}
// phpcs:enable
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Stripe\Exception;
/**
* IdempotencyException is thrown in cases where an idempotency key was used
* improperly.
*/
class IdempotencyException extends ApiErrorException {}

View File

@@ -0,0 +1,5 @@
<?php
namespace Stripe\Exception;
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface {}

View File

@@ -0,0 +1,60 @@
<?php
namespace Stripe\Exception;
/**
* InvalidRequestException is thrown when a request is initiated with invalid
* parameters.
*/
class InvalidRequestException extends ApiErrorException
{
protected $stripeParam;
/**
* Creates a new InvalidRequestException exception.
*
* @param string $message the exception message
* @param null|int $httpStatus the HTTP status code
* @param null|string $httpBody the HTTP body as a string
* @param null|array $jsonBody the JSON deserialized body
* @param null|array|\Stripe\Util\CaseInsensitiveArray $httpHeaders the HTTP headers array
* @param null|string $stripeCode the Stripe error code
* @param null|string $stripeParam the parameter related to the error
*
* @return InvalidRequestException
*/
public static function factory(
$message,
$httpStatus = null,
$httpBody = null,
$jsonBody = null,
$httpHeaders = null,
$stripeCode = null,
$stripeParam = null
) {
$instance = parent::factory($message, $httpStatus, $httpBody, $jsonBody, $httpHeaders, $stripeCode);
$instance->setStripeParam($stripeParam);
return $instance;
}
/**
* Gets the parameter related to the error.
*
* @return null|string
*/
public function getStripeParam()
{
return $this->stripeParam;
}
/**
* Sets the parameter related to the error.
*
* @param null|string $stripeParam
*/
public function setStripeParam($stripeParam)
{
$this->stripeParam = $stripeParam;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* The base interface for all Stripe OAuth exceptions.
*/
interface ExceptionInterface extends \Stripe\Exception\ExceptionInterface {}

View File

@@ -0,0 +1,10 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* InvalidClientException is thrown when the client_id does not belong to you,
* the stripe_user_id does not exist or is not connected to your application,
* or the API key mode (live or test mode) does not match the client_id mode.
*/
class InvalidClientException extends OAuthErrorException {}

View File

@@ -0,0 +1,11 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* InvalidGrantException is thrown when a specified code doesn't exist, is
* expired, has been used, or doesn't belong to you; a refresh token doesn't
* exist, or doesn't belong to you; or if an API key's mode (live or test)
* doesn't match the mode of a code or refresh token.
*/
class InvalidGrantException extends OAuthErrorException {}

View File

@@ -0,0 +1,9 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* InvalidRequestException is thrown when a code, refresh token, or grant
* type parameter is not provided, but was required.
*/
class InvalidRequestException extends OAuthErrorException {}

View File

@@ -0,0 +1,8 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* InvalidScopeException is thrown when an invalid scope parameter is provided.
*/
class InvalidScopeException extends OAuthErrorException {}

View File

@@ -0,0 +1,19 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* Implements properties and methods common to all (non-SPL) Stripe OAuth
* exceptions.
*/
abstract class OAuthErrorException extends \Stripe\Exception\ApiErrorException
{
protected function constructErrorObject()
{
if (null === $this->jsonBody) {
return null;
}
return \Stripe\OAuthErrorObject::constructFrom($this->jsonBody);
}
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* UnknownApiErrorException is thrown when the client library receives an
* error from the OAuth API it doesn't know about. Receiving this error usually
* means that your client library is outdated and should be upgraded.
*/
class UnknownOAuthErrorException extends OAuthErrorException {}

View File

@@ -0,0 +1,9 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* UnsupportedGrantTypeException is thrown when an unuspported grant type
* parameter is specified.
*/
class UnsupportedGrantTypeException extends OAuthErrorException {}

View File

@@ -0,0 +1,9 @@
<?php
namespace Stripe\Exception\OAuth;
/**
* UnsupportedResponseTypeException is thrown when an unsupported response type
* parameter is specified.
*/
class UnsupportedResponseTypeException extends OAuthErrorException {}

View File

@@ -0,0 +1,9 @@
<?php
namespace Stripe\Exception;
/**
* PermissionException is thrown in cases where access was attempted on a
* resource that wasn't allowed.
*/
class PermissionException extends ApiErrorException {}

View File

@@ -0,0 +1,10 @@
<?php
namespace Stripe\Exception;
/**
* RateLimitException is thrown in cases where an account is putting too much
* load on Stripe's API servers (usually by performing too many requests).
* Please back off on request rate.
*/
class RateLimitException extends InvalidRequestException {}

View File

@@ -0,0 +1,74 @@
<?php
namespace Stripe\Exception;
/**
* SignatureVerificationException is thrown when the signature verification for
* a webhook fails.
*/
class SignatureVerificationException extends \Exception implements ExceptionInterface
{
protected $httpBody;
protected $sigHeader;
/**
* Creates a new SignatureVerificationException exception.
*
* @param string $message the exception message
* @param null|string $httpBody the HTTP body as a string
* @param null|string $sigHeader the `Stripe-Signature` HTTP header
*
* @return SignatureVerificationException
*/
public static function factory(
$message,
$httpBody = null,
$sigHeader = null
) {
$instance = new static($message);
$instance->setHttpBody($httpBody);
$instance->setSigHeader($sigHeader);
return $instance;
}
/**
* Gets the HTTP body as a string.
*
* @return null|string
*/
public function getHttpBody()
{
return $this->httpBody;
}
/**
* Sets the HTTP body as a string.
*
* @param null|string $httpBody
*/
public function setHttpBody($httpBody)
{
$this->httpBody = $httpBody;
}
/**
* Gets the `Stripe-Signature` HTTP header.
*
* @return null|string
*/
public function getSigHeader()
{
return $this->sigHeader;
}
/**
* Sets the `Stripe-Signature` HTTP header.
*
* @param null|string $sigHeader
*/
public function setSigHeader($sigHeader)
{
$this->sigHeader = $sigHeader;
}
}

View File

@@ -0,0 +1,7 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Exception;
class TemporarySessionExpiredException extends ApiErrorException {}

View File

@@ -0,0 +1,5 @@
<?php
namespace Stripe\Exception;
class UnexpectedValueException extends \UnexpectedValueException implements ExceptionInterface {}

View File

@@ -0,0 +1,10 @@
<?php
namespace Stripe\Exception;
/**
* UnknownApiErrorException is thrown when the client library receives an
* error from the API it doesn't know about. Receiving this error usually
* means that your client library is outdated and should be upgraded.
*/
class UnknownApiErrorException extends ApiErrorException {}

View File

@@ -0,0 +1,80 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* <code>ExchangeRate</code> objects allow you to determine the rates that Stripe is currently
* using to convert from one currency to another. Since this number is variable
* throughout the day, there are various reasons why you might want to know the current
* rate (for example, to dynamically price an item for a user with a default
* payment in a foreign currency).
*
* Please refer to our <a href="https://stripe.com/docs/fx-rates">Exchange Rates API</a> guide for more details.
*
* <em>[Note: this integration path is supported but no longer recommended]</em> Additionally,
* you can guarantee that a charge is made with an exchange rate that you expect is
* current. To do so, you must pass in the exchange_rate to charges endpoints. If the
* value is no longer up to date, the charge won't go through. Please refer to our
* <a href="https://stripe.com/docs/exchange-rates">Using with charges</a> guide for more details.
*
* -----
*
*
*
* <em>This Exchange Rates API is a Beta Service and is subject to Stripe's terms of service. You may use the API solely for the purpose of transacting on Stripe. For example, the API may be queried in order to:</em>
*
* - <em>localize prices for processing payments on Stripe</em>
* - <em>reconcile Stripe transactions</em>
* - <em>determine how much money to send to a connected account</em>
* - <em>determine app fees to charge a connected account</em>
*
* <em>Using this Exchange Rates API beta for any purpose other than to transact on Stripe is strictly prohibited and constitutes a violation of Stripe's terms of service.</em>
*
* @property string $id Unique identifier for the object. Represented as the three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a> in lowercase.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property StripeObject $rates Hash where the keys are supported currencies and the values are the exchange rate at which the base id currency converts to the key currency.
*/
class ExchangeRate extends ApiResource
{
const OBJECT_NAME = 'exchange_rate';
/**
* Returns a list of objects that contain the rates at which foreign currencies are
* converted to one another. Only shows the currencies for which Stripe supports.
*
* @param null|array{ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<ExchangeRate> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the exchange rates from the given currency to every supported
* currency.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return ExchangeRate
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

120
vendor/stripe/stripe-php/lib/File.php vendored Normal file
View File

@@ -0,0 +1,120 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* This object represents files hosted on Stripe's servers. You can upload
* files with the <a href="https://stripe.com/docs/api#create_file">create file</a> request
* (for example, when uploading dispute evidence). Stripe also
* creates files independently (for example, the results of a <a href="#scheduled_queries">Sigma scheduled
* query</a>).
*
* Related guide: <a href="https://stripe.com/docs/file-upload">File upload guide</a>
*
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property null|int $expires_at The file expires and isn't available at this time in epoch seconds.
* @property null|string $filename The suitable name for saving the file to a filesystem.
* @property null|Collection<FileLink> $links A list of <a href="https://stripe.com/docs/api#file_links">file links</a> that point at this file.
* @property string $purpose The <a href="https://stripe.com/docs/file-upload#uploading-a-file">purpose</a> of the uploaded file.
* @property int $size The size of the file object in bytes.
* @property null|string $title A suitable title for the document.
* @property null|string $type The returned file type (for example, <code>csv</code>, <code>pdf</code>, <code>jpg</code>, or <code>png</code>).
* @property null|string $url Use your live secret API key to download the file from this URL.
*/
class File extends ApiResource
{
const OBJECT_NAME = 'file';
const PURPOSE_ACCOUNT_REQUIREMENT = 'account_requirement';
const PURPOSE_ADDITIONAL_VERIFICATION = 'additional_verification';
const PURPOSE_BUSINESS_ICON = 'business_icon';
const PURPOSE_BUSINESS_LOGO = 'business_logo';
const PURPOSE_CUSTOMER_SIGNATURE = 'customer_signature';
const PURPOSE_DISPUTE_EVIDENCE = 'dispute_evidence';
const PURPOSE_DOCUMENT_PROVIDER_IDENTITY_DOCUMENT = 'document_provider_identity_document';
const PURPOSE_FINANCE_REPORT_RUN = 'finance_report_run';
const PURPOSE_FINANCIAL_ACCOUNT_STATEMENT = 'financial_account_statement';
const PURPOSE_IDENTITY_DOCUMENT = 'identity_document';
const PURPOSE_IDENTITY_DOCUMENT_DOWNLOADABLE = 'identity_document_downloadable';
const PURPOSE_ISSUING_REGULATORY_REPORTING = 'issuing_regulatory_reporting';
const PURPOSE_PCI_DOCUMENT = 'pci_document';
const PURPOSE_SELFIE = 'selfie';
const PURPOSE_SIGMA_SCHEDULED_QUERY = 'sigma_scheduled_query';
const PURPOSE_TAX_DOCUMENT_USER_UPLOAD = 'tax_document_user_upload';
const PURPOSE_TERMINAL_READER_SPLASHSCREEN = 'terminal_reader_splashscreen';
/**
* Returns a list of the files that your account has access to. Stripe sorts and
* returns the files by their creation dates, placing the most recently created
* files at the top.
*
* @param null|array{created?: array|int, ending_before?: string, expand?: string[], limit?: int, purpose?: string, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<File> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the details of an existing file object. After you supply a unique file
* ID, Stripe returns the corresponding file object. Learn how to <a
* href="/docs/file-upload#download-file-contents">access file contents</a>.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return File
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
// This resource can have two different object names. In latter API
// versions, only `file` is used, but since stripe-php may be used with
// any API version, we need to support deserializing the older
// `file_upload` object into the same class.
const OBJECT_NAME_ALT = 'file_upload';
use ApiOperations\Create {
create as protected _create;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return File the created file
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
if (null === $opts->apiBase) {
$opts->apiBase = Stripe::$apiUploadBase;
}
// Manually flatten params, otherwise curl's multipart encoder will
// choke on nested arrays.
$flatParams = \array_column(Util\Util::flattenParams($params), 1, 0);
return static::_create($flatParams, $opts);
}
}

View File

@@ -0,0 +1,108 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe;
/**
* To share the contents of a <code>File</code> object with non-Stripe users, you can
* create a <code>FileLink</code>. <code>FileLink</code>s contain a URL that you can use to
* retrieve the contents of the file without authentication.
*
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property bool $expired Returns if the link is already expired.
* @property null|int $expires_at Time that the link expires.
* @property File|string $file The file object this link points to.
* @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 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 null|string $url The publicly accessible URL to download the file.
*/
class FileLink extends ApiResource
{
const OBJECT_NAME = 'file_link';
use ApiOperations\Update;
/**
* Creates a new file link object.
*
* @param null|array{expand?: string[], expires_at?: int, file: string, metadata?: null|array<string, string>} $params
* @param null|array|string $options
*
* @return FileLink the created resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Returns a list of file links.
*
* @param null|array{created?: array|int, ending_before?: string, expand?: string[], expired?: bool, file?: string, limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return Collection<FileLink> of ApiResources
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, Collection::class, $params, $opts);
}
/**
* Retrieves the file link with the given ID.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return FileLink
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* Updates an existing file link object. Expired links can no longer be updated.
*
* @param string $id the ID of the resource to update
* @param null|array{expand?: string[], expires_at?: null|array|int|string, metadata?: null|array<string, string>} $params
* @param null|array|string $opts
*
* @return FileLink the updated resource
*
* @throws Exception\ApiErrorException if the request fails
*/
public static function update($id, $params = null, $opts = null)
{
self::_validateParams($params);
$url = static::resourceUrl($id);
list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
$obj = Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
}

View File

@@ -0,0 +1,172 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\FinancialConnections;
/**
* A Financial Connections Account represents an account that exists outside of Stripe, to which you have been granted some degree of access.
*
* @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|(object{account?: string|\Stripe\Account, customer?: string|\Stripe\Customer, type: string}&\Stripe\StripeObject) $account_holder The account holder that this account belongs to.
* @property null|(object{as_of: int, cash?: (object{available: null|\Stripe\StripeObject}&\Stripe\StripeObject), credit?: (object{used: null|\Stripe\StripeObject}&\Stripe\StripeObject), current: \Stripe\StripeObject, type: string}&\Stripe\StripeObject) $balance The most recent information about the account's balance.
* @property null|(object{last_attempted_at: int, next_refresh_available_at: null|int, status: string}&\Stripe\StripeObject) $balance_refresh The state of the most recent attempt to refresh the account balance.
* @property string $category The type of the account. Account category is further divided in <code>subcategory</code>.
* @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 <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property null|AccountOwnership|string $ownership The most recent information about the account's owners.
* @property null|(object{last_attempted_at: int, next_refresh_available_at: null|int, status: string}&\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 <p>If <code>category</code> is <code>cash</code>, one of:</p><p>- <code>checking</code> - <code>savings</code> - <code>other</code></p><p>If <code>category</code> is <code>credit</code>, one of:</p><p>- <code>mortgage</code> - <code>line_of_credit</code> - <code>credit_card</code> - <code>other</code></p><p>If <code>category</code> is <code>investment</code> or <code>other</code>, this will be <code>other</code>.</p>
* @property null|string[] $subscriptions The list of data refresh subscriptions requested on this account.
* @property string[] $supported_payment_method_types The <a href="https://stripe.com/docs/api/payment_methods/object#payment_method_object-type">PaymentMethod type</a>(s) that can be created from this account.
* @property null|(object{id: string, last_attempted_at: int, next_refresh_available_at: null|int, status: string}&\Stripe\StripeObject) $transaction_refresh The state of the most recent attempt to refresh the account transactions.
*/
class Account extends \Stripe\ApiResource
{
const OBJECT_NAME = 'financial_connections.account';
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';
/**
* Returns a list of Financial Connections <code>Account</code> objects.
*
* @param null|array{account_holder?: array{account?: string, customer?: string}, ending_before?: string, expand?: string[], limit?: int, session?: string, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Account> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves the details of an Financial Connections <code>Account</code>.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Account
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Account the disconnected account
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
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 string $id
* @param null|array $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<AccountOwner> list of account owners
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
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
*
* @return Account the refreshed account
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function refreshAccount($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/refresh';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Account the subscribed account
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function subscribe($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/subscribe';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
/**
* @param null|array $params
* @param null|array|string $opts
*
* @return Account the unsubscribed account
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public function unsubscribe($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/unsubscribe';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);
return $this;
}
}

View File

@@ -0,0 +1,22 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\FinancialConnections;
/**
* Describes an owner of an account.
*
* @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 $email The email address of the owner.
* @property string $name The full name of the owner.
* @property string $ownership The ownership object that this owner belongs to.
* @property null|string $phone The raw phone number of the owner.
* @property null|string $raw_address The raw physical address of the owner.
* @property null|int $refreshed_at The timestamp of the refresh that updated this owner.
*/
class AccountOwner extends \Stripe\ApiResource
{
const OBJECT_NAME = 'financial_connections.account_owner';
}

View File

@@ -0,0 +1,18 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\FinancialConnections;
/**
* Describes a snapshot of the owners of an account at a particular point in time.
*
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property \Stripe\Collection<AccountOwner> $owners A paginated list of owners for this account.
*/
class AccountOwnership extends \Stripe\ApiResource
{
const OBJECT_NAME = 'financial_connections.account_ownership';
}

View File

@@ -0,0 +1,67 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\FinancialConnections;
/**
* A Financial Connections Session is the secure way to programmatically launch the client-side Stripe.js modal that lets your users link their accounts.
*
* @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|(object{account?: string|\Stripe\Account, customer?: string|\Stripe\Customer, type: string}&\Stripe\StripeObject) $account_holder The account holder for whom accounts are collected in this session.
* @property \Stripe\Collection<Account> $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 null|(object{account_subcategories: null|string[], countries: null|string[]}&\Stripe\StripeObject) $filters
* @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 string[] $permissions Permissions requested for accounts collected during this session.
* @property null|string[] $prefetch Data features requested to be retrieved upon account creation.
* @property null|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';
/**
* To launch the Financial Connections authorization flow, create a
* <code>Session</code>. The sessions <code>client_secret</code> can be used to
* launch the flow using Stripe.js.
*
* @param null|array{account_holder: array{account?: string, customer?: string, type: string}, expand?: string[], filters?: array{account_subcategories?: string[], countries?: string[]}, permissions: string[], prefetch?: string[], return_url?: string} $params
* @param null|array|string $options
*
* @return Session the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Retrieves the details of a Financial Connections <code>Session</code>.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Session
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,66 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\FinancialConnections;
/**
* A Transaction represents a real transaction that affects a Financial Connections Account 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 string $account The ID of the Financial Connections Account this transaction belongs to.
* @property int $amount The amount of this transaction, in cents (or local equivalent).
* @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 $description The description of this transaction.
* @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 string $status The status of the transaction.
* @property (object{posted_at: null|int, void_at: null|int}&\Stripe\StripeObject) $status_transitions
* @property int $transacted_at Time at which the transaction was transacted. Measured in seconds since the Unix epoch.
* @property string $transaction_refresh The token of the transaction refresh that last updated or created this transaction.
* @property int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
*/
class Transaction extends \Stripe\ApiResource
{
const OBJECT_NAME = 'financial_connections.transaction';
const STATUS_PENDING = 'pending';
const STATUS_POSTED = 'posted';
const STATUS_VOID = 'void';
/**
* Returns a list of Financial Connections <code>Transaction</code> objects.
*
* @param null|array{account: string, ending_before?: string, expand?: string[], limit?: int, starting_after?: string, transacted_at?: array|int, transaction_refresh?: array{after: string}} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Transaction> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves the details of a Financial Connections <code>Transaction</code>.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Transaction
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

View File

@@ -0,0 +1,98 @@
<?php
// File generated from our OpenAPI spec
namespace Stripe\Forwarding;
/**
* Instructs Stripe to make a request on your behalf using the destination URL. The destination URL
* is activated by Stripe at the time of onboarding. Stripe verifies requests with your credentials
* provided during onboarding, and injects card details from the payment_method into the request.
*
* Stripe redacts all sensitive fields and headers, including authentication credentials and card numbers,
* before storing the request and response data in the forwarding Request object, which are subject to a
* 30-day retention period.
*
* You can provide a Stripe idempotency key to make sure that requests with the same key result in only one
* outbound request. The Stripe idempotency key provided should be unique and different from any idempotency
* keys provided on the underlying third-party request.
*
* Forwarding Requests are synchronous requests that return a response or time out according to
* Stripes limits.
*
* Related guide: <a href="https://docs.stripe.com/payments/forwarding">Forward card details to third-party API endpoints</a>.
*
* @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 $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @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 null|\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 string $payment_method The PaymentMethod to insert into the forwarded request. Forwarding previously consumed PaymentMethods is allowed.
* @property string[] $replacements The field kinds to be replaced in the forwarded request.
* @property null|(object{destination_duration: int, destination_ip_address: string}&\Stripe\StripeObject) $request_context Context about the request from Stripe's servers to the destination endpoint.
* @property null|(object{body: string, headers: (object{name: string, value: string}&\Stripe\StripeObject)[], http_method: string}&\Stripe\StripeObject) $request_details The request that was sent to the destination endpoint. We redact any sensitive fields.
* @property null|(object{body: string, headers: (object{name: string, value: string}&\Stripe\StripeObject)[], status: int}&\Stripe\StripeObject) $response_details The response that the destination endpoint returned to us. We redact any sensitive fields.
* @property null|string $url The destination URL for the forwarded request. Must be supported by the config.
*/
class Request extends \Stripe\ApiResource
{
const OBJECT_NAME = 'forwarding.request';
/**
* Creates a ForwardingRequest object.
*
* @param null|array{expand?: string[], metadata?: array<string, string>, payment_method: string, replacements: string[], request: array{body?: string, headers?: array{name: string, value: string}[]}, url: string} $params
* @param null|array|string $options
*
* @return Request the created resource
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function create($params = null, $options = null)
{
self::_validateParams($params);
$url = static::classUrl();
list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);
return $obj;
}
/**
* Lists all ForwardingRequest objects.
*
* @param null|array{created?: array{gt?: int, gte?: int, lt?: int, lte?: int}, ending_before?: string, expand?: string[], limit?: int, starting_after?: string} $params
* @param null|array|string $opts
*
* @return \Stripe\Collection<Request> of ApiResources
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function all($params = null, $opts = null)
{
$url = static::classUrl();
return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
}
/**
* Retrieves a ForwardingRequest object.
*
* @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
* @param null|array|string $opts
*
* @return Request
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*/
public static function retrieve($id, $opts = null)
{
$opts = \Stripe\Util\RequestOptions::parse($opts);
$instance = new static($id, $opts);
$instance->refresh();
return $instance;
}
}

Some files were not shown because too many files have changed in this diff Show More