diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 0e2fd6c97..22402537f 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v294 \ No newline at end of file +v296 \ No newline at end of file diff --git a/lib/Event.php b/lib/Event.php index d7a8c1538..31c5d7cd1 100644 --- a/lib/Event.php +++ b/lib/Event.php @@ -261,6 +261,7 @@ class Event extends ApiResource const TAX_RATE_UPDATED = 'tax_rate.updated'; const TERMINAL_READER_ACTION_FAILED = 'terminal.reader.action_failed'; const TERMINAL_READER_ACTION_SUCCEEDED = 'terminal.reader.action_succeeded'; + const TERMINAL_READER_ACTION_UPDATED = 'terminal.reader.action_updated'; const TEST_HELPERS_TEST_CLOCK_ADVANCING = 'test_helpers.test_clock.advancing'; const TEST_HELPERS_TEST_CLOCK_CREATED = 'test_helpers.test_clock.created'; const TEST_HELPERS_TEST_CLOCK_DELETED = 'test_helpers.test_clock.deleted'; diff --git a/lib/Service/Terminal/ReaderService.php b/lib/Service/Terminal/ReaderService.php index b0df7c46c..e5f8987e6 100644 --- a/lib/Service/Terminal/ReaderService.php +++ b/lib/Service/Terminal/ReaderService.php @@ -53,6 +53,39 @@ public function collectInputs($id, $params = null, $opts = null) return $this->request('post', $this->buildPath('/v1/terminal/readers/%s/collect_inputs', $id), $params, $opts); } + /** + * Initiates a payment flow on a Reader and updates the PaymentIntent with card + * details before manual confirmation. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Reader + */ + public function collectPaymentMethod($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/terminal/readers/%s/collect_payment_method', $id), $params, $opts); + } + + /** + * Finializes a payment on a Reader. + * + * @param string $id + * @param null|array $params + * @param null|array|\Stripe\Util\RequestOptions $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Reader + */ + public function confirmPaymentIntent($id, $params = null, $opts = null) + { + return $this->request('post', $this->buildPath('/v1/terminal/readers/%s/confirm_payment_intent', $id), $params, $opts); + } + /** * Creates a new Reader object. * diff --git a/lib/Terminal/Reader.php b/lib/Terminal/Reader.php index a50c942b6..7afed6245 100644 --- a/lib/Terminal/Reader.php +++ b/lib/Terminal/Reader.php @@ -68,6 +68,40 @@ public function collectInputs($params = null, $opts = null) return $this; } + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Reader the collected reader + */ + public function collectPaymentMethod($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/collect_payment_method'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + + /** + * @param null|array $params + * @param null|array|string $opts + * + * @throws \Stripe\Exception\ApiErrorException if the request fails + * + * @return \Stripe\Terminal\Reader the confirmed reader + */ + public function confirmPaymentIntent($params = null, $opts = null) + { + $url = $this->instanceUrl() . '/confirm_payment_intent'; + list($response, $opts) = $this->_request('post', $url, $params, $opts); + $this->refreshFrom($response, $opts); + + return $this; + } + /** * @param null|array $params * @param null|array|string $opts diff --git a/tests/Stripe/GeneratedExamplesTest.php b/tests/Stripe/GeneratedExamplesTest.php index 75a347962..724e76154 100644 --- a/tests/Stripe/GeneratedExamplesTest.php +++ b/tests/Stripe/GeneratedExamplesTest.php @@ -4045,4 +4045,17 @@ public function testPreviewInvoiceLinesQuote() static::assertInstanceOf(\Stripe\Collection::class, $result); static::assertInstanceOf(\Stripe\InvoiceLineItem::class, $result->data[0]); } + + public function testCreatePaymentIntent3() + { + $this->expectsRequest('post', '/v1/payment_intents'); + $result = $this->client->paymentIntents->create( + [ + 'amount' => 200, + 'currency' => 'usd', + 'payment_method_data' => ['type' => 'p24', 'p24' => ['bank' => 'blik']], + ] + ); + static::assertInstanceOf(\Stripe\PaymentIntent::class, $result); + } }