forked from apoloz/alfa-bank-sdk
37 lines
1.3 KiB
PHP
37 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Apoloz\AlfaBank\AlfaBankConnector;
|
|
use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\CreateBeneficiaryRequest;
|
|
use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData;
|
|
use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\AddressData;
|
|
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData;
|
|
use Saloon\Http\Faking\MockResponse;
|
|
|
|
test('can create a beneficiary', function () {
|
|
$mockClient = new \Saloon\Http\Faking\MockClient([
|
|
CreateBeneficiaryRequest::class => MockResponse::make([
|
|
'requestId' => 'req-123',
|
|
'status' => 'PENDING'
|
|
], 202),
|
|
]);
|
|
|
|
$connector = new AlfaBankConnector('cert.pem', 'key.pem');
|
|
$connector->withMockClient($mockClient);
|
|
|
|
$payload = new CreateBeneficiaryRequestData(
|
|
type: 'FL_RESIDENT',
|
|
countryOfTaxResidence: 'RU',
|
|
addresses: AddressData::collect([
|
|
new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU')
|
|
]),
|
|
digestSignatures: DigestSignatureData::collect([
|
|
new DigestSignatureData('base64sig', 'rsa')
|
|
])
|
|
);
|
|
|
|
$response = $connector->send(new CreateBeneficiaryRequest($payload));
|
|
|
|
expect($response->status())->toBe(202)
|
|
->and($response->dto()->requestId)->toBe('req-123');
|
|
});
|