diff --git a/README.md b/README.md index 8051bae..bf17110 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,19 @@ if (OrderStatus::isDeclined($result['orderStatus'])) { } ``` +Also, you can get an order's status by using you own identifier (e.g. assigned by your database): + +```php + 'username', 'password' => 'password']); + +$result = $client->getOrderStatusByOwnId($orderId); +``` + ### Reversing an exising order [/payment/rest/reverse.do](https://securepayments.sberbank.ru/wiki/doku.php/integration:api:rest:requests:reverse) diff --git a/src/Client.php b/src/Client.php index 2be117c..3b8c4ca 100644 --- a/src/Client.php +++ b/src/Client.php @@ -301,11 +301,11 @@ public function refundOrder($orderId, int $amount, array $data = []): array } /** - * Get an existing order's status. + * Get an existing order's status by Sberbank's gateway identifier. * * @see https://securepayments.sberbank.ru/wiki/doku.php/integration:api:rest:requests:getorderstatusextended * - * @param int|string $orderId An order identifier + * @param int|string $orderId A Sberbank's gateway order identifier * @param array $data Additional data * * @return array A server's response @@ -317,6 +317,23 @@ public function getOrderStatus($orderId, array $data = []): array return $this->execute($this->prefixDefault . 'getOrderStatusExtended.do', $data); } + /** + * Get an existing order's status by own identifier. + * + * @see https://securepayments.sberbank.ru/wiki/doku.php/integration:api:rest:requests:getorderstatusextended + * + * @param int|string $orderId An own order identifier + * @param array $data Additional data + * + * @return array A server's response + */ + public function getOrderStatusByOwnId($orderId, array $data = []): array + { + $data['orderNumber'] = $orderId; + + return $this->execute($this->prefixDefault . 'getOrderStatusExtended.do', $data); + } + /** * Verify card enrollment in the 3DS. * diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 9ffb7a8..b1248dd 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -385,6 +385,21 @@ public function testGetsAnOrderStatus() $client->getOrderStatus('aaa-bbb-yyy', ['currency' => 100]); } + public function testGetsAnOrderStatusByOwnId() + { + $httpClient = $this->getHttpClientToTestSendingData( + '/rest/getOrderStatusExtended.do', + 'currency=100&orderNumber=111&token=abrakadabra' + ); + + $client = new Client([ + 'token' => 'abrakadabra', + 'httpClient' => $httpClient, + ]); + + $client->getOrderStatusByOwnId(111, ['currency' => 100]); + } + public function testVerifiesACardEnrollment() { $httpClient = $this->getHttpClientToTestSendingData(