From 4bc63691b33354f9c004ae0139fe264ece3fd2bf Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Fri, 8 Oct 2021 14:15:59 -0400 Subject: [PATCH 1/4] Codegen for openapi c2caca4 --- lib/Customer.php | 19 +++++++++++++++++++ lib/Service/CustomerService.php | 16 ++++++++++++++++ tests/Stripe/GeneratedExamplesTest.php | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/lib/Customer.php b/lib/Customer.php index 6cc983a72..50641406b 100644 --- a/lib/Customer.php +++ b/lib/Customer.php @@ -80,6 +80,25 @@ public function deleteDiscount($params = null, $opts = null) $this->refreshFrom(['discount' => null], $opts, true); } + /** + * @param null|array $params + * @param null|array|string $opts + * @param mixed $id + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection list of PaymentMethods + */ + public static function allPaymentMethods($id, $params = null, $opts = null) + { + $url = static::resourceUrl($id) . '/payment_methods'; + list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); + $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); + $obj->setLastResponse($response); + + return $obj; + } + const PATH_BALANCE_TRANSACTIONS = '/balance_transactions'; /** diff --git a/lib/Service/CustomerService.php b/lib/Service/CustomerService.php index fdc6a5960..50dddec49 100644 --- a/lib/Service/CustomerService.php +++ b/lib/Service/CustomerService.php @@ -39,6 +39,22 @@ public function allBalanceTransactions($parentId, $params = null, $opts = null) return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/balance_transactions', $parentId), $params, $opts); } + /** + * Returns a list of PaymentMethods for a given Customer. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Collection + */ + public function allPaymentMethods($id, $params = null, $opts = null) + { + return $this->requestCollection('get', $this->buildPath('/v1/customers/%s/payment_methods', $id), $params, $opts); + } + /** * List sources for a specified customer. * diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index afff1d1c5..ad76c28e1 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -2491,4 +2491,12 @@ public function testDeleteWebhookEndpoint() $result = $this->client->webhookEndpoints->delete('we_xxxxxxxxxxxxx', []); static::assertInstanceOf(\Stripe\WebhookEndpoint::class, $result); } + + public function testListPaymentMethodsCustomer() + { + $this->expectsRequest('get', '/v1/customers/cus_xyz/payment_methods'); + $result = $this->client->customers->allPaymentMethods('cus_xyz', []); + static::assertInstanceOf(\Stripe\Collection::class, $result); + static::assertInstanceOf(\Stripe\Customer::class, $result->data[0]); + } } From 9fe448ce6f4c82bbb01f2d32060fa78385b9bb57 Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Fri, 8 Oct 2021 20:55:18 -0400 Subject: [PATCH 2/4] fix test --- tests/Stripe/GeneratedExamplesTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index ad76c28e1..df5ca86a9 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -2495,7 +2495,10 @@ public function testDeleteWebhookEndpoint() public function testListPaymentMethodsCustomer() { $this->expectsRequest('get', '/v1/customers/cus_xyz/payment_methods'); - $result = $this->client->customers->allPaymentMethods('cus_xyz', []); + $result = $this->client->customers->allPaymentMethods( + 'cus_xyz', + ['type' => 'card'] + ); static::assertInstanceOf(\Stripe\Collection::class, $result); static::assertInstanceOf(\Stripe\Customer::class, $result->data[0]); } From 45f86dedae4005bf14c15583462db53c916cdf2e Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Mon, 11 Oct 2021 10:55:20 -0400 Subject: [PATCH 3/4] Fix docker org --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f994d6a5..493aa92d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,7 +101,7 @@ jobs: run: composer install --prefer-dist --no-progress --no-suggest - name: Start stripe-mock - run: docker pull stripemock/stripe-mock && docker run -d -p 12111-12112:12111-12112 stripemock/stripe-mock && sleep 5 + run: docker pull stripe/stripe-mock && docker run -d -p 12111-12112:12111-12112 stripe/stripe-mock && sleep 5 - name: Run test suite run: | From 0f4b0e87457e030ed7ca7a6bbfaddf5fde50d73f Mon Sep 17 00:00:00 2001 From: Richard Marmorstein Date: Mon, 11 Oct 2021 11:03:16 -0400 Subject: [PATCH 4/4] Fix tests --- tests/Stripe/GeneratedExamplesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index df5ca86a9..22c291cf6 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -2500,6 +2500,6 @@ public function testListPaymentMethodsCustomer() ['type' => 'card'] ); static::assertInstanceOf(\Stripe\Collection::class, $result); - static::assertInstanceOf(\Stripe\Customer::class, $result->data[0]); + static::assertInstanceOf(\Stripe\PaymentMethod::class, $result->data[0]); } }