-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for /v1/topups endpoints.
- Loading branch information
1 parent
702a3ee
commit 7c07bfc
Showing
6 changed files
with
106 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Stripe; | ||
|
||
/** | ||
* Class Topup | ||
* | ||
* @property string $id | ||
* @property string $object | ||
* @property int $amount | ||
* @property string $balance_transaction | ||
* @property int $created | ||
* @property string $currency | ||
* @property string $description | ||
* @property int $expected_availability_date | ||
* @property string $failure_code | ||
* @property string $failure_message | ||
* @property bool $livemode | ||
* @property StripeObject $metadata | ||
* @property mixed $source | ||
* @property string $statement_descriptor | ||
* @property string $status | ||
* | ||
* @package Stripe | ||
*/ | ||
class Topup extends ApiResource | ||
{ | ||
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
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,69 @@ | ||
<?php | ||
|
||
namespace Stripe; | ||
|
||
class TopupTest extends TestCase | ||
{ | ||
const TEST_RESOURCE_ID = 'tu_123'; | ||
|
||
public function testIsListable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/topups' | ||
); | ||
$resources = Topup::all(); | ||
$this->assertTrue(is_array($resources->data)); | ||
$this->assertInstanceOf("Stripe\\Topup", $resources->data[0]); | ||
} | ||
|
||
public function testIsRetrievable() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/topups/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = Topup::retrieve(self::TEST_RESOURCE_ID); | ||
$this->assertInstanceOf("Stripe\\Topup", $resource); | ||
} | ||
|
||
public function testIsCreatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/topups' | ||
); | ||
$resource = Topup::create([ | ||
"amount" => 100, | ||
"currency" => "usd", | ||
"source" => "tok_123", | ||
"description" => "description", | ||
"statement_descriptor" => "statement descriptor" | ||
]); | ||
$this->assertInstanceOf("Stripe\\Topup", $resource); | ||
} | ||
|
||
public function testIsSaveable() | ||
{ | ||
$resource = Topup::retrieve(self::TEST_RESOURCE_ID); | ||
$resource->metadata["key"] = "value"; | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/topups/' . $resource->id | ||
); | ||
$resource->save(); | ||
$this->assertInstanceOf("Stripe\\Topup", $resource); | ||
} | ||
|
||
public function testIsUpdatable() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/topups/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = Topup::update(self::TEST_RESOURCE_ID, [ | ||
"metadata" => ["key" => "value"], | ||
]); | ||
$this->assertInstanceOf("Stripe\\Topup", $resource); | ||
} | ||
} |