diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 23ee098c2..bf758c50a 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v261 \ No newline at end of file +v276 \ No newline at end of file diff --git a/init.php b/init.php index 5555d8f9a..315f70a22 100644 --- a/init.php +++ b/init.php @@ -156,6 +156,10 @@ require __DIR__ . '/lib/Subscription.php'; require __DIR__ . '/lib/SubscriptionItem.php'; require __DIR__ . '/lib/SubscriptionSchedule.php'; +require __DIR__ . '/lib/Tax/Calculation.php'; +require __DIR__ . '/lib/Tax/CalculationLineItem.php'; +require __DIR__ . '/lib/Tax/Transaction.php'; +require __DIR__ . '/lib/Tax/TransactionLineItem.php'; require __DIR__ . '/lib/TaxCode.php'; require __DIR__ . '/lib/TaxId.php'; require __DIR__ . '/lib/TaxRate.php'; @@ -241,6 +245,8 @@ require __DIR__ . '/lib/Service/SubscriptionService.php'; require __DIR__ . '/lib/Service/SubscriptionItemService.php'; require __DIR__ . '/lib/Service/SubscriptionScheduleService.php'; +require __DIR__ . '/lib/Service/Tax/CalculationService.php'; +require __DIR__ . '/lib/Service/Tax/TransactionService.php'; require __DIR__ . '/lib/Service/TaxCodeService.php'; require __DIR__ . '/lib/Service/TaxRateService.php'; require __DIR__ . '/lib/Service/Terminal/ConfigurationService.php'; @@ -283,6 +289,7 @@ require __DIR__ . '/lib/Service/Radar/RadarServiceFactory.php'; require __DIR__ . '/lib/Service/Reporting/ReportingServiceFactory.php'; require __DIR__ . '/lib/Service/Sigma/SigmaServiceFactory.php'; +require __DIR__ . '/lib/Service/Tax/TaxServiceFactory.php'; require __DIR__ . '/lib/Service/Terminal/TerminalServiceFactory.php'; require __DIR__ . '/lib/Service/TestHelpers/Issuing/IssuingServiceFactory.php'; require __DIR__ . '/lib/Service/TestHelpers/Terminal/TerminalServiceFactory.php'; diff --git a/lib/Checkout/Session.php b/lib/Checkout/Session.php index acfecef13..d6f97ad36 100644 --- a/lib/Checkout/Session.php +++ b/lib/Checkout/Session.php @@ -37,6 +37,7 @@ * @property null|\Stripe\StripeObject $consent_collection When set, provides configuration for the Checkout Session to gather active consent from customers. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. * @property null|string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. + * @property null|\Stripe\StripeObject $currency_conversion Currency conversion details for automatic currency conversion sessions * @property \Stripe\StripeObject[] $custom_fields Collect additional information from your customer using custom fields. Up to 2 fields are supported. * @property \Stripe\StripeObject $custom_text * @property null|string|\Stripe\Customer $customer The ID of the customer for this Session. For Checkout Sessions in payment or subscription mode, Checkout will create a new customer object based on information provided during the payment flow unless an existing customer was provided when the Session was created. diff --git a/lib/Service/CoreServiceFactory.php b/lib/Service/CoreServiceFactory.php index 351f6913e..5bd3f3c69 100644 --- a/lib/Service/CoreServiceFactory.php +++ b/lib/Service/CoreServiceFactory.php @@ -55,6 +55,7 @@ * @property SubscriptionItemService $subscriptionItems * @property SubscriptionService $subscriptions * @property SubscriptionScheduleService $subscriptionSchedules + * @property Tax\TaxServiceFactory $tax * @property TaxCodeService $taxCodes * @property TaxRateService $taxRates * @property Terminal\TerminalServiceFactory $terminal @@ -119,6 +120,7 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory 'subscriptionItems' => SubscriptionItemService::class, 'subscriptions' => SubscriptionService::class, 'subscriptionSchedules' => SubscriptionScheduleService::class, + 'tax' => Tax\TaxServiceFactory::class, 'taxCodes' => TaxCodeService::class, 'taxRates' => TaxRateService::class, 'terminal' => Terminal\TerminalServiceFactory::class, diff --git a/lib/Service/Tax/CalculationService.php b/lib/Service/Tax/CalculationService.php new file mode 100644 index 000000000..dfb4b9046 --- /dev/null +++ b/lib/Service/Tax/CalculationService.php @@ -0,0 +1,39 @@ + + */ + public function allLineItems($id, $params = null, $opts = null) + { + return $this->requestCollection('get', $this->buildPath('/v1/tax/calculations/%s/line_items', $id), $params, $opts); + } + + /** + * Calculates tax based on input and returns a Tax Calculation object. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Calculation + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/tax/calculations', $params, $opts); + } +} diff --git a/lib/Service/Tax/TaxServiceFactory.php b/lib/Service/Tax/TaxServiceFactory.php new file mode 100644 index 000000000..6f645a17d --- /dev/null +++ b/lib/Service/Tax/TaxServiceFactory.php @@ -0,0 +1,27 @@ + + */ + private static $classMap = [ + 'calculations' => CalculationService::class, + 'transactions' => TransactionService::class, + ]; + + protected function getServiceClass($name) + { + return \array_key_exists($name, self::$classMap) ? self::$classMap[$name] : null; + } +} diff --git a/lib/Service/Tax/TransactionService.php b/lib/Service/Tax/TransactionService.php new file mode 100644 index 000000000..f8e65fd32 --- /dev/null +++ b/lib/Service/Tax/TransactionService.php @@ -0,0 +1,85 @@ + + */ + public function allLineItems($id, $params = null, $opts = null) + { + return $this->requestCollection('get', $this->buildPath('/v1/tax/transactions/%s/line_items', $id), $params, $opts); + } + + /** + * Creates a Tax Transaction from a calculation. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Transaction + */ + public function create($params = null, $opts = null) + { + return $this->request('post', '/v1/tax/transactions', $params, $opts); + } + + /** + * Creates a Tax Transaction from a calculation. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Transaction + */ + public function createFromCalculation($params = null, $opts = null) + { + return $this->request('post', '/v1/tax/transactions/create_from_calculation', $params, $opts); + } + + /** + * Partially or fully reverses a previously created Transaction. + * + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Transaction + */ + public function createReversal($params = null, $opts = null) + { + return $this->request('post', '/v1/tax/transactions/create_reversal', $params, $opts); + } + + /** + * Retrieves a Tax Transaction object. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Transaction + */ + public function retrieve($id, $params = null, $opts = null) + { + return $this->request('get', $this->buildPath('/v1/tax/transactions/%s', $id), $params, $opts); + } +} diff --git a/lib/SetupIntent.php b/lib/SetupIntent.php index a21573685..2e9c7a00e 100644 --- a/lib/SetupIntent.php +++ b/lib/SetupIntent.php @@ -44,6 +44,7 @@ * @property string $object String representing the object's type. Objects of the same type share the same value. * @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the SetupIntent. * @property null|bool $attach_to_self

If present, the SetupIntent's payment method will be attached to the in-context Stripe Account.

It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer.

+ * @property null|\Stripe\StripeObject $automatic_payment_methods Settings for automatic payment methods compatible with this Setup Intent * @property null|string $cancellation_reason Reason for cancellation of this SetupIntent, one of abandoned, requested_by_customer, or duplicate. * @property null|string $client_secret

The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.

The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.

* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. diff --git a/lib/StripeClient.php b/lib/StripeClient.php index 79de2ca04..645ff5f0b 100644 --- a/lib/StripeClient.php +++ b/lib/StripeClient.php @@ -55,6 +55,7 @@ * @property \Stripe\Service\SubscriptionItemService $subscriptionItems * @property \Stripe\Service\SubscriptionScheduleService $subscriptionSchedules * @property \Stripe\Service\SubscriptionService $subscriptions + * @property \Stripe\Service\Tax\TaxServiceFactory $tax * @property \Stripe\Service\TaxCodeService $taxCodes * @property \Stripe\Service\TaxRateService $taxRates * @property \Stripe\Service\Terminal\TerminalServiceFactory $terminal diff --git a/lib/Tax/Calculation.php b/lib/Tax/Calculation.php new file mode 100644 index 000000000..c8ab80d5a --- /dev/null +++ b/lib/Tax/Calculation.php @@ -0,0 +1,50 @@ +Calculation allows you to calculate the tax to collect from + * your customer. + * + * @property null|string $id Unique identifier for the calculation. + * @property string $object String representing the object's type. Objects of the same type share the same value. + * @property int $amount_total Total after taxes. + * @property string $currency Three-letter ISO currency code, in lowercase. Must be a supported currency. + * @property null|string $customer The ID of an existing Customer used for the resource. + * @property \Stripe\StripeObject $customer_details + * @property null|int $expires_at Timestamp of date at which the tax calculation will expire. + * @property null|\Stripe\Collection<\Stripe\Tax\CalculationLineItem> $line_items The list of items the customer is purchasing. + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property null|\Stripe\StripeObject $shipping_cost The shipping cost details for the calculation. + * @property int $tax_amount_exclusive The amount of tax to be collected on top of the line item prices. + * @property int $tax_amount_inclusive The amount of tax already included in the line item prices. + * @property \Stripe\StripeObject[] $tax_breakdown Breakdown of individual tax amounts that add up to the total. + * @property int $tax_date Timestamp of date at which the tax rules and rates in effect applies for the calculation. + */ +class Calculation extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'tax.calculation'; + + use \Stripe\ApiOperations\Create; + + /** + * @param string $id + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Tax\CalculationLineItem> list of TaxProductResourceTaxCalculationLineItems + */ + public static function allLineItems($id, $params = null, $opts = null) + { + $url = static::resourceUrl($id) . '/line_items'; + list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } +} diff --git a/lib/Tax/CalculationLineItem.php b/lib/Tax/CalculationLineItem.php new file mode 100644 index 000000000..38280aa5b --- /dev/null +++ b/lib/Tax/CalculationLineItem.php @@ -0,0 +1,26 @@ +tax_behavior=inclusive, then this amount includes taxes. Otherwise, taxes were calculated on top of this amount. + * @property int $amount_tax The amount of tax calculated for this line item, in integer cents. + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property null|string $product A Product ID. + * @property int $quantity The number of units of the item being purchased. For reversals, this is the quantity reversed. + * @property null|string $reference A custom identifier for this line item. + * @property string $tax_behavior Specifies whether the amount includes taxes. If tax_behavior=inclusive, then the amount includes taxes. + * @property null|\Stripe\StripeObject[] $tax_breakdown Detailed account of taxes relevant to this line item. + * @property string $tax_code The tax code ID used for this resource. + */ +class CalculationLineItem extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'tax.calculation_line_item'; + + const TAX_BEHAVIOR_EXCLUSIVE = 'exclusive'; + const TAX_BEHAVIOR_INCLUSIVE = 'inclusive'; +} diff --git a/lib/Tax/Transaction.php b/lib/Tax/Transaction.php new file mode 100644 index 000000000..38fc6801f --- /dev/null +++ b/lib/Tax/Transaction.php @@ -0,0 +1,89 @@ +ISO currency code, in lowercase. Must be a supported currency. + * @property null|string $customer The ID of an existing Customer used for the resource. + * @property \Stripe\StripeObject $customer_details + * @property null|\Stripe\Collection<\Stripe\Tax\TransactionLineItem> $line_items The tax collected or refunded, by line item. + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property null|\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 $reference A custom unique identifier, such as 'myOrder_123'. + * @property null|\Stripe\StripeObject $reversal If type=reversal, contains information about what was reversed. + * @property null|\Stripe\StripeObject $shipping_cost The shipping cost details for the transaction. + * @property int $tax_date Timestamp of date at which the tax rules and rates in effect applies for the calculation. + * @property string $type If reversal, this transaction reverses an earlier transaction. + */ +class Transaction extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'tax.transaction'; + + use \Stripe\ApiOperations\Create; + use \Stripe\ApiOperations\Retrieve; + + const TYPE_REVERSAL = 'reversal'; + const TYPE_TRANSACTION = 'transaction'; + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Transaction the created transaction + */ + public static function createFromCalculation($params = null, $opts = null) + { + $url = static::classUrl() . '/create_from_calculation'; + 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 + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Tax\Transaction the created transaction + */ + public static function createReversal($params = null, $opts = null) + { + $url = static::classUrl() . '/create_reversal'; + list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + + /** + * @param string $id + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection<\Stripe\Tax\TransactionLineItem> list of TaxProductResourceTaxTransactionLineItems + */ + public static function allLineItems($id, $params = null, $opts = null) + { + $url = static::resourceUrl($id) . '/line_items'; + list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } +} diff --git a/lib/Tax/TransactionLineItem.php b/lib/Tax/TransactionLineItem.php new file mode 100644 index 000000000..f5db49205 --- /dev/null +++ b/lib/Tax/TransactionLineItem.php @@ -0,0 +1,30 @@ +tax_behavior=inclusive, then this amount includes taxes. Otherwise, taxes were calculated on top of this amount. + * @property int $amount_tax The amount of tax calculated for this line item, in integer cents. + * @property bool $livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode. + * @property null|\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 int $quantity The number of units of the item being purchased. For reversals, this is the quantity reversed. + * @property string $reference A custom identifier for this line item in the transaction. + * @property null|\Stripe\StripeObject $reversal If type=reversal, contains information about what was reversed. + * @property string $tax_behavior Specifies whether the amount includes taxes. If tax_behavior=inclusive, then the amount includes taxes. + * @property string $tax_code The tax code ID used for this resource. + * @property string $type If reversal, this line item reverses an earlier transaction. + */ +class TransactionLineItem extends \Stripe\ApiResource +{ + const OBJECT_NAME = 'tax.transaction_line_item'; + + const TAX_BEHAVIOR_EXCLUSIVE = 'exclusive'; + const TAX_BEHAVIOR_INCLUSIVE = 'inclusive'; + + const TYPE_REVERSAL = 'reversal'; + const TYPE_TRANSACTION = 'transaction'; +} diff --git a/lib/Util/ObjectTypes.php b/lib/Util/ObjectTypes.php index 6fa98e407..e7459991c 100644 --- a/lib/Util/ObjectTypes.php +++ b/lib/Util/ObjectTypes.php @@ -88,6 +88,10 @@ class ObjectTypes \Stripe\Subscription::OBJECT_NAME => \Stripe\Subscription::class, \Stripe\SubscriptionItem::OBJECT_NAME => \Stripe\SubscriptionItem::class, \Stripe\SubscriptionSchedule::OBJECT_NAME => \Stripe\SubscriptionSchedule::class, + \Stripe\Tax\Calculation::OBJECT_NAME => \Stripe\Tax\Calculation::class, + \Stripe\Tax\CalculationLineItem::OBJECT_NAME => \Stripe\Tax\CalculationLineItem::class, + \Stripe\Tax\Transaction::OBJECT_NAME => \Stripe\Tax\Transaction::class, + \Stripe\Tax\TransactionLineItem::OBJECT_NAME => \Stripe\Tax\TransactionLineItem::class, \Stripe\TaxCode::OBJECT_NAME => \Stripe\TaxCode::class, \Stripe\TaxId::OBJECT_NAME => \Stripe\TaxId::class, \Stripe\TaxRate::OBJECT_NAME => \Stripe\TaxRate::class,