Skip to content

Commit

Permalink
Get order status by own identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
voronkovich committed Aug 15, 2020
1 parent d89d8f3 commit 6095e00
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php

use Voronkovich\SberbankAcquiring\Client;
use Voronkovich\SberbankAcquiring\OrderStatus;

$client = new Client(['userName' => '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)
Expand Down
21 changes: 19 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
*
Expand Down
15 changes: 15 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 6095e00

Please sign in to comment.