diff --git a/init.php b/init.php index 7d908bf44..5ccf3327c 100644 --- a/init.php +++ b/init.php @@ -120,6 +120,7 @@ require(dirname(__FILE__) . '/lib/SubscriptionSchedule.php'); require(dirname(__FILE__) . '/lib/SubscriptionScheduleRevision.php'); require(dirname(__FILE__) . '/lib/TaxId.php'); +require(dirname(__FILE__) . '/lib/TaxRate.php'); require(dirname(__FILE__) . '/lib/Terminal/ConnectionToken.php'); require(dirname(__FILE__) . '/lib/Terminal/Location.php'); require(dirname(__FILE__) . '/lib/Terminal/Reader.php'); diff --git a/lib/Customer.php b/lib/Customer.php index 23076aa8a..44f5e6e2f 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -42,6 +42,14 @@ class Customer extends ApiResource use ApiOperations\Retrieve; use ApiOperations\Update; + /** + * Possible string representations of the customer's type of tax exemption. + * @link https://stripe.com/docs/api/customers/object#customer_object-tax_exempt + */ + const TAX_EXEMPT_NONE = 'none'; + const TAX_EXEMPT_EXEMPT = 'exempt'; + const TAX_EXEMPT_REVERSE = 'reverse'; + public static function getSavedNestedResources() { static $savedNestedResources = null; diff --git a/lib/Event.php b/lib/Event.php index bb9b3bfbb..5e199c05d 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -143,6 +143,8 @@ class Event extends ApiResource 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 TOPUP_CANCELED = 'topup.canceled'; const TOPUP_CREATED = 'topup.created'; const TOPUP_FAILED = 'topup.failed'; diff --git a/lib/TaxRate.php b/lib/TaxRate.php new file mode 100644 index 000000000..25884dd84 --- /dev/null +++ b/lib/TaxRate.php @@ -0,0 +1,31 @@ + 'Stripe\\SubscriptionSchedule', \Stripe\SubscriptionScheduleRevision::OBJECT_NAME => 'Stripe\\SubscriptionScheduleRevision', \Stripe\TaxId::OBJECT_NAME => 'Stripe\\TaxId', + \Stripe\TaxRate::OBJECT_NAME => 'Stripe\\TaxRate', \Stripe\ThreeDSecure::OBJECT_NAME => 'Stripe\\ThreeDSecure', \Stripe\Terminal\ConnectionToken::OBJECT_NAME => 'Stripe\\Terminal\\ConnectionToken', \Stripe\Terminal\Location::OBJECT_NAME => 'Stripe\\Terminal\\Location', diff --git a/tests/Stripe/TaxRateTest.php b/tests/Stripe/TaxRateTest.php new file mode 100644 index 000000000..69be07148 --- /dev/null +++ b/tests/Stripe/TaxRateTest.php @@ -0,0 +1,67 @@ +expectsRequest( + 'get', + '/v1/tax_rates' + ); + $resources = TaxRate::all(); + $this->assertTrue(is_array($resources->data)); + $this->assertInstanceOf("Stripe\\TaxRate", $resources->data[0]); + } + + public function testIsRetrievable() + { + $this->expectsRequest( + 'get', + '/v1/tax_rates/' . self::TEST_RESOURCE_ID + ); + $resource = TaxRate::retrieve(self::TEST_RESOURCE_ID); + $this->assertInstanceOf("Stripe\\TaxRate", $resource); + } + + public function testIsCreatable() + { + $this->expectsRequest( + 'post', + '/v1/tax_rates' + ); + $resource = TaxRate::create([ + "display_name" => "name", + "inclusive" => false, + "percentage" => 10.15, + ]); + $this->assertInstanceOf("Stripe\\TaxRate", $resource); + } + + public function testIsSaveable() + { + $resource = TaxRate::retrieve(self::TEST_RESOURCE_ID); + $resource->metadata["key"] = "value"; + $this->expectsRequest( + 'post', + '/v1/tax_rates/' . self::TEST_RESOURCE_ID + ); + $resource->save(); + $this->assertInstanceOf("Stripe\\TaxRate", $resource); + } + + public function testIsUpdatable() + { + $this->expectsRequest( + 'post', + '/v1/tax_rates/' . self::TEST_RESOURCE_ID + ); + $resource = TaxRate::update(self::TEST_RESOURCE_ID, [ + "metadata" => ["key" => "value"], + ]); + $this->assertInstanceOf("Stripe\\TaxRate", $resource); + } +}