forked from apoloz/alfa-bank-sdk
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\Core\AlfaConfig;
|
|
use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData;
|
|
use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest;
|
|
use Apoloz\AlfaBank\Sbp\SbpConnector;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
|
|
test('can generate static qr code', function (): void {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
GetQrCodeRequest::class => MockResponse::make([
|
|
'ErrorCode' => 0,
|
|
'message' => 'OK',
|
|
'payload' => 'https://qr.nspk.ru/test',
|
|
'image' => 'base64image',
|
|
], 200),
|
|
]);
|
|
|
|
$config = new AlfaConfig(
|
|
baseUrl: 'https://test.com',
|
|
certificatePath: __DIR__ . '/../../test_key.pem',
|
|
privateKeyPath: __DIR__ . '/../../test_key.pem'
|
|
);
|
|
$connector = new SbpConnector($config, 'key-alias');
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$payload = new QrCodeRequestData(
|
|
termNo: 'test-term',
|
|
amount: '100'
|
|
);
|
|
|
|
$response = $connector->send(new GetQrCodeRequest($payload));
|
|
|
|
expect($response->status())->toBe(200)
|
|
->and($response->dto()->payload)->toBe('https://qr.nspk.ru/test');
|
|
});
|