Registration.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Tax;
  4. /**
  5. * A Tax <code>Registration</code> lets us know that your business is registered to collect tax on payments within a region, enabling you to <a href="https://stripe.com/docs/tax">automatically collect tax</a>.
  6. *
  7. * Stripe doesn't register on your behalf with the relevant authorities when you create a Tax <code>Registration</code> object. For more information on how to register to collect tax, see <a href="https://stripe.com/docs/tax/registering">our guide</a>.
  8. *
  9. * Related guide: <a href="https://stripe.com/docs/tax/registrations-api">Using the Registrations API</a>
  10. *
  11. * @property string $id Unique identifier for the object.
  12. * @property string $object String representing the object's type. Objects of the same type share the same value.
  13. * @property int $active_from Time at which the registration becomes active. Measured in seconds since the Unix epoch.
  14. * @property string $country Two-letter country code (<a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2">ISO 3166-1 alpha-2</a>).
  15. * @property \Stripe\StripeObject $country_options
  16. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  17. * @property null|int $expires_at If set, the registration stops being active at this time. If not set, the registration will be active indefinitely. Measured in seconds since the Unix epoch.
  18. * @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.
  19. * @property string $status The status of the registration. This field is present for convenience and can be deduced from <code>active_from</code> and <code>expires_at</code>.
  20. */
  21. class Registration extends \Stripe\ApiResource
  22. {
  23. const OBJECT_NAME = 'tax.registration';
  24. use \Stripe\ApiOperations\Update;
  25. const STATUS_ACTIVE = 'active';
  26. const STATUS_EXPIRED = 'expired';
  27. const STATUS_SCHEDULED = 'scheduled';
  28. /**
  29. * Creates a new Tax <code>Registration</code> object.
  30. *
  31. * @param null|array $params
  32. * @param null|array|string $options
  33. *
  34. * @throws \Stripe\Exception\ApiErrorException if the request fails
  35. *
  36. * @return \Stripe\Tax\Registration the created resource
  37. */
  38. public static function create($params = null, $options = null)
  39. {
  40. self::_validateParams($params);
  41. $url = static::classUrl();
  42. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  43. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  44. $obj->setLastResponse($response);
  45. return $obj;
  46. }
  47. /**
  48. * Returns a list of Tax <code>Registration</code> objects.
  49. *
  50. * @param null|array $params
  51. * @param null|array|string $opts
  52. *
  53. * @throws \Stripe\Exception\ApiErrorException if the request fails
  54. *
  55. * @return \Stripe\Collection<\Stripe\Tax\Registration> of ApiResources
  56. */
  57. public static function all($params = null, $opts = null)
  58. {
  59. $url = static::classUrl();
  60. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  61. }
  62. /**
  63. * Returns a Tax <code>Registration</code> object.
  64. *
  65. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  66. * @param null|array|string $opts
  67. *
  68. * @throws \Stripe\Exception\ApiErrorException if the request fails
  69. *
  70. * @return \Stripe\Tax\Registration
  71. */
  72. public static function retrieve($id, $opts = null)
  73. {
  74. $opts = \Stripe\Util\RequestOptions::parse($opts);
  75. $instance = new static($id, $opts);
  76. $instance->refresh();
  77. return $instance;
  78. }
  79. /**
  80. * Updates an existing Tax <code>Registration</code> object.
  81. *
  82. * A registration cannot be deleted after it has been created. If you wish to end a
  83. * registration you may do so by setting <code>expires_at</code>.
  84. *
  85. * @param string $id the ID of the resource to update
  86. * @param null|array $params
  87. * @param null|array|string $opts
  88. *
  89. * @throws \Stripe\Exception\ApiErrorException if the request fails
  90. *
  91. * @return \Stripe\Tax\Registration the updated resource
  92. */
  93. public static function update($id, $params = null, $opts = null)
  94. {
  95. self::_validateParams($params);
  96. $url = static::resourceUrl($id);
  97. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  98. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  99. $obj->setLastResponse($response);
  100. return $obj;
  101. }
  102. }