TaxRate.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * Tax rates can be applied to <a href="https://stripe.com/docs/billing/invoices/tax-rates">invoices</a>, <a href="https://stripe.com/docs/billing/subscriptions/taxes">subscriptions</a> and <a href="https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates">Checkout Sessions</a> to collect tax.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/billing/taxes/tax-rates">Tax rates</a>
  8. *
  9. * @property string $id Unique identifier for the object.
  10. * @property string $object String representing the object's type. Objects of the same type share the same value.
  11. * @property bool $active Defaults to <code>true</code>. When set to <code>false</code>, this tax rate cannot be used with new applications or Checkout Sessions, but will still work for subscriptions and invoices that already have it set.
  12. * @property null|string $country Two-letter country code (<a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>).
  13. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  14. * @property null|string $description An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers.
  15. * @property string $display_name The display name of the tax rates as it will appear to your customer on their receipt email, PDF, and the hosted invoice page.
  16. * @property null|float $effective_percentage Actual/effective tax rate percentage out of 100. For tax calculations with automatic_tax[enabled]=true, this percentage reflects the rate actually used to calculate tax based on the product's taxability and whether the user is registered to collect taxes in the corresponding jurisdiction.
  17. * @property bool $inclusive This specifies if the tax rate is inclusive or exclusive.
  18. * @property null|string $jurisdiction The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer’s invoice.
  19. * @property null|string $jurisdiction_level The level of the jurisdiction that imposes this tax rate. Will be <code>null</code> for manually defined tax rates.
  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|\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.
  22. * @property float $percentage Tax rate percentage out of 100. For tax calculations with automatic_tax[enabled]=true, this percentage includes the statutory tax rate of non-taxable jurisdictions.
  23. * @property null|string $state <a href="https://en.wikipedia.org/wiki/ISO_3166-2:US">ISO 3166-2 subdivision code</a>, without country prefix. For example, &quot;NY&quot; for New York, United States.
  24. * @property null|string $tax_type The high-level tax type, such as <code>vat</code> or <code>sales_tax</code>.
  25. */
  26. class TaxRate extends ApiResource
  27. {
  28. const OBJECT_NAME = 'tax_rate';
  29. use ApiOperations\Update;
  30. const JURISDICTION_LEVEL_CITY = 'city';
  31. const JURISDICTION_LEVEL_COUNTRY = 'country';
  32. const JURISDICTION_LEVEL_COUNTY = 'county';
  33. const JURISDICTION_LEVEL_DISTRICT = 'district';
  34. const JURISDICTION_LEVEL_MULTIPLE = 'multiple';
  35. const JURISDICTION_LEVEL_STATE = 'state';
  36. const TAX_TYPE_AMUSEMENT_TAX = 'amusement_tax';
  37. const TAX_TYPE_COMMUNICATIONS_TAX = 'communications_tax';
  38. const TAX_TYPE_GST = 'gst';
  39. const TAX_TYPE_HST = 'hst';
  40. const TAX_TYPE_IGST = 'igst';
  41. const TAX_TYPE_JCT = 'jct';
  42. const TAX_TYPE_LEASE_TAX = 'lease_tax';
  43. const TAX_TYPE_PST = 'pst';
  44. const TAX_TYPE_QST = 'qst';
  45. const TAX_TYPE_RST = 'rst';
  46. const TAX_TYPE_SALES_TAX = 'sales_tax';
  47. const TAX_TYPE_VAT = 'vat';
  48. /**
  49. * Creates a new tax rate.
  50. *
  51. * @param null|array $params
  52. * @param null|array|string $options
  53. *
  54. * @throws \Stripe\Exception\ApiErrorException if the request fails
  55. *
  56. * @return \Stripe\TaxRate the created resource
  57. */
  58. public static function create($params = null, $options = null)
  59. {
  60. self::_validateParams($params);
  61. $url = static::classUrl();
  62. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  63. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  64. $obj->setLastResponse($response);
  65. return $obj;
  66. }
  67. /**
  68. * Returns a list of your tax rates. Tax rates are returned sorted by creation
  69. * date, with the most recently created tax rates appearing first.
  70. *
  71. * @param null|array $params
  72. * @param null|array|string $opts
  73. *
  74. * @throws \Stripe\Exception\ApiErrorException if the request fails
  75. *
  76. * @return \Stripe\Collection<\Stripe\TaxRate> of ApiResources
  77. */
  78. public static function all($params = null, $opts = null)
  79. {
  80. $url = static::classUrl();
  81. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  82. }
  83. /**
  84. * Retrieves a tax rate with the given ID.
  85. *
  86. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  87. * @param null|array|string $opts
  88. *
  89. * @throws \Stripe\Exception\ApiErrorException if the request fails
  90. *
  91. * @return \Stripe\TaxRate
  92. */
  93. public static function retrieve($id, $opts = null)
  94. {
  95. $opts = \Stripe\Util\RequestOptions::parse($opts);
  96. $instance = new static($id, $opts);
  97. $instance->refresh();
  98. return $instance;
  99. }
  100. /**
  101. * Updates an existing tax rate.
  102. *
  103. * @param string $id the ID of the resource to update
  104. * @param null|array $params
  105. * @param null|array|string $opts
  106. *
  107. * @throws \Stripe\Exception\ApiErrorException if the request fails
  108. *
  109. * @return \Stripe\TaxRate the updated resource
  110. */
  111. public static function update($id, $params = null, $opts = null)
  112. {
  113. self::_validateParams($params);
  114. $url = static::resourceUrl($id);
  115. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  116. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  117. $obj->setLastResponse($response);
  118. return $obj;
  119. }
  120. }