forked from apoloz/alfa-bank-sdk
60 lines
2.0 KiB
PHP
60 lines
2.0 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\Core\AlfaBankConnector;
|
|
use Apoloz\AlfaBank\Data\B2C\B2CClientData;
|
|
use Apoloz\AlfaBank\Data\B2C\B2CPaymentRecipientData;
|
|
use Apoloz\AlfaBank\Data\B2C\B2CPaymentRequestData;
|
|
use Apoloz\AlfaBank\Requests\B2C\CreateB2CPaymentRequest;
|
|
use Apoloz\AlfaBank\Requests\B2C\GetB2CPaymentReportRequest;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
use Spatie\LaravelData\DataCollection;
|
|
|
|
test('can create b2c sbp payout', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
CreateB2CPaymentRequest::class => MockResponse::make([
|
|
'status' => 'SUCCESS'
|
|
], 200, ['Content-Type' => 'application/json']),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$payload = new B2CPaymentRequestData(
|
|
client: new B2CClientData(b2cClientId: 'uuid-1', partnerId: 123),
|
|
inn: '7700000000',
|
|
account: '40702...',
|
|
total: 100.53,
|
|
signedBody: 'SIGNATURE',
|
|
payments: B2CPaymentRecipientData::collect([
|
|
[
|
|
'phone' => '79001112233',
|
|
'amount' => 100.53,
|
|
'nspkBankId' => '100000000001',
|
|
'sequence' => 'seq-1',
|
|
'name' => ['first' => 'Ivan', 'last' => 'Ivanov']
|
|
]
|
|
], DataCollection::class)
|
|
);
|
|
|
|
$response = $connector->send(new CreateB2CPaymentRequest($payload));
|
|
|
|
expect($response->status())->toBe(200);
|
|
});
|
|
|
|
test('can get b2c payment report', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
GetB2CPaymentReportRequest::class => MockResponse::make([
|
|
'payments' => []
|
|
], 200, ['Content-Type' => 'application/json']),
|
|
]);
|
|
|
|
$config = createTestConfig();
|
|
$connector = new AlfaBankConnector($config);
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$response = $connector->send(new GetB2CPaymentReportRequest(partnerId: 123));
|
|
|
|
expect($response->status())->toBe(200);
|
|
});
|