-
Notifications
You must be signed in to change notification settings - Fork 857
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Stripe\Service\Issuing; | ||
|
||
class CardService extends \Stripe\Service\AbstractService | ||
{ | ||
public function basePath() | ||
{ | ||
return '/v1/issuing/cards'; | ||
} | ||
|
||
/** | ||
* List all cards. | ||
* | ||
* @param array $params | ||
* @param array $opts | ||
* | ||
* @return \Stripe\Collection | ||
*/ | ||
public function all($params = [], $opts = []) | ||
{ | ||
return $this->allObjects($params, $opts); | ||
} | ||
|
||
/** | ||
* Create a card. | ||
* | ||
* @param array $params | ||
* @param array $opts | ||
* | ||
* @return \Stripe\Issuing\Card | ||
*/ | ||
public function create($params = [], $opts = []) | ||
{ | ||
return $this->createObject($params, $opts); | ||
} | ||
|
||
/** | ||
* Retrieve a card details. | ||
* | ||
* @param string $id | ||
* @param array $params | ||
* @param array $opts | ||
* | ||
* @return \Stripe\Issuing\CardDetails | ||
*/ | ||
public function details($id, $params = [], $opts = []) | ||
{ | ||
return $this->request('get', $this->instancePath($id) . '/details', $params, $opts); | ||
} | ||
|
||
/** | ||
* Retrieve a card. | ||
* | ||
* @param string $id | ||
* @param array $params | ||
* @param array $opts | ||
* | ||
* @return \Stripe\Issuing\Card | ||
*/ | ||
public function retrieve($id, $params = [], $opts = []) | ||
{ | ||
return $this->retrieveObject($id, $params, $opts); | ||
} | ||
|
||
/** | ||
* Update a card. | ||
* | ||
* @param string $id | ||
* @param array $params | ||
* @param array $opts | ||
* | ||
* @return \Stripe\Issuing\Card | ||
*/ | ||
public function update($id, $params = [], $opts = []) | ||
{ | ||
return $this->updateObject($id, $params, $opts); | ||
} | ||
} |
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,81 @@ | ||
<?php | ||
|
||
namespace Stripe\Service\Issuing; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class CardServiceTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
use \Stripe\TestHelper; | ||
|
||
const TEST_RESOURCE_ID = 'ic_123'; | ||
|
||
private $client; | ||
private $service; | ||
|
||
/** | ||
* @before | ||
*/ | ||
protected function setUpService() | ||
{ | ||
$this->client = new \Stripe\StripeClient('sk_test_123', null, MOCK_URL); | ||
$this->service = new CardService($this->client); | ||
} | ||
|
||
public function testAll() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/issuing/cards' | ||
); | ||
$resources = $this->service->all(); | ||
static::assertInternalType('array', $resources->data); | ||
static::assertInstanceOf(\Stripe\Issuing\Card::class, $resources->data[0]); | ||
} | ||
|
||
public function testCreate() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/issuing/cards' | ||
); | ||
$resource = $this->service->create([ | ||
'currency' => 'usd', | ||
'type' => 'physical', | ||
]); | ||
static::assertInstanceOf(\Stripe\Issuing\Card::class, $resource); | ||
} | ||
|
||
public function testDetails() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/issuing/cards/' . self::TEST_RESOURCE_ID . '/details' | ||
); | ||
$resource = $this->service->details(self::TEST_RESOURCE_ID); | ||
static::assertInstanceOf(\Stripe\Issuing\CardDetails::class, $resource); | ||
} | ||
|
||
public function testRetrieve() | ||
{ | ||
$this->expectsRequest( | ||
'get', | ||
'/v1/issuing/cards/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = $this->service->retrieve(self::TEST_RESOURCE_ID); | ||
static::assertInstanceOf(\Stripe\Issuing\Card::class, $resource); | ||
} | ||
|
||
public function testUpdate() | ||
{ | ||
$this->expectsRequest( | ||
'post', | ||
'/v1/issuing/cards/' . self::TEST_RESOURCE_ID | ||
); | ||
$resource = $this->service->update(self::TEST_RESOURCE_ID, [ | ||
'metadata' => ['key' => 'value'], | ||
]); | ||
static::assertInstanceOf(\Stripe\Issuing\Card::class, $resource); | ||
} | ||
} |