Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Updates #1258

Merged
merged 4 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
require __DIR__ . '/lib/Service/Terminal/ConnectionTokenService.php';
require __DIR__ . '/lib/Service/Terminal/LocationService.php';
require __DIR__ . '/lib/Service/Terminal/ReaderService.php';
require __DIR__ . '/lib/Service/TestHelpers/Terminal/ReaderService.php';
require __DIR__ . '/lib/Service/TestHelpers/TestClockService.php';
require __DIR__ . '/lib/Service/TokenService.php';
require __DIR__ . '/lib/Service/TopupService.php';
Expand Down
2 changes: 1 addition & 1 deletion lib/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @property string[] $images A list of up to 8 URLs of images for this product, meant to be displayable to the customer.
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
* @property string $name The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions.
* @property string $name The product's name, meant to be displayable to the customer.
* @property null|\Stripe\StripeObject $package_dimensions The dimensions of this product for shipping purposes.
* @property null|bool $shippable Whether this product is shipped (i.e., physical goods).
* @property null|string $statement_descriptor Extra information about a product which will appear on your customer's credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used.
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/ChargeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public function retrieve($id, $params = null, $opts = null)

/**
* Search for charges you’ve previously created using Stripe’s <a
* href="/docs/search#search-query-language">Search Query Language</a>.
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
* search in read-after-write flows where strict consistency is necessary. Under
* normal operating conditions, data is searchable in less than a minute.
* Occasionally, propagation of new or updated data can be up to an hour behind
* during outages. Search functionality is not available to merchants in India.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ public function retrieveTaxId($parentId, $id, $params = null, $opts = null)

/**
* Search for customers you’ve previously created using Stripe’s <a
* href="/docs/search#search-query-language">Search Query Language</a>.
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
* search in read-after-write flows where strict consistency is necessary. Under
* normal operating conditions, data is searchable in less than a minute.
* Occasionally, propagation of new or updated data can be up to an hour behind
* during outages. Search functionality is not available to merchants in India.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/InvoiceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ public function retrieve($id, $params = null, $opts = null)

/**
* Search for invoices you’ve previously created using Stripe’s <a
* href="/docs/search#search-query-language">Search Query Language</a>.
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
* search in read-after-write flows where strict consistency is necessary. Under
* normal operating conditions, data is searchable in less than a minute.
* Occasionally, propagation of new or updated data can be up to an hour behind
* during outages. Search functionality is not available to merchants in India.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/PaymentIntentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ public function retrieve($id, $params = null, $opts = null)

/**
* Search for PaymentIntents you’ve previously created using Stripe’s <a
* href="/docs/search#search-query-language">Search Query Language</a>.
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
* search in read-after-write flows where strict consistency is necessary. Under
* normal operating conditions, data is searchable in less than a minute.
* Occasionally, propagation of new or updated data can be up to an hour behind
* during outages. Search functionality is not available to merchants in India.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/PriceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public function retrieve($id, $params = null, $opts = null)

/**
* Search for prices you’ve previously created using Stripe’s <a
* href="/docs/search#search-query-language">Search Query Language</a>.
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
* search in read-after-write flows where strict consistency is necessary. Under
* normal operating conditions, data is searchable in less than a minute.
* Occasionally, propagation of new or updated data can be up to an hour behind
* during outages. Search functionality is not available to merchants in India.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/ProductService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public function retrieve($id, $params = null, $opts = null)

/**
* Search for products you’ve previously created using Stripe’s <a
* href="/docs/search#search-query-language">Search Query Language</a>.
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
* search in read-after-write flows where strict consistency is necessary. Under
* normal operating conditions, data is searchable in less than a minute.
* Occasionally, propagation of new or updated data can be up to an hour behind
* during outages. Search functionality is not available to merchants in India.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/SubscriptionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ public function retrieve($id, $params = null, $opts = null)

/**
* Search for subscriptions you’ve previously created using Stripe’s <a
* href="/docs/search#search-query-language">Search Query Language</a>.
* href="/docs/search#search-query-language">Search Query Language</a>. Don’t use
* search in read-after-write flows where strict consistency is necessary. Under
* normal operating conditions, data is searchable in less than a minute.
* Occasionally, propagation of new or updated data can be up to an hour behind
* during outages. Search functionality is not available to merchants in India.
*
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
Expand Down
64 changes: 64 additions & 0 deletions lib/Service/Terminal/ReaderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ public function all($params = null, $opts = null)
return $this->requestCollection('get', '/v1/terminal/readers', $params, $opts);
}

/**
* Cancels the current reader action.
*
* @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 cancelAction($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/terminal/readers/%s/cancel_action', $id), $params, $opts);
}

/**
* Creates a new <code>Reader</code> object.
*
Expand Down Expand Up @@ -52,6 +68,38 @@ public function delete($id, $params = null, $opts = null)
return $this->request('delete', $this->buildPath('/v1/terminal/readers/%s', $id), $params, $opts);
}

/**
* Initiates a payment flow 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 processPaymentIntent($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/terminal/readers/%s/process_payment_intent', $id), $params, $opts);
}

/**
* Initiates a setup intent flow 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 processSetupIntent($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/terminal/readers/%s/process_setup_intent', $id), $params, $opts);
}

/**
* Retrieves a <code>Reader</code> object.
*
Expand All @@ -68,6 +116,22 @@ public function retrieve($id, $params = null, $opts = null)
return $this->request('get', $this->buildPath('/v1/terminal/readers/%s', $id), $params, $opts);
}

/**
* Sets reader display.
*
* @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 setReaderDisplay($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/terminal/readers/%s/set_reader_display', $id), $params, $opts);
}

/**
* Updates a <code>Reader</code> object by setting the values of the parameters
* passed. Any parameters not provided will be left unchanged.
Expand Down
25 changes: 25 additions & 0 deletions lib/Service/TestHelpers/Terminal/ReaderService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\Service\TestHelpers\Terminal;

class ReaderService extends \Stripe\Service\AbstractService
{
/**
* Presents a payment method on a simulated reader. Can be used to simulate
* accepting a payment, saving a card or refunding a transaction.
*
* @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 presentPaymentMethod($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/test_helpers/terminal/readers/%s/present_payment_method', $id), $params, $opts);
}
}
25 changes: 25 additions & 0 deletions lib/Service/TestHelpers/Terminal/TerminalServiceFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

// File generated from our OpenAPI spec

namespace Stripe\Service\TestHelpers\Terminal;

/**
* Service factory class for API resources in the Terminal namespace.
*
* @property ReaderService $readers
*/
class TerminalServiceFactory extends \Stripe\Service\AbstractServiceFactory
{
/**
* @var array<string, string>
*/
private static $classMap = [
'readers' => ReaderService::class,
];

protected function getServiceClass($name)
{
return \array_key_exists($name, self::$classMap) ? self::$classMap[$name] : null;
}
}
2 changes: 2 additions & 0 deletions lib/Service/TestHelpers/TestHelpersServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/**
* Service factory class for API resources in the TestHelpers namespace.
*
* @property Terminal\TerminalServiceFactory $terminal
* @property TestClockService $testClocks
*/
class TestHelpersServiceFactory extends \Stripe\Service\AbstractServiceFactory
Expand All @@ -15,6 +16,7 @@ class TestHelpersServiceFactory extends \Stripe\Service\AbstractServiceFactory
* @var array<string, string>
*/
private static $classMap = [
'terminal' => Terminal\TerminalServiceFactory::class,
'testClocks' => TestClockService::class,
];

Expand Down
69 changes: 69 additions & 0 deletions lib/Terminal/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property null|\Stripe\StripeObject $action The most recent action performed by the reader.
* @property null|string $device_sw_version The current software version of the reader.
* @property string $device_type Type of reader, one of <code>bbpos_wisepad3</code>, <code>stripe_m2</code>, <code>bbpos_chipper2x</code>, <code>bbpos_wisepos_e</code>, or <code>verifone_P400</code>.
* @property null|string $ip_address The local IP address of the reader.
Expand All @@ -32,4 +33,72 @@ class Reader extends \Stripe\ApiResource
use \Stripe\ApiOperations\Delete;
use \Stripe\ApiOperations\Retrieve;
use \Stripe\ApiOperations\Update;

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Terminal\Reader the canceled reader
*/
public function cancelAction($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/cancel_action';
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 processed reader
*/
public function processPaymentIntent($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/process_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
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Terminal\Reader the processed reader
*/
public function processSetupIntent($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/process_setup_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
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Terminal\Reader the seted reader
*/
public function setReaderDisplay($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/set_reader_display';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}
}
39 changes: 39 additions & 0 deletions tests/Stripe/Service/TestHelpers/Terminal/ReaderServiceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Stripe\Service\TestHelpers\Terminal;

/**
* @internal
* @covers \Stripe\Service\TestHelpers\Terminal\ReaderService
*/
final class ReaderServiceTest extends \Stripe\TestCase
{
use \Stripe\TestHelper;

const TEST_RESOURCE_ID = 'tml_123';

/** @var \Stripe\StripeClient */
private $client;

/** @var ReaderService */
private $service;

/**
* @before
*/
protected function setUpService()
{
$this->client = new \Stripe\StripeClient(['api_key' => 'sk_test_123', 'api_base' => MOCK_URL]);
$this->service = new ReaderService($this->client);
}

public function testPresentPaymentMethod()
{
$this->expectsRequest(
'post',
'/v1/test_helpers/terminal/readers/' . self::TEST_RESOURCE_ID . '/present_payment_method'
);
$resource = $this->service->presentPaymentMethod(self::TEST_RESOURCE_ID);
static::assertInstanceOf(\Stripe\Terminal\Reader::class, $resource);
}
}