-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #626 from stripe/remi-add-tax-rates
Add support for the TaxRate resource
- Loading branch information
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace Stripe; | ||
|
||
/** | ||
* Class TaxRate | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property bool $active | ||
* @property int $created | ||
* @property string $description | ||
* @property string $display_name | ||
* @property bool $inclusive | ||
* @property string $jurisdiction | ||
* @property bool $livemode | ||
* @property StripeObject $metadata | ||
* @property float $percentage | ||
* | ||
* @package Stripe | ||
*/ | ||
class TaxRate extends ApiResource | ||
{ | ||
|
||
const OBJECT_NAME = "tax_rate"; | ||
|
||
use ApiOperations\All; | ||
use ApiOperations\Create; | ||
use ApiOperations\Retrieve; | ||
use ApiOperations\Update; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Stripe; | ||
|
||
class TaxRateTest extends TestCase | ||
{ | ||
const TEST_RESOURCE_ID = 'txr_123'; | ||
|
||
public function testIsListable() | ||
{ | ||
$this->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); | ||
} | ||
} |