-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da2a11b
commit d9eb38a
Showing
19 changed files
with
578 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* YandexKassa driver for the Omnipay PHP payment processing library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-YandexKassa | ||
* @package omnipay-YandexKassa | ||
* @license MIT | ||
* @copyright Copyright (c) 2019, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace Omnipay\YandexKassa\Tests\Message; | ||
|
||
use Omnipay\YandexKassa\Message\CaptureRequest; | ||
use Omnipay\YandexKassa\Message\CaptureResponse; | ||
use Symfony\Component\HttpFoundation\Request as HttpRequest; | ||
|
||
class CaptureRequestTest extends TestCase | ||
{ | ||
/** @var CaptureRequest */ | ||
private $request; | ||
|
||
private $shopId = '54401'; | ||
private $secretKey = 'test_Fh8hUAVVBGUGbjmlzba6TB0iyUbos_lueTHE-axOwM0'; | ||
private $transactionReference = '2475e163-000f-5000-9000-18030530d620'; | ||
private $transactionId = '5ce3cdb0d1436'; | ||
private $amount = '187.50'; | ||
private $currency = 'RUB'; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$httpRequest = new HttpRequest(); | ||
$this->request = new CaptureRequest($this->getHttpClient(), $httpRequest); | ||
$this->request->initialize([ | ||
'yandexClient' => $this->buildYandexClient($this->shopId, $this->secretKey), | ||
'shopId' => $this->shopId, | ||
'secret' => $this->secretKey, | ||
'transactionReference' => $this->transactionReference, | ||
'transactionId' => $this->transactionId, | ||
'amount' => $this->amount, | ||
'currency' => $this->currency, | ||
]); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$data = $this->request->getData(); | ||
$this->assertEmpty($data); | ||
} | ||
|
||
public function testSendData() | ||
{ | ||
$curlClientStub = $this->getCurlClientStub(); | ||
$curlClientStub->method('sendRequest')->willReturn([ | ||
[], | ||
$this->fixture('payment.succeeded'), | ||
['http_code' => 200], | ||
]); | ||
|
||
$this->getYandexClient($this->request) | ||
->setApiClient($curlClientStub) | ||
->setAuth($this->shopId, $this->secretKey); | ||
|
||
$response = $this->request->sendData([]); | ||
$this->assertInstanceOf(CaptureResponse::class, $response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace Omnipay\YandexKassa\Tests\Message; | ||
|
||
use Omnipay\YandexKassa\Message\CaptureRequest; | ||
use Omnipay\YandexKassa\Message\CaptureResponse; | ||
use Omnipay\YandexKassa\Message\DetailsResponse; | ||
use Omnipay\YandexKassa\Message\IncomingNotificationRequest; | ||
use Symfony\Component\HttpFoundation\Request as HttpRequest; | ||
|
||
class CaptureResponseTest extends TestCase | ||
{ | ||
/** @var IncomingNotificationRequest */ | ||
private $request; | ||
|
||
|
||
private $shopId = '54401'; | ||
private $secretKey = 'test_Fh8hUAVVBGUGbjmlzba6TB0iyUbos_lueTHE-axOwM0'; | ||
private $transactionReference = '2475e163-000f-5000-9000-18030530d620'; | ||
private $transactionId = '5ce3cdb0d1436'; | ||
private $amount = '187.50'; | ||
private $currency = 'RUB'; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$httpRequest = new HttpRequest(); | ||
$this->request = new CaptureRequest($this->getHttpClient(), $httpRequest); | ||
$this->request->initialize([ | ||
'yandexClient' => $this->buildYandexClient($this->shopId, $this->secretKey), | ||
'shopId' => $this->shopId, | ||
'secret' => $this->secretKey, | ||
'transactionReference' => $this->transactionReference, | ||
'transactionId' => $this->transactionId, | ||
'amount' => $this->amount, | ||
'currency' => $this->currency, | ||
]); | ||
} | ||
|
||
public function testSuccess(): void | ||
{ | ||
$curlClientStub = $this->getCurlClientStub(); | ||
$curlClientStub->method('sendRequest') | ||
->willReturn([ | ||
[], | ||
$this->fixture('payment.succeeded'), | ||
['http_code' => 200] | ||
]); | ||
|
||
$this->getYandexClient($this->request) | ||
->setApiClient($curlClientStub) | ||
->setAuth($this->shopId, $this->secretKey); | ||
|
||
/** @var DetailsResponse $response */ | ||
$response = $this->request->send(); | ||
|
||
$this->assertInstanceOf(DetailsResponse::class, $response); | ||
$this->assertTrue($response->isSuccessful()); | ||
$this->assertSame('5ce3cdb0d1436', $response->getTransactionId()); | ||
$this->assertSame('2475e163-000f-5000-9000-18030530d620', $response->getTransactionReference()); | ||
$this->assertSame('187.50', $response->getAmount()); | ||
$this->assertSame('RUB', $response->getCurrency()); | ||
$this->assertSame('2019-05-21T10:09:54+00:00', $response->getPaymentDate()->format(\DATE_ATOM)); | ||
$this->assertSame('succeeded', $response->getState()); | ||
$this->assertSame('Bank card *4444', $response->getPayer()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* YandexKassa driver for the Omnipay PHP payment processing library | ||
* | ||
* @link https://github.com/hiqdev/omnipay-YandexKassa | ||
* @package omnipay-YandexKassa | ||
* @license MIT | ||
* @copyright Copyright (c) 2019, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace Omnipay\YandexKassa\Tests\Message; | ||
|
||
use Omnipay\YandexKassa\Message\DetailsRequest; | ||
use Omnipay\YandexKassa\Message\DetailsResponse; | ||
use Symfony\Component\HttpFoundation\Request as HttpRequest; | ||
|
||
class DetailsRequestTest extends TestCase | ||
{ | ||
/** @var DetailsRequest */ | ||
private $request; | ||
|
||
private $shopId = '54401'; | ||
private $secretKey = 'test_Fh8hUAVVBGUGbjmlzba6TB0iyUbos_lueTHE-axOwM0'; | ||
private $transactionReference = '2475e163-000f-5000-9000-18030530d620'; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$httpRequest = new HttpRequest(); | ||
$this->request = new DetailsRequest($this->getHttpClient(), $httpRequest); | ||
$this->request->initialize([ | ||
'yandexClient' => $this->buildYandexClient($this->shopId, $this->secretKey), | ||
'shopId' => $this->shopId, | ||
'secret' => $this->secretKey, | ||
'transactionReference' => $this->transactionReference, | ||
]); | ||
} | ||
|
||
public function testGetData() | ||
{ | ||
$data = $this->request->getData(); | ||
$this->assertEmpty($data); | ||
} | ||
|
||
public function testSendData() | ||
{ | ||
$curlClientStub = $this->getCurlClientStub(); | ||
$curlClientStub->method('sendRequest') | ||
->willReturn([ | ||
[], | ||
$this->fixture('payment.waiting_for_capture'), | ||
['http_code' => 200] | ||
]); | ||
|
||
$this->getYandexClient($this->request) | ||
->setApiClient($curlClientStub) | ||
->setAuth($this->shopId, $this->secretKey); | ||
|
||
$response = $this->request->sendData([]); | ||
$this->assertInstanceOf(DetailsResponse::class, $response); | ||
} | ||
} |
Oops, something went wrong.