forked from apoloz/alfa-bank-sdk
58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\Core\AlfaBankConnector;
|
|
use Apoloz\AlfaBank\Core\AlfaConfig;
|
|
use Apoloz\AlfaBank\Requests\Payments\CreatePaymentRequest;
|
|
use Apoloz\AlfaBank\Requests\Payments\GetPaymentStateRequest;
|
|
use Apoloz\AlfaBank\Data\Payments\PaymentData;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
|
|
test('can create payment order', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
CreatePaymentRequest::class => MockResponse::make('', 201),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$payload = new PaymentData(
|
|
amount: 100.00,
|
|
date: '2023-10-10',
|
|
externalId: 'ext-pay-1',
|
|
operationCode: '01',
|
|
payeeAccount: '40702...',
|
|
payeeBankBic: '044...',
|
|
payeeName: 'OOO ROMASHKA',
|
|
payerAccount: '40702...',
|
|
payerBankBic: '044...',
|
|
payerBankCorrAccount: '301...',
|
|
payerInn: '770...',
|
|
payerName: 'MY COMPANY',
|
|
priority: '5',
|
|
purpose: 'Payment for services'
|
|
);
|
|
|
|
$response = $connector->send(new CreatePaymentRequest($payload));
|
|
|
|
expect($response->status())->toBe(201);
|
|
});
|
|
|
|
test('can get payment state', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
GetPaymentStateRequest::class => MockResponse::make([
|
|
'bankStatus' => 'ACCEPTED',
|
|
'bankComment' => 'Processing'
|
|
], 200, ['Content-Type' => 'application/json']),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$response = $connector->send(new GetPaymentStateRequest('ext-pay-1'));
|
|
|
|
expect($response->status())->toBe(200)
|
|
->and($response->dto()->bankStatus)->toBe('ACCEPTED');
|
|
});
|