Calculation.php
6 months ago
CalculationLineItem.php
6 months ago
Registration.php
6 months ago
Settings.php
6 months ago
Transaction.php
6 months ago
TransactionLineItem.php
6 months ago
Calculation.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | |
| 5 | namespace AmeliaVendor\Stripe\Tax; |
| 6 | |
| 7 | /** |
| 8 | * A Tax Calculation allows you to calculate the tax to collect from your customer. |
| 9 | * |
| 10 | * Related guide: <a href="https://stripe.com/docs/tax/custom">Calculate tax in your custom payment flow</a> |
| 11 | * |
| 12 | * @property null|string $id Unique identifier for the calculation. |
| 13 | * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 14 | * @property int $amount_total Total amount after taxes in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>. |
| 15 | * @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>. |
| 16 | * @property null|string $customer The ID of an existing <a href="https://stripe.com/docs/api/customers/object">Customer</a> used for the resource. |
| 17 | * @property (object{address: null|(object{city: null|string, country: string, line1: null|string, line2: null|string, postal_code: null|string, state: null|string}&\AmeliaVendor\Stripe\StripeObject), address_source: null|string, ip_address: null|string, tax_ids: (object{type: string, value: string}&\AmeliaVendor\Stripe\StripeObject)[], taxability_override: string}&\AmeliaVendor\Stripe\StripeObject) $customer_details |
| 18 | * @property null|int $expires_at Timestamp of date at which the tax calculation will expire. |
| 19 | * @property null|\AmeliaVendor\Stripe\Collection<CalculationLineItem> $line_items The list of items the customer is purchasing. |
| 20 | * @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. |
| 21 | * @property null|(object{address: (object{city: null|string, country: string, line1: null|string, line2: null|string, postal_code: null|string, state: null|string}&\AmeliaVendor\Stripe\StripeObject)}&\AmeliaVendor\Stripe\StripeObject) $ship_from_details The details of the ship from location, such as the address. |
| 22 | * @property null|(object{amount: int, amount_tax: int, shipping_rate?: string, tax_behavior: string, tax_breakdown?: ((object{amount: int, jurisdiction: (object{country: string, display_name: string, level: string, state: null|string}&\AmeliaVendor\Stripe\StripeObject), sourcing: string, tax_rate_details: null|(object{display_name: string, percentage_decimal: string, tax_type: string}&\AmeliaVendor\Stripe\StripeObject), taxability_reason: string, taxable_amount: int}&\AmeliaVendor\Stripe\StripeObject))[], tax_code: string}&\AmeliaVendor\Stripe\StripeObject) $shipping_cost The shipping cost details for the calculation. |
| 23 | * @property int $tax_amount_exclusive The amount of tax to be collected on top of the line item prices. |
| 24 | * @property int $tax_amount_inclusive The amount of tax already included in the line item prices. |
| 25 | * @property ((object{amount: int, inclusive: bool, tax_rate_details: (object{country: null|string, flat_amount: null|(object{amount: int, currency: string}&\AmeliaVendor\Stripe\StripeObject), percentage_decimal: string, rate_type: null|string, state: null|string, tax_type: null|string}&\AmeliaVendor\Stripe\StripeObject), taxability_reason: string, taxable_amount: int}&\AmeliaVendor\Stripe\StripeObject))[] $tax_breakdown Breakdown of individual tax amounts that add up to the total. |
| 26 | * @property int $tax_date Timestamp of date at which the tax rules and rates in effect applies for the calculation. |
| 27 | */ |
| 28 | class Calculation extends \AmeliaVendor\Stripe\ApiResource |
| 29 | { |
| 30 | const OBJECT_NAME = 'tax.calculation'; |
| 31 | |
| 32 | /** |
| 33 | * Calculates tax based on the input and returns a Tax <code>Calculation</code> |
| 34 | * object. |
| 35 | * |
| 36 | * @param null|array{currency: string, customer?: string, customer_details?: array{address?: array{city?: null|string, country: string, line1?: null|string, line2?: null|string, postal_code?: null|string, state?: null|string}, address_source?: string, ip_address?: string, tax_ids?: array{type: string, value: string}[], taxability_override?: string}, expand?: string[], line_items: array{amount: int, product?: string, quantity?: int, reference?: string, tax_behavior?: string, tax_code?: string}[], ship_from_details?: array{address: array{city?: null|string, country: string, line1?: null|string, line2?: null|string, postal_code?: null|string, state?: null|string}}, shipping_cost?: array{amount?: int, shipping_rate?: string, tax_behavior?: string, tax_code?: string}, tax_date?: int} $params |
| 37 | * @param null|array|string $options |
| 38 | * |
| 39 | * @return Calculation the created resource |
| 40 | * |
| 41 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 42 | */ |
| 43 | public static function create($params = null, $options = null) |
| 44 | { |
| 45 | self::_validateParams($params); |
| 46 | $url = static::classUrl(); |
| 47 | |
| 48 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 49 | $obj = \AmeliaVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 50 | $obj->setLastResponse($response); |
| 51 | |
| 52 | return $obj; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Retrieves a Tax <code>Calculation</code> object, if the calculation hasn’t |
| 57 | * expired. |
| 58 | * |
| 59 | * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key |
| 60 | * @param null|array|string $opts |
| 61 | * |
| 62 | * @return Calculation |
| 63 | * |
| 64 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 65 | */ |
| 66 | public static function retrieve($id, $opts = null) |
| 67 | { |
| 68 | $opts = \AmeliaVendor\Stripe\Util\RequestOptions::parse($opts); |
| 69 | $instance = new static($id, $opts); |
| 70 | $instance->refresh(); |
| 71 | |
| 72 | return $instance; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @param string $id |
| 77 | * @param null|array $params |
| 78 | * @param null|array|string $opts |
| 79 | * |
| 80 | * @return \AmeliaVendor\Stripe\Collection<CalculationLineItem> list of calculation line items |
| 81 | * |
| 82 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 83 | */ |
| 84 | public static function allLineItems($id, $params = null, $opts = null) |
| 85 | { |
| 86 | $url = static::resourceUrl($id) . '/line_items'; |
| 87 | list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); |
| 88 | $obj = \AmeliaVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 89 | $obj->setLastResponse($response); |
| 90 | |
| 91 | return $obj; |
| 92 | } |
| 93 | } |
| 94 |