diff --git a/init.php b/init.php index 910911e8b8..2fd6c48a9c 100644 --- a/init.php +++ b/init.php @@ -158,4 +158,5 @@ require __DIR__ . '/lib/Service/AbstractService.php'; require __DIR__ . '/lib/Service/CouponService.php'; require __DIR__ . '/lib/Service/FileService.php'; +require __DIR__ . '/lib/Service/Issuing/CardService.php'; require __DIR__ . '/lib/Service/PaymentIntentService.php'; diff --git a/lib/Service/Issuing/CardService.php b/lib/Service/Issuing/CardService.php new file mode 100644 index 0000000000..d95ae2ce65 --- /dev/null +++ b/lib/Service/Issuing/CardService.php @@ -0,0 +1,79 @@ +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); + } +} diff --git a/tests/Stripe/Service/Issuing/CardServiceTest.php b/tests/Stripe/Service/Issuing/CardServiceTest.php new file mode 100644 index 0000000000..cec5cccf0a --- /dev/null +++ b/tests/Stripe/Service/Issuing/CardServiceTest.php @@ -0,0 +1,81 @@ +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); + } +}