diff --git a/examples/01_baas_flow.php b/examples/01_baas_flow.php index 008c7a9..8284aba 100644 --- a/examples/01_baas_flow.php +++ b/examples/01_baas_flow.php @@ -18,20 +18,20 @@ $baas = AlfaBank::baas( try { echo "Authenticating...\n"; - + // AUTHENTICATION: // client_id: From Developer Portal (App Settings) // client_secret: From Developer Portal (App Settings -> Key Icon) OR generated via SDK (examples/14_generate_client_secret.php) - + // METHOD A: Standard Client Credentials (for simple services) // $baas->login( // clientId: 'your-client-id-uuid', // clientSecret: 'your-client-secret-string' // ); - + // METHOD B: Authorization Code Flow (H2H) (REQUIRED for Nominal Accounts) // See examples/13_h2h_auth_service.php for the full setup - + // We re-initialize with auth credentials if we didn't pass them initially $baas = AlfaBank::baas( certificatePath: __DIR__ . '/certs/client.cer', @@ -41,7 +41,7 @@ try { clientSecret: 'your-client-secret', redirectUri: 'https://...' ); - + // Now you can use OAuth methods: // $url = $baas->getAuthorizationUrl(); // or @@ -51,17 +51,16 @@ try { // 2. Create a Beneficiary (Counterparty) echo "Creating Beneficiary...\n"; - + // In a real app, use the DTOs // $payload = new CreateBeneficiaryRequestData(...); // $baas->send(new CreateBeneficiaryRequest($payload)); - + echo "Beneficiary Request Sent (Mock).\n"; } catch (\Exception $e) { - echo "Error: " . $e->getMessage() . "\n"; + echo 'Error: ' . $e->getMessage() . "\n"; if ($e instanceof \Apoloz\AlfaBank\Exceptions\AlfaBankException) { - echo "API Code: " . $e->getErrorCode() . "\n"; + echo 'API Code: ' . $e->getErrorCode() . "\n"; } } - diff --git a/examples/02_sbp_qr.php b/examples/02_sbp_qr.php index 3f5d099..cc3a73a 100644 --- a/examples/02_sbp_qr.php +++ b/examples/02_sbp_qr.php @@ -4,8 +4,8 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; use Apoloz\AlfaBank\Enums\Environment; -use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest; use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData; +use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest; // 1. Initialize SBP $sbp = AlfaBank::sbp( @@ -30,8 +30,8 @@ try { if ($response->successful()) { $qrData = $response->dto(); - echo "QR Payload: " . $qrData->payload . "\n"; - echo "QR Image URL: " . $qrData->image . "\n"; + echo 'QR Payload: ' . $qrData->payload . "\n"; + echo 'QR Image URL: ' . $qrData->image . "\n"; } else { echo "Failed to generate QR.\n"; } @@ -41,5 +41,5 @@ try { // foreach($paginator as $item) { ... } } catch (\Exception $e) { - echo "Error: " . $e->getMessage() . "\n"; + echo 'Error: ' . $e->getMessage() . "\n"; } diff --git a/examples/03_sandbox_init.php b/examples/03_sandbox_init.php index b14004b..bf5881a 100644 --- a/examples/03_sandbox_init.php +++ b/examples/03_sandbox_init.php @@ -7,44 +7,43 @@ use Apoloz\AlfaBank\Enums\Environment; /** * This example shows how to initialize the SDK with the Sandbox files provided by the bank. - * + * * IMPORTANT: You must first convert the .pfx file to .pem format using OpenSSL: - * - * 1. Extract signing key: + * + * 1. Extract signing key: * openssl pkcs12 -in certificate_for_requests_sign_with_password_1234.pfx -nocerts -out signing_key.pem -nodes -password pass:1234 - * + * * 2. Extract signing certificate: * openssl pkcs12 -in certificate_for_requests_sign_with_password_1234.pfx -clcerts -nokeys -out signing_cert.pem -password pass:1234 - * + * * 3. Ensure transport certs are in PEM format if they aren't already. */ // --- 1. BaaS / Main API Initialization --- $baas = AlfaBank::baas( // Transport (mTLS) - use the sandbox_cert/key files - certificatePath: __DIR__ . '/certs/sandbox_cert_2026.cer', + certificatePath: __DIR__ . '/certs/sandbox_cert_2026.cer', privateKeyPath: __DIR__ . '/certs/sandbox_key_2026.key', - + // Signing (Business Logic) - use the extracted PEM files from PFX signingCertificatePath: __DIR__ . '/certs/signing_cert.pem', signingPrivateKeyPath: __DIR__ . '/certs/signing_key.pem', - + environment: Environment::SANDBOX, caBundlePath: __DIR__ . '/certs/apica_2022_chain.cer' // Trust chain ); echo "BaaS Connector Initialized.\n"; - // --- 2. SBP (Faster Payments) Initialization --- $sbp = AlfaBank::sbp( // SBP usually uses its own mTLS pair found in the sbp_payout/mtls folder certificatePath: __DIR__ . '/certs/sbp_payout/mtls/9728109955_test_mtls.crt', privateKeyPath: __DIR__ . '/certs/sbp_payout/mtls/9728109955_test_mtls.key', - + // Terminal ID from terminal_num.txt - keyNameAlias: '9728109955', - + keyNameAlias: '9728109955', + environment: Environment::SANDBOX, caBundlePath: __DIR__ . '/certs/sbp_payout/sandbox_root/root-ca-test.crt' ); @@ -52,4 +51,3 @@ $sbp = AlfaBank::sbp( echo "SBP Connector Initialized.\n"; // Now you can use $baas->login(...) or $sbp->send(...) - diff --git a/examples/04_nominal_accounts.php b/examples/04_nominal_accounts.php index f5b3d6f..9fce295 100644 --- a/examples/04_nominal_accounts.php +++ b/examples/04_nominal_accounts.php @@ -3,10 +3,10 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; +use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\AddressData; +use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData; use Apoloz\AlfaBank\Enums\Environment; use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\CreateBeneficiaryRequest; -use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData; -use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\AddressData; use Spatie\LaravelData\DataCollection; // 1. Initialize @@ -29,7 +29,7 @@ $payload = new CreateBeneficiaryRequestData( countryOfTaxResidence: 'RU', name: 'Ivanov Ivan', addresses: new DataCollection(AddressData::class, [ - new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU') + new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU'), ]) // Note: digestSignatures is now optional! ); @@ -40,12 +40,12 @@ $payload->sign($baas->getSigner()); // 5. Send $response = $baas->send(new CreateBeneficiaryRequest($payload)); -echo "Status: " . $response->status() . "\n"; -echo "ID: " . $response->dto()->id . "\n"; +echo 'Status: ' . $response->status() . "\n"; +echo 'ID: ' . $response->dto()->id . "\n"; if ($response->successful()) { $data = $response->dto(); // BeneficiaryResponseData echo "Beneficiary creation accepted. ID: {$data->id}, Status: {$data->status}\n"; } else { - echo "Error: " . $response->body() . "\n"; + echo 'Error: ' . $response->body() . "\n"; } diff --git a/examples/05_webhooks.php b/examples/05_webhooks.php index fdbbc5e..b2f808e 100644 --- a/examples/05_webhooks.php +++ b/examples/05_webhooks.php @@ -3,10 +3,10 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; -use Apoloz\AlfaBank\Webhooks\WebhookFactory; -use Apoloz\AlfaBank\Requests\Webhooks\GetWebhooksRequest; -use Apoloz\AlfaBank\Requests\Webhooks\CreateWebhookRequest; use Apoloz\AlfaBank\Data\Webhooks\Subscriptions\WebhookSubscriptionRequestData; +use Apoloz\AlfaBank\Requests\Webhooks\CreateWebhookRequest; +use Apoloz\AlfaBank\Requests\Webhooks\GetWebhooksRequest; +use Apoloz\AlfaBank\Webhooks\WebhookFactory; /** * 1. Managing Webhooks (BaaS API) @@ -15,7 +15,7 @@ $baas = AlfaBank::baas('cert.pem', 'key.pem'); $baas->login('id', 'secret'); // List existing webhooks -$response = $baas->send(new GetWebhooksRequest()); +$response = $baas->send(new GetWebhooksRequest); $webhooks = $response->dto(); // DataCollection of WebhookSubscriptionData foreach ($webhooks as $webhook) { @@ -38,9 +38,9 @@ $rawPayload = [ 'transactionId' => 'TX-12345', 'amount' => ['amount' => 100.50, 'currencyName' => 'RUR'], 'direction' => 'CREDIT', - 'paymentPurpose' => 'Test payment' - ] - ] + 'paymentPurpose' => 'Test payment', + ], + ], ]; // Use the factory to parse the payload into a DTO diff --git a/examples/06_sbp_b2c_payout.php b/examples/06_sbp_b2c_payout.php index 8069264..d9aed47 100644 --- a/examples/06_sbp_b2c_payout.php +++ b/examples/06_sbp_b2c_payout.php @@ -3,16 +3,15 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; -use Apoloz\AlfaBank\Requests\B2C\CreateB2CPaymentRequest; -use Apoloz\AlfaBank\Data\B2C\B2CPaymentRequestData; 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 Spatie\LaravelData\DataCollection; /** * Example: B2C Payout via SBP (Phone Number). */ - $baas = AlfaBank::baas( certificatePath: 'path/to/cert.pem', privateKeyPath: 'path/to/key.pem' @@ -29,8 +28,8 @@ $payload = new B2CPaymentRequestData( 'phone' => '79001112233', 'amount' => 100.00, 'nspkBankId' => '100000000001', - 'sequence' => 'unique-payout-id-1' - ] + 'sequence' => 'unique-payout-id-1', + ], ], DataCollection::class) ); @@ -41,6 +40,5 @@ if ($response->successful()) { $data = $response->dto(); // B2CPaymentResponseData echo "Payout request sent. Status: {$data->status}\n"; } else { - echo "Error: " . $response->body() . "\n"; + echo 'Error: ' . $response->body() . "\n"; } - diff --git a/examples/07_registry_signing.php b/examples/07_registry_signing.php index 9a135a0..f2540ef 100644 --- a/examples/07_registry_signing.php +++ b/examples/07_registry_signing.php @@ -3,18 +3,17 @@ require_once __DIR__ . '/../vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; -use Apoloz\AlfaBank\Utils\CmsSigner; -use Apoloz\AlfaBank\Requests\Registries\CreateRegistryRequest; -use Apoloz\AlfaBank\Data\Registries\RegistryRequestData; use Apoloz\AlfaBank\Data\Registries\RegistryPaymentData; -use Apoloz\AlfaBank\Requests\Registries\SignRegistryRequest; +use Apoloz\AlfaBank\Data\Registries\RegistryRequestData; use Apoloz\AlfaBank\Data\Registries\RegistrySignatureData; +use Apoloz\AlfaBank\Requests\Registries\CreateRegistryRequest; +use Apoloz\AlfaBank\Requests\Registries\SignRegistryRequest; +use Apoloz\AlfaBank\Utils\CmsSigner; use Spatie\LaravelData\DataCollection; /** * Example: Creating and Signing a Payment Registry (Batch Payments). */ - $baas = AlfaBank::baas( certificatePath: 'path/to/cert.pem', privateKeyPath: 'path/to/key.pem' @@ -31,8 +30,8 @@ $payload = new RegistryRequestData( 'payeeInn' => '770...', 'payeeName' => 'Vendor 1', 'payerAccount' => '40702...', - 'purpose' => 'Payment for goods' - ] + 'purpose' => 'Payment for goods', + ], ], DataCollection::class) ); @@ -43,7 +42,7 @@ $registryId = $response->dto()->id; echo "Registry Created: $registryId\n"; // 2. Sign Registry -// In real life, you might need to sign the digest provided by the bank +// In real life, you might need to sign the digest provided by the bank // or the registry content itself. This depends on the specific bank requirement. $signature = CmsSigner::sign( $registryId, // Example data @@ -55,11 +54,10 @@ $signatures = RegistrySignatureData::collect([ [ 'base64Encoded' => $signature, 'signatureType' => 'RSA', - 'certificateUuid' => 'YOUR_CERT_UUID' - ] + 'certificateUuid' => 'YOUR_CERT_UUID', + ], ], DataCollection::class); $baas->send(new SignRegistryRequest($registryId, $signatures)); echo "Registry Signed.\n"; - diff --git a/examples/08_nominal_accounts_full_lifecycle.php b/examples/08_nominal_accounts_full_lifecycle.php index 0791c9e..207a370 100644 --- a/examples/08_nominal_accounts_full_lifecycle.php +++ b/examples/08_nominal_accounts_full_lifecycle.php @@ -14,7 +14,6 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\RecipientData; use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\CreateBeneficiaryRequest; use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\ScoreBeneficiaryRequest; use Apoloz\AlfaBank\Requests\NominalAccounts\Payouts\CreatePayoffRequest; -use Apoloz\AlfaBank\Utils\CmsSigner; use Spatie\LaravelData\DataCollection; /** @@ -23,7 +22,7 @@ use Spatie\LaravelData\DataCollection; */ // 1. Инициализация SDK -// Сертификаты (Transport Certs): +// Сертификаты (Transport Certs): // Получены от банка (Sandbox) или сгенерированы вами и активированы банком (Production). $baas = AlfaBank::baas( certificatePath: 'transport.crt', @@ -50,27 +49,26 @@ try { countryOfTaxResidence: 'RU', name: 'Иванов Иван', addresses: AddressData::collect([ - new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU') + new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU'), ]) ); - + // Автоматическая подпись $benData->sign($baas->getSigner()); - + $response = $baas->send(new CreateBeneficiaryRequest($benData)); $beneficiaryId = $response->dto()->id; echo "Beneficiary Created: $beneficiaryId\n"; // --- ЭТАП 2: Идентификация Входящего Платежа --- // После создания банк должен проверить бенефициара - echo "2. Запуск верификации (скоринга)..."; + echo '2. Запуск верификации (скоринга)...'; $baas->send(new ScoreBeneficiaryRequest($beneficiaryId)); echo "Скоринг инициирован.\n"; - // --- ЭТАП 3: Выплата (Payoff) --- // Когда бенефициар проверен, можно делать выплату - echo "3. Создание выплаты..."; + echo '3. Создание выплаты...'; $payoffData = new PayoffRequestData( type: 'PAYMENT_ORDER', @@ -89,14 +87,14 @@ try { digestSignatures: DigestSignatureData::collect([ [ 'base64Encoded' => '...', // Здесь должна быть подпись тела выплаты - 'signatureType' => 'cms' - ] + 'signatureType' => 'cms', + ], ], DataCollection::class) ); $payoffResponse = $baas->send(new CreatePayoffRequest($payoffData)); - echo "Выплата создана. ID: " . $payoffResponse->dto()->payoffId . "\n"; + echo 'Выплата создана. ID: ' . $payoffResponse->dto()->payoffId . "\n"; } catch (\Exception $e) { - echo "Ошибка: " . $e->getMessage() . "\n"; + echo 'Ошибка: ' . $e->getMessage() . "\n"; } diff --git a/examples/09_self_employed_income.php b/examples/09_self_employed_income.php index 96a65b2..563924c 100644 --- a/examples/09_self_employed_income.php +++ b/examples/09_self_employed_income.php @@ -5,15 +5,14 @@ declare(strict_types=1); require_once __DIR__ . '/../vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; +use Apoloz\AlfaBank\Data\SelfEmployed\CreateIncomeRequestData; use Apoloz\AlfaBank\Enums\Environment; use Apoloz\AlfaBank\Requests\SelfEmployed\RegisterIncomeRequest; -use Apoloz\AlfaBank\Data\SelfEmployed\CreateIncomeRequestData; /** * Пример регистрации дохода самозанятого. * Позволяет автоматически задекларировать доход в ФНС от лица самозанятого. */ - $baas = AlfaBank::baas( certificatePath: __DIR__ . '/../tests/test_cert.pem', privateKeyPath: __DIR__ . '/../tests/test_key.pem', @@ -37,6 +36,5 @@ try { echo "ID запроса: {$dto->requestId}\n"; echo "Текущий статус: {$dto->status}\n"; } catch (\Exception $e) { - echo "Ошибка: " . $e->getMessage() . "\n"; + echo 'Ошибка: ' . $e->getMessage() . "\n"; } - diff --git a/examples/10_sbp_reversal_history.php b/examples/10_sbp_reversal_history.php index 9fa1f43..5b075ca 100644 --- a/examples/10_sbp_reversal_history.php +++ b/examples/10_sbp_reversal_history.php @@ -12,7 +12,6 @@ use Apoloz\AlfaBank\Sbp\Requests\Reversal\GetQrcReversalHistoryRequest; * Пример получения истории возвратов по транзакции СБП. * Полезно для отладки частичных возвратов или поиска зависших операций. */ - $sbp = AlfaBank::sbp( certificatePath: __DIR__ . '/../tests/test_cert.pem', privateKeyPath: __DIR__ . '/../tests/test_key.pem', @@ -27,7 +26,7 @@ try { $response = $sbp->send(new GetQrcReversalHistoryRequest($payrrn, $termNo)); $dto = $response->dto(); - echo "Найдено возвратов: " . ($dto->refunds ? $dto->refunds->count() : 0) . "\n"; + echo 'Найдено возвратов: ' . ($dto->refunds ? $dto->refunds->count() : 0) . "\n"; if ($dto->refunds) { foreach ($dto->refunds as $refund) { @@ -38,6 +37,5 @@ try { } } } catch (\Exception $e) { - echo "Ошибка: " . $e->getMessage() . "\n"; + echo 'Ошибка: ' . $e->getMessage() . "\n"; } - diff --git a/examples/11_file_upload_kyc.php b/examples/11_file_upload_kyc.php index 1e6beef..fc852be 100644 --- a/examples/11_file_upload_kyc.php +++ b/examples/11_file_upload_kyc.php @@ -13,7 +13,6 @@ use Apoloz\AlfaBank\Requests\Files\UploadFileRequest; * Сначала создается бенефициар, банк возвращает ссылку для загрузки паспорта. * Затем SDK загружает файл по этой ссылке. */ - $baas = AlfaBank::baas( certificatePath: __DIR__ . '/../tests/test_cert.pem', privateKeyPath: __DIR__ . '/../tests/test_key.pem', @@ -34,13 +33,12 @@ try { if ($response->status() === 200) { echo "Файл успешно загружен в банк!\n"; } else { - echo "Ошибка загрузки: " . $response->body() . "\n"; + echo 'Ошибка загрузки: ' . $response->body() . "\n"; } } catch (\Exception $e) { - echo "Ошибка: " . $e->getMessage() . "\n"; + echo 'Ошибка: ' . $e->getMessage() . "\n"; } finally { if (is_resource($fileResource)) { fclose($fileResource); } } - diff --git a/examples/12_auth_code_flow.php b/examples/12_auth_code_flow.php index 2a9aee6..463e015 100644 --- a/examples/12_auth_code_flow.php +++ b/examples/12_auth_code_flow.php @@ -10,7 +10,7 @@ use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\GetBeneficiariesReque /** * Authorization Code Flow (H2H) Example - * + * * Сценарий: Обмен полученного в браузере кода на токены и дальнейшая работа через refresh_token. */ @@ -21,20 +21,20 @@ $config = [ // Sandbox: Bank sent you these via email/portal. 'cert' => __DIR__ . '/certs/client.cer', 'key' => __DIR__ . '/certs/private.key', - + // APP CREDENTIALS (OAUTH2): // From: Developer Portal -> Your App -> Settings/Keys // Note: If you don't have client_secret, generate it using `14_generate_client_secret.php` 'client_id' => getenv('ALFA_BAAS_CLIENT_ID'), 'client_secret' => getenv('ALFA_BAAS_CLIENT_SECRET'), - + // REDIRECT URI: // Must match exactly what you entered in Developer Portal for this App. - 'redirect_uri' => 'https://your-app.com/callback', - + 'redirect_uri' => 'https://your-app.com/callback', + // BUSINESS DATA: // From your Contract or Internet Bank. Not related to Auth directly. - 'account_number' => '40702810...' + 'account_number' => '40702810...', ]; // 2. Инициализация коннектора @@ -48,46 +48,45 @@ $baas = AlfaBank::baas( try { // --- СЦЕНАРИЙ А: Первый вход (у нас есть только код из браузера) --- // Ссылка для получения кода: https://baas.alfabank.ru/oidc/authorize?response_type=code&client_id=... - + $authCode = 'code_from_browser_url'; // <-- Вставьте сюда код - + if ($authCode) { echo "Обмениваем код на токены...\n"; $tokenData = $baas->authWithCode($authCode, $config['redirect_uri']); - + echo "Access Token получен!\n"; - echo "Refresh Token: " . $tokenData->refresh_token . "\n"; + echo 'Refresh Token: ' . $tokenData->refresh_token . "\n"; echo "(Сохраните refresh_token в базу данных)\n\n"; } // --- СЦЕНАРИЙ Б: Повторный вход (у нас есть сохраненный refresh_token) --- $savedRefreshToken = 'your_saved_refresh_token_from_db'; - + if ($savedRefreshToken) { echo "Обновляем сессию по Refresh Token...\n"; $tokenData = $baas->refreshToken($savedRefreshToken); - - echo "Сессия обновлена. Новый Access Token действует " . $tokenData->expires_in . " сек.\n"; + + echo 'Сессия обновлена. Новый Access Token действует ' . $tokenData->expires_in . " сек.\n"; if ($tokenData->refresh_token) { - echo "Пришел новый Refresh Token (сохраните его): " . $tokenData->refresh_token . "\n"; + echo 'Пришел новый Refresh Token (сохраните его): ' . $tokenData->refresh_token . "\n"; } } // 3. Выполняем защищенный запрос (например, список бенефициаров) // Коннектор уже авторизован (внутри updateAccessToken/authWithCode вызывается authenticate()) - + echo "Запрашиваем список...\n"; $response = $baas->send(new GetBeneficiariesRequest( accountNumber: $config['account_number'], type: 'FL_RESIDENT' )); - echo "Успешно! Найдено: " . count($response->dto()->beneficiaries) . "\n"; + echo 'Успешно! Найдено: ' . count($response->dto()->beneficiaries) . "\n"; } catch (\Exception $e) { - echo "Ошибка: " . $e->getMessage() . "\n"; + echo 'Ошибка: ' . $e->getMessage() . "\n"; if (method_exists($e, 'getResponse')) { - echo "Body: " . $e->getResponse()->body() . "\n"; + echo 'Body: ' . $e->getResponse()->body() . "\n"; } } - diff --git a/examples/13_h2h_auth_service.php b/examples/13_h2h_auth_service.php index 7fbe74d..4532618 100644 --- a/examples/13_h2h_auth_service.php +++ b/examples/13_h2h_auth_service.php @@ -34,7 +34,6 @@ $baas = AlfaBank::baas( $link = $baas->getAuthorizationUrl(scopes: ['beneficiaries', 'payment']); echo "1. Перейдите по ссылке для авторизации:\n$link\n\n"; - // --- СЦЕНАРИЙ 2: Обмен кода на токен (в callback-скрипте) --- // $code приходит в GET-параметре: /callback?code=... $codeFromUrl = '...код из браузера...'; @@ -42,18 +41,18 @@ $codeFromUrl = '...код из браузера...'; if ($codeFromUrl !== '...код из браузера...') { try { echo "2. Обмен кода на токены...\n"; - + // Saloon делает всё сам: $authenticator = $baas->getAccessToken($codeFromUrl); - - echo "Access Token: " . substr($authenticator->getAccessToken(), 0, 20) . "...\n"; - echo "Refresh Token: " . $authenticator->getRefreshToken() . "\n"; - echo "Expires At: " . $authenticator->getExpiresAt()->format('Y-m-d H:i:s') . "\n"; - + + echo 'Access Token: ' . substr($authenticator->getAccessToken(), 0, 20) . "...\n"; + echo 'Refresh Token: ' . $authenticator->getRefreshToken() . "\n"; + echo 'Expires At: ' . $authenticator->getExpiresAt()->format('Y-m-d H:i:s') . "\n"; + // TODO: Сохраните refresh_token в базу данных! - + } catch (\Exception $e) { - echo "Ошибка обмена кода: " . $e->getMessage() . "\n"; + echo 'Ошибка обмена кода: ' . $e->getMessage() . "\n"; } } @@ -63,22 +62,21 @@ $savedRefreshToken = '...saved_refresh_token...'; if ($savedRefreshToken !== '...saved_refresh_token...') { try { echo "3. Обновление токена...\n"; - + // Обновляем токен $newAuthenticator = $baas->refreshAccessToken($savedRefreshToken); - + // Автоматически применяем к коннектору (для текущего скрипта) $baas->authenticate($newAuthenticator); - + echo "Токен обновлен!\n"; - + // Если пришел новый refresh_token — обновляем его if ($newAuthenticator->getRefreshToken()) { - // DB::update(...) - echo "Новый Refresh Token получен.\n"; + // DB::update(...) + echo "Новый Refresh Token получен.\n"; } } catch (\Exception $e) { - echo "Ошибка обновления токена: " . $e->getMessage() . "\n"; + echo 'Ошибка обновления токена: ' . $e->getMessage() . "\n"; } } - diff --git a/examples/14_generate_client_secret.php b/examples/14_generate_client_secret.php index df7d6c5..fb94bfb 100644 --- a/examples/14_generate_client_secret.php +++ b/examples/14_generate_client_secret.php @@ -5,14 +5,14 @@ declare(strict_types=1); require_once __DIR__ . '/vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; -use Apoloz\AlfaBank\Requests\Auth\RefreshClientSecretRequest; use Apoloz\AlfaBank\Enums\Environment; +use Apoloz\AlfaBank\Requests\Auth\RefreshClientSecretRequest; /** * UTILITY SCRIPT: Generate a Client Secret using your TLS certificates. - * + * * Run this ONCE when setting up the project or if you lose your secret. - * + * * Requirements: * 1. You have the `client_id` (Found in Developer Portal -> App Settings URL or Overview). * 2. You have the TLS certificates (.pem/.key) authorized by the bank. @@ -22,7 +22,7 @@ use Apoloz\AlfaBank\Enums\Environment; // 1. Configuration $certPath = __DIR__ . '/certs/transport.crt'; // Your mTLS certificate -$keyPath = __DIR__ . '/certs/transport.key'; // Your mTLS private key +$keyPath = __DIR__ . '/certs/transport.key'; // Your mTLS private key $clientId = 'YOUR_CLIENT_ID_UUID'; // E.g. '0cee0683-85ae-...' // 2. Initialize Connector (No Login required yet) @@ -41,20 +41,20 @@ try { // 4. Output Result $data = $response->dto(); // Returns ClientSecretData - + echo "\n-------------------------------------------------------\n"; echo "SUCCESS! New Client Secret Generated:\n"; echo "-------------------------------------------------------\n"; - echo "Client ID: " . $data->clientId . "\n"; - echo "Client Secret: " . $data->clientSecret . "\n"; + echo 'Client ID: ' . $data->clientId . "\n"; + echo 'Client Secret: ' . $data->clientSecret . "\n"; echo "-------------------------------------------------------\n"; echo "IMPORTANT: Save this to your .env file immediately.\n"; echo "It will not be shown again.\n"; } catch (\Exception $e) { echo "\nERROR: Could not generate secret.\n"; - echo "Message: " . $e->getMessage() . "\n"; + echo 'Message: ' . $e->getMessage() . "\n"; if (method_exists($e, 'getResponse')) { - echo "Response: " . $e->getResponse()->body() . "\n"; + echo 'Response: ' . $e->getResponse()->body() . "\n"; } } diff --git a/examples/15_nominal_accounts_list.php b/examples/15_nominal_accounts_list.php index 0ddc047..d44723c 100644 --- a/examples/15_nominal_accounts_list.php +++ b/examples/15_nominal_accounts_list.php @@ -10,11 +10,11 @@ use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\GetBeneficiariesReque /** * FINAL GOAL EXAMPLE: Get List of Nominal Account Beneficiaries - * + * * Usage: * 1. Standalone: php examples/15_nominal_accounts_list.php * 2. Laravel Tinker: Copy-paste the code below (replace config with app() helper). - * + * * This script assumes you have already: * 1. Generated/Received Certificates. * 2. Obtained Client ID & Secret (via Portal or Script 14). @@ -23,15 +23,15 @@ use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\GetBeneficiariesReque // --- CONFIGURATION (From .env) --- $config = [ - 'client_id' => getenv('ALFA_BAAS_CLIENT_ID'), + 'client_id' => getenv('ALFA_BAAS_CLIENT_ID'), 'client_secret' => getenv('ALFA_BAAS_CLIENT_SECRET'), - 'redirect_uri' => 'https://your-app.com/callback', - 'cert_path' => __DIR__ . '/certs/client.cer', - 'key_path' => __DIR__ . '/certs/private.key', - + 'redirect_uri' => 'https://your-app.com/callback', + 'cert_path' => __DIR__ . '/certs/client.cer', + 'key_path' => __DIR__ . '/certs/private.key', + // BUSINESS DATA - 'account_num' => '40702810...', // Nominal Account Number - 'refresh_token' => 'saved_refresh_token_db' // Your stored token + 'account_num' => '40702810...', // Nominal Account Number + 'refresh_token' => 'saved_refresh_token_db', // Your stored token ]; try { @@ -48,7 +48,7 @@ try { // 2. Refresh Token (Get valid Access Token for this session) echo "Refreshing session...\n"; $authenticator = $baas->refreshAccessToken($config['refresh_token']); - + // Apply authentication to the connector $baas->authenticate($authenticator); @@ -60,15 +60,15 @@ try { ); $response = $baas->send($request); - + // 4. Handle Result $list = $response->dto(); - echo "Found " . count($list->beneficiaries) . " beneficiaries.\n"; - + echo 'Found ' . count($list->beneficiaries) . " beneficiaries.\n"; + foreach ($list->beneficiaries as $b) { echo "- {$b->name} (ID: {$b->beneficiaryId})\n"; } } catch (Exception $e) { - echo "Error: " . $e->getMessage() . "\n"; + echo 'Error: ' . $e->getMessage() . "\n"; } diff --git a/examples/16_automated_startup.php b/examples/16_automated_startup.php index 9eac1e5..fa92993 100644 --- a/examples/16_automated_startup.php +++ b/examples/16_automated_startup.php @@ -5,18 +5,18 @@ declare(strict_types=1); require_once __DIR__ . '/vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; +use Apoloz\AlfaBank\Enums\Environment; use Apoloz\AlfaBank\Requests\Auth\RefreshClientSecretRequest; use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\GetBeneficiariesRequest; -use Apoloz\AlfaBank\Enums\Environment; /** * FULLY AUTOMATED WORKFLOW - * - * Scenario: You don't want to store `client_secret` persistently. + * + * Scenario: You don't want to store `client_secret` persistently. * Instead, you use your Certificates to fetch a fresh secret on startup (or when needed), * and then immediately use it to refresh your OAuth tokens. - * - * CAUTION: Requesting a new secret invalidates the old one. + * + * CAUTION: Requesting a new secret invalidates the old one. * If you have multiple app instances, implement a shared cache (Redis/DB) for the secret! */ @@ -25,8 +25,8 @@ use Apoloz\AlfaBank\Enums\Environment; $clientId = getenv('ALFA_BAAS_CLIENT_ID'); $redirectUri = 'https://your-app.com/callback'; $certPath = __DIR__ . '/certs/client.cer'; -$keyPath = __DIR__ . '/certs/private.key'; -$accNum = '40702810...'; +$keyPath = __DIR__ . '/certs/private.key'; +$accNum = '40702810...'; // This assumes you have already passed the browser flow once and saved the refresh token. $savedRefreshToken = 'your_saved_refresh_token_from_db'; @@ -38,20 +38,20 @@ try { // 2. FETCH CLIENT SECRET DYNAMICALLY // We prove our identity via mTLS certificates. echo "1. Requesting dynamic client_secret via API...\n"; - + // In a real app: CHECK CACHE FIRST! // $cachedSecret = Cache::get('alfa_client_secret'); // if ($cachedSecret) { $tempSecret = $cachedSecret; } else { ... } - + $secretResponse = $baas->send(new RefreshClientSecretRequest($clientId)); $tempSecret = $secretResponse->dto()->clientSecret; - - echo " Secret acquired: " . substr($tempSecret, 0, 5) . "...\n"; + + echo ' Secret acquired: ' . substr($tempSecret, 0, 5) . "...\n"; // 3. AUTHENTICATE OAUTH2 // Now we use the fresh secret to get an access token. echo "2. Refreshing OAuth2 session...\n"; - + // Re-initialize connector with the new secret $baasReady = AlfaBank::baas( certificatePath: $certPath, @@ -65,9 +65,9 @@ try { // Refresh token using native method $authenticator = $baasReady->refreshAccessToken($savedRefreshToken); $baasReady->authenticate($authenticator); - - echo " Session active. Access Token expires at " . $authenticator->getExpiresAt()->format('H:i:s') . "\n"; - + + echo ' Session active. Access Token expires at ' . $authenticator->getExpiresAt()->format('H:i:s') . "\n"; + // Update DB if refresh token rotated if ($authenticator->getRefreshToken()) { // saveNewRefreshToken($authenticator->getRefreshToken()); @@ -76,14 +76,14 @@ try { // 4. BUSINESS LOGIC echo "3. Fetching beneficiaries...\n"; - + $response = $baasReady->send(new GetBeneficiariesRequest($accNum, 'FL_RESIDENT')); - - echo " Success! Found " . count($response->dto()->beneficiaries) . " records.\n"; + + echo ' Success! Found ' . count($response->dto()->beneficiaries) . " records.\n"; } catch (Exception $e) { - echo "CRITICAL ERROR: " . $e->getMessage() . "\n"; + echo 'CRITICAL ERROR: ' . $e->getMessage() . "\n"; if (method_exists($e, 'getResponse')) { - echo "Body: " . $e->getResponse()->body() . "\n"; + echo 'Body: ' . $e->getResponse()->body() . "\n"; } } diff --git a/examples/17_laravel_tinker_scoring_creation.php b/examples/17_laravel_tinker_scoring_creation.php index 4076f4b..719166c 100644 --- a/examples/17_laravel_tinker_scoring_creation.php +++ b/examples/17_laravel_tinker_scoring_creation.php @@ -2,21 +2,21 @@ /** * LARAVEL TINKER WORKFLOW: Scoring -> Creation -> Signing - * + * * This script is designed to be copy-pasted directly into `php artisan tinker`. * It demonstrates the new simplified DX with automatic signing. - * + * * Prerequisites: * 1. .env is configured (ALFA_BAAS_CLIENT_ID, ALFA_BAAS_CERT_PATH, etc.) * 2. Run: php artisan tinker */ use Apoloz\AlfaBank\Core\AlfaBankConnector; -use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\ScoreBeneficiaryRequest; +use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\AddressData; +use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData; use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\ScoreBeneficiaryRequestData; use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\CreateBeneficiaryRequest; -use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData; -use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\AddressData; +use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\ScoreBeneficiaryRequest; // 1. Get Configured Connector // Laravel automatically injects config from config/alfa-bank.php @@ -40,17 +40,19 @@ $scoreData = new ScoreBeneficiaryRequestData( try { $scoreResponse = $baas->send(new ScoreBeneficiaryRequest($scoreData)); $scoreResult = $scoreResponse->dto(); // ScoreBeneficiaryResponseData - - echo "Scoring Result: " . $scoreResult->result . "\n"; - echo "Description: " . $scoreResult->description . "\n"; + + echo 'Scoring Result: ' . $scoreResult->result . "\n"; + echo 'Description: ' . $scoreResult->description . "\n"; if ($scoreResult->result !== 'SUCCESS') { echo "Stopping: Scoring failed.\n"; + return; } } catch (\Exception $e) { - echo "Scoring Error: " . $e->getMessage() . "\n"; + echo 'Scoring Error: ' . $e->getMessage() . "\n"; + return; } @@ -69,7 +71,7 @@ $createData = new CreateBeneficiaryRequestData( type: 'REGISTRATION_ADDRESS', address: '123456, г. Москва, ул. Тверская, д. 1', country: 'RU' - ) + ), ]) ); @@ -83,14 +85,13 @@ try { $beneficiary = $createResponse->dto(); // CreateBeneficiaryResponseData echo "SUCCESS! Beneficiary Created.\n"; - echo "ID: " . $beneficiary->id . "\n"; - echo "Status: " . $beneficiary->status . "\n"; - echo "Request ID: " . $beneficiary->requestId . "\n"; + echo 'ID: ' . $beneficiary->id . "\n"; + echo 'Status: ' . $beneficiary->status . "\n"; + echo 'Request ID: ' . $beneficiary->requestId . "\n"; } catch (\Exception $e) { - echo "Creation Error: " . $e->getMessage() . "\n"; + echo 'Creation Error: ' . $e->getMessage() . "\n"; if (method_exists($e, 'getResponse')) { - echo "Response Body: " . $e->getResponse()->body() . "\n"; + echo 'Response Body: ' . $e->getResponse()->body() . "\n"; } } - diff --git a/examples/19_laravel_tinker_card_registration_payout.php b/examples/19_laravel_tinker_card_registration_payout.php index a3db06f..c7dcaa4 100644 --- a/examples/19_laravel_tinker_card_registration_payout.php +++ b/examples/19_laravel_tinker_card_registration_payout.php @@ -2,30 +2,30 @@ /** * LARAVEL TINKER WORKFLOW: Secure Card Registration -> Payout by ID - * - * Scenario: + * + * Scenario: * 1. User enters Card Number (PAN). * 2. You encrypt PAN and register it as a "Requisite" in Alfa Bank. * 3. You save only the `requisiteId` in your database. * 4. Later, you pay out to this user using only the ID (Zero PAN storage). - * + * * Usage: Copy-paste into `php artisan tinker`. */ use Apoloz\AlfaBank\Core\AlfaBankConnector; -use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\Requisites\CreateRequisiteRequest; -use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites\CreateRequisiteRequestData; -use Apoloz\AlfaBank\Requests\NominalAccounts\Payouts\PayoffRequest; -use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\PayoffRequestData; use Apoloz\AlfaBank\Data\Common\RecipientData; +use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites\CreateRequisiteRequestData; +use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\PayoffRequestData; use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\PayoutRequisiteData; +use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\Requisites\CreateRequisiteRequest; +use Apoloz\AlfaBank\Requests\NominalAccounts\Payouts\PayoffRequest; use Apoloz\AlfaBank\Services\PhpseclibCardEncryptor; // --- CONFIGURATION --- $nominalAccount = '40702810...'; -$beneficiaryId = 'BEN-123...'; -$rawPan = '4276000000001234'; // Вводится пользователем (не сохранять в БД!) -$cardPubKeyPath = storage_path('certs/alfa_card_enc_key.pub'); +$beneficiaryId = 'BEN-123...'; +$rawPan = '4276000000001234'; // Вводится пользователем (не сохранять в БД!) +$cardPubKeyPath = storage_path('certs/alfa_card_enc_key.pub'); // 1. Setup $baas = app(AlfaBankConnector::class); @@ -34,8 +34,8 @@ $baas->login(); // ========================================== // STEP 1: SECURE REGISTRATION (Tokenization) // ========================================== -echo "--- Step 1: Registering Card Requisite --- -"; +echo '--- Step 1: Registering Card Requisite --- +'; // A. Encrypt PAN for transport $encryptor = new PhpseclibCardEncryptor(file_get_contents($cardPubKeyPath)); @@ -55,20 +55,20 @@ try { $reqResponse = $baas->send(new CreateRequisiteRequest($reqData)); $requisiteId = $reqResponse->dto()->id; // E.g. "REQ-998877" - echo "SUCCESS! Card Registered. -"; + echo 'SUCCESS! Card Registered. +'; echo "Requisite ID: $requisiteId (SAVE THIS TO DATABASE) "; - echo "Mask: " . substr($rawPan, 0, 6) . "******" . substr($rawPan, -4) . " -"; + echo 'Mask: ' . substr($rawPan, 0, 6) . '******' . substr($rawPan, -4) . ' +'; } catch (\Exception $e) { - echo "Registration Failed: " . $e->getMessage() . " -"; + echo 'Registration Failed: ' . $e->getMessage() . ' +'; + return; } - // ========================================== // STEP 2: PAYOUT (Using Requisite ID) // ========================================== @@ -82,11 +82,11 @@ $payoutData = new PayoffRequestData( recipient: new RecipientData($beneficiaryId), amount: '100.00', purpose: 'Выплата вознаграждения', - + // Instead of PAN, we provide the Requisite ID payoutRequisite: new PayoutRequisiteData( type: 'CARD', - requisiteId: $requisiteId + requisiteId: $requisiteId ) ); @@ -96,12 +96,12 @@ try { $payResponse = $baas->send(new PayoffRequest($payoutData)); $result = $payResponse->dto(); - echo "Payout Sent! -"; - echo "ID: " . ($result->id ?? 'N/A') . " -"; + echo 'Payout Sent! +'; + echo 'ID: ' . ($result->id ?? 'N/A') . ' +'; } catch (\Exception $e) { - echo "Payout Failed: " . $e->getMessage() . " -"; + echo 'Payout Failed: ' . $e->getMessage() . ' +'; } diff --git a/examples/20_sbp_qr_to_nominal_account.php b/examples/20_sbp_qr_to_nominal_account.php index 34d0922..09fa8d9 100644 --- a/examples/20_sbp_qr_to_nominal_account.php +++ b/examples/20_sbp_qr_to_nominal_account.php @@ -4,7 +4,7 @@ declare(strict_types=1); /** * Пример: SBP QR → Номинальный счёт → Идентификация → Бенефициар - * + * * Сценарий: * 1. Генерируем SBP QR код для пополнения номинального счёта * 2. Клиент оплачивает через QR (переводит деньги на номинальный счёт) @@ -16,17 +16,17 @@ declare(strict_types=1); require_once __DIR__ . '/../vendor/autoload.php'; use Apoloz\AlfaBank\AlfaBank; -use Apoloz\AlfaBank\Enums\Environment; -use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData; -use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest; use Apoloz\AlfaBank\Core\AlfaConfig; -use Apoloz\AlfaBank\Sbp\SbpConnector; +use Apoloz\AlfaBank\Data\NominalAccounts\Identification\AmountDistributionData; +use Apoloz\AlfaBank\Data\NominalAccounts\Identification\IdentifyRequestData; +use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData; +use Apoloz\AlfaBank\Enums\Environment; +use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\GetIdentifyStatusRequest; use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\GetUnidentifiedTransactionsRequest; use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\IdentifyTransactionRequest; -use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\GetIdentifyStatusRequest; -use Apoloz\AlfaBank\Data\NominalAccounts\Identification\IdentifyRequestData; -use Apoloz\AlfaBank\Data\NominalAccounts\Identification\AmountDistributionData; -use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData; +use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData; +use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest; +use Apoloz\AlfaBank\Sbp\SbpConnector; use Spatie\LaravelData\DataCollection; echo "=== SBP QR → Номинальный счёт → Идентификация ===\n\n"; @@ -73,12 +73,12 @@ try { caBundlePath: $sbpCaBundle, signingPrivateKeyPath: $sbpSigningKey // 4096-bit ключ для подписи ); - + $sbp = new SbpConnector($sbpConfig, $sbpKeyAlias); // Создаём динамический QR код с уникальным OrderNumber для идентификации $orderNumber = 'ORDER-' . uniqid(); - + $qrPayload = new QrCodeRequestData( termNo: $sbpTermNo, qrcType: '02', // Dynamic QR @@ -109,7 +109,7 @@ try { echo "\n💡 Клиент должен отсканировать QR и оплатить {$qrData->payload}\n\n"; // Сохраняем QR изображение для показа клиенту - if (!empty($qrData->image)) { + if (! empty($qrData->image)) { $qrImagePath = __DIR__ . '/qr_payment.png'; file_put_contents($qrImagePath, base64_decode($qrData->image)); echo " 📁 QR изображение сохранено: $qrImagePath\n\n"; @@ -148,7 +148,7 @@ try { $unidentifiedResponse = $baas->send($unidentifiedRequest); $unidentifiedCollection = $unidentifiedResponse->dto(); - echo "Найдено неидентифицированных пополнений: " . count($unidentifiedCollection->items) . "\n\n"; + echo 'Найдено неидентифицированных пополнений: ' . count($unidentifiedCollection->items) . "\n\n"; if (count($unidentifiedCollection->items) === 0) { echo "⚠️ Нет неидентифицированных пополнений. Возможные причины:\n"; @@ -175,7 +175,7 @@ try { } if ($targetTransaction === null) { - throw new \RuntimeException("Не найдена подходящая транзакция для идентификации"); + throw new \RuntimeException('Не найдена подходящая транзакция для идентификации'); } echo "✅ Выбрана транзакция для идентификации: {$targetTransaction->id}\n"; @@ -194,7 +194,7 @@ try { new AmountDistributionData( beneficiaryId: $beneficiaryId, amount: $targetTransaction->amount - ) + ), ], AmountDistributionData::class); // Подготавливаем данные для идентификации @@ -207,7 +207,7 @@ try { new DigestSignatureData( base64Encoded: 'base64-encoded-signature-here', // Реальная подпись signatureType: 'rsa' - ) + ), ], DigestSignatureData::class) ); diff --git a/examples/21_laravel_tinker_sbp_identification.php b/examples/21_laravel_tinker_sbp_identification.php index f433603..f9f0a34 100644 --- a/examples/21_laravel_tinker_sbp_identification.php +++ b/examples/21_laravel_tinker_sbp_identification.php @@ -4,7 +4,7 @@ declare(strict_types=1); /** * Laravel Tinker: SBP QR → Номинальный счёт → Идентификация - * + * * Использование: * docker compose exec php-fpm php artisan tinker * >>> include 'examples/21_laravel_tinker_sbp_identification.php' @@ -12,16 +12,15 @@ declare(strict_types=1); use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; +use Apoloz\AlfaBank\Data\NominalAccounts\Identification\AmountDistributionData; +use Apoloz\AlfaBank\Data\NominalAccounts\Identification\IdentifyRequestData; use Apoloz\AlfaBank\Enums\Environment; -use Apoloz\AlfaBank\Sbp\SbpConnector; -use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData; -use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest; +use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\GetIdentifyStatusRequest; use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\GetUnidentifiedTransactionsRequest; use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\IdentifyTransactionRequest; -use Apoloz\AlfaBank\Requests\NominalAccounts\Identification\GetIdentifyStatusRequest; -use Apoloz\AlfaBank\Data\NominalAccounts\Identification\IdentifyRequestData; -use Apoloz\AlfaBank\Data\NominalAccounts\Identification\AmountDistributionData; -use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData; +use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData; +use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest; +use Apoloz\AlfaBank\Sbp\SbpConnector; use Spatie\LaravelData\DataCollection; echo "=== SBP QR → Номинальный счёт → Идентификация (Tinker) ===\n\n"; @@ -35,7 +34,7 @@ $beneficiaryId = 'your-beneficiary-id-here'; // ID бенефициара (по $amount = '15000'; // 150.00 RUB в копейках echo "Номинальный счёт: $nominalAccountNumber\n"; -echo "Сумма: " . number_format($amount / 100, 2) . " RUB\n\n"; +echo 'Сумма: ' . number_format($amount / 100, 2) . " RUB\n\n"; // ============================================================================= // ШАГ 1: Генерация SBP QR @@ -52,11 +51,11 @@ try { caBundlePath: config('alfa-bank.sbp.ca_bundle'), signingPrivateKeyPath: config('alfa-bank.sbp.signing_private_key_path') ); - + $sbp = new SbpConnector($sbpConfig, config('alfa-bank.sbp.key_name_alias')); $orderNumber = 'ORDER-' . uniqid(); - + $qrResponse = $sbp->send(new GetQrCodeRequest( new QrCodeRequestData( termNo: config('alfa-bank.sbp.terminal_no'), @@ -71,9 +70,10 @@ try { )); $qrData = $qrResponse->dto(); - + if ($qrData->ErrorCode !== 0) { echo "❌ Ошибка генерации QR: {$qrData->message}\n"; + return; } @@ -90,17 +90,18 @@ try { echo "(После оплаты клиентом через SBP)\n\n"; $baas = app(AlfaBankConnector::class); - + // Получаем список $unidentifiedResponse = $baas->send( new GetUnidentifiedTransactionsRequest($nominalAccountNumber, limit: 5) ); - + $transactions = $unidentifiedResponse->dto()->items; - echo "Найдено транзакций: " . count($transactions) . "\n\n"; + echo 'Найдено транзакций: ' . count($transactions) . "\n\n"; if (count($transactions) === 0) { echo "⚠️ Нет неидентифицированных пополнений\n"; + return; } @@ -121,11 +122,12 @@ try { // ============================================================================= echo "=== ШАГ 3: Идентификация платежа ===\n"; - + if (empty($beneficiaryId) || $beneficiaryId === 'your-beneficiary-id-here') { echo "⚠️ Укажите правильный beneficiaryId!\n"; echo " Получите список бенефициаров через:\n"; echo " >>> \$baas->send(new GetBeneficiariesRequest())->dto()\n"; + return; } @@ -136,7 +138,7 @@ try { new AmountDistributionData( beneficiaryId: $beneficiaryId, amount: $transaction->amount - ) + ), ], AmountDistributionData::class) ); @@ -158,7 +160,7 @@ try { $statusResponse = $baas->send( new GetIdentifyStatusRequest($result->identifyId) ); - + $status = $statusResponse->dto(); echo "Текущий статус: {$status->status}\n\n"; @@ -171,7 +173,7 @@ try { } catch (\Exception $e) { echo "\n❌ Ошибка: {$e->getMessage()}\n"; - echo "Класс: " . get_class($e) . "\n"; + echo 'Класс: ' . get_class($e) . "\n"; } echo "\n=== Готово ===\n"; diff --git a/src/AlfaBank.php b/src/AlfaBank.php index f45116d..b0ce6cd 100644 --- a/src/AlfaBank.php +++ b/src/AlfaBank.php @@ -9,9 +9,9 @@ namespace Apoloz\AlfaBank; use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; use Apoloz\AlfaBank\Enums\Environment; -use Apoloz\AlfaBank\Services\OpenSslCmsSigner; -use Apoloz\AlfaBank\Sbp\SbpConnector; use Apoloz\AlfaBank\Requests\Accounts\GetAccountsRequest; +use Apoloz\AlfaBank\Sbp\SbpConnector; +use Apoloz\AlfaBank\Services\OpenSslCmsSigner; class AlfaBank { @@ -29,7 +29,8 @@ class AlfaBank ): bool { $baas = self::baas($certificatePath, $privateKeyPath, $environment, $caBundlePath); $baas->login($clientId, $clientSecret); - $baas->send(new GetAccountsRequest()); + $baas->send(new GetAccountsRequest); + return true; } @@ -76,8 +77,8 @@ class AlfaBank ?string $signingCertificatePath = null, ?string $signingPrivateKeyPath = null ): SbpConnector { - $baseUrl = $environment === Environment::PRODUCTION - ? Environment::SBP_PRODUCTION->value + $baseUrl = $environment === Environment::PRODUCTION + ? Environment::SBP_PRODUCTION->value : Environment::SBP_SANDBOX->value; $config = new AlfaConfig( @@ -92,4 +93,4 @@ class AlfaBank return new SbpConnector($config, $keyNameAlias); } // -} \ No newline at end of file +} diff --git a/src/Core/AlfaBankConnector.php b/src/Core/AlfaBankConnector.php index bd544bf..0f4aa87 100644 --- a/src/Core/AlfaBankConnector.php +++ b/src/Core/AlfaBankConnector.php @@ -7,6 +7,7 @@ namespace Apoloz\AlfaBank\Core; //
// use Apoloz\AlfaBank\Contracts\SignerInterface; +use Apoloz\AlfaBank\Enums\Environment; use Apoloz\AlfaBank\Http\Middleware\RequestIdMiddleware; use Apoloz\AlfaBank\Http\Pagination\AlfaOffsetPaginator; use Apoloz\AlfaBank\Traits\HasAlfaErrorHandling; @@ -15,19 +16,18 @@ use Saloon\Http\Connector; use Saloon\Http\Request; use Saloon\PaginationPlugin\Contracts\HasPagination; use Saloon\PaginationPlugin\OffsetPaginator; -use Saloon\Traits\Plugins\AlwaysThrowOnErrors; -use Saloon\Traits\RequestProperties\HasTries; -use Saloon\Traits\Plugins\HasTimeout; use Saloon\Traits\OAuth2\AuthorizationCodeGrant; -use Apoloz\AlfaBank\Enums\Environment; +use Saloon\Traits\Plugins\AlwaysThrowOnErrors; +use Saloon\Traits\Plugins\HasTimeout; +use Saloon\Traits\RequestProperties\HasTries; class AlfaBankConnector extends Connector implements HasPagination { + use AlwaysThrowOnErrors; + use AuthorizationCodeGrant; + use HasAlfaErrorHandling; use HasTimeout; use HasTries; - use AlwaysThrowOnErrors; - use HasAlfaErrorHandling; - use AuthorizationCodeGrant; public function __construct( protected AlfaConfig $alfaConfig, @@ -42,6 +42,79 @@ class AlfaBankConnector extends Connector implements HasPagination return $this->alfaConfig->baseUrl; } + public function boot(\Saloon\Http\PendingRequest $pendingRequest): void + { + // + } + + public function paginate(Request $request): OffsetPaginator + { + return new AlfaOffsetPaginator($this, $request); + } + + // login() kept for ClientCredentials compatibility (legacy/simple flow) + public function login(?string $clientId = null, ?string $clientSecret = null, array $scopes = []): static + { + $oauthConfig = $this->oauthConfig(); + + // Allow overriding credentials via method arguments + if ($clientId) { + $oauthConfig->setClientId($clientId); + } + if ($clientSecret) { + $oauthConfig->setClientSecret($clientSecret); + } + + if (empty($oauthConfig->getClientId()) || empty($oauthConfig->getClientSecret())) { + throw new \RuntimeException('Client ID/Secret not configured.'); + } + + $request = new \Saloon\Http\OAuth2\GetClientCredentialsTokenRequest($oauthConfig, $scopes); + + $response = $this->send($request); + + // Use the trait's helper to parse the token + $authenticator = $this->createOAuthAuthenticatorFromResponse($response); + + $this->authenticate($authenticator); + + return $this; + } + //
+ // + + //
+ // + public function getSigner(): SignerInterface + { + if (! $this->signer) { + throw new \RuntimeException('No signer configured for this connector.'); + } + + return $this->signer; + } + //
+ + //
+ // + public function withLogging(\Psr\Log\LoggerInterface $logger): static + { + $this->middleware()->onRequest(new \Apoloz\AlfaBank\Http\Middleware\LoggingRequestMiddleware($logger)); + $this->middleware()->onResponse(new \Apoloz\AlfaBank\Http\Middleware\LoggingResponseMiddleware($logger)); + + return $this; + } + + /** + * Enable automated JWS response verification and decoding. + */ + public function withJwsVerification(string $publicKeyPem): static + { + $this->middleware()->onResponse(new \Apoloz\AlfaBank\Http\Middleware\VerifyJwsResponseMiddleware($publicKeyPem)); + + return $this; + } + protected function defaultOauthConfig(): OAuthConfig { $idUrl = $this->alfaConfig->baseUrl === Environment::PRODUCTION->value @@ -83,80 +156,8 @@ class AlfaBankConnector extends Connector implements HasPagination protected function defaultMiddleware(): array { return [ - new RequestIdMiddleware(), + new RequestIdMiddleware, ]; } - - public function boot(\Saloon\Http\PendingRequest $pendingRequest): void - { - // - } - - public function paginate(Request $request): OffsetPaginator - { - return new AlfaOffsetPaginator($this, $request); - } - - // login() kept for ClientCredentials compatibility (legacy/simple flow) - public function login(?string $clientId = null, ?string $clientSecret = null, array $scopes = []): static - { - $oauthConfig = $this->oauthConfig(); - - // Allow overriding credentials via method arguments - if ($clientId) { - $oauthConfig->setClientId($clientId); - } - if ($clientSecret) { - $oauthConfig->setClientSecret($clientSecret); - } - - if (empty($oauthConfig->getClientId()) || empty($oauthConfig->getClientSecret())) { - throw new \RuntimeException("Client ID/Secret not configured."); - } - - $request = new \Saloon\Http\OAuth2\GetClientCredentialsTokenRequest($oauthConfig, $scopes); - - $response = $this->send($request); - - // Use the trait's helper to parse the token - $authenticator = $this->createOAuthAuthenticatorFromResponse($response); - - $this->authenticate($authenticator); - - return $this; - } //
- // - - //
- // - public function getSigner(): SignerInterface - { - if (!$this->signer) { - throw new \RuntimeException("No signer configured for this connector."); - } - return $this->signer; - } - //
- - //
- // - public function withLogging(\Psr\Log\LoggerInterface $logger): static - { - $this->middleware()->onRequest(new \Apoloz\AlfaBank\Http\Middleware\LoggingRequestMiddleware($logger)); - $this->middleware()->onResponse(new \Apoloz\AlfaBank\Http\Middleware\LoggingResponseMiddleware($logger)); - - return $this; - } - - /** - * Enable automated JWS response verification and decoding. - */ - public function withJwsVerification(string $publicKeyPem): static - { - $this->middleware()->onResponse(new \Apoloz\AlfaBank\Http\Middleware\VerifyJwsResponseMiddleware($publicKeyPem)); - - return $this; - } - //
-} \ No newline at end of file +} diff --git a/src/Core/AlfaConfig.php b/src/Core/AlfaConfig.php index 3c172c2..c151f02 100644 --- a/src/Core/AlfaConfig.php +++ b/src/Core/AlfaConfig.php @@ -41,17 +41,17 @@ readonly class AlfaConfig public ?string $signingPrivateKeyPath = null, ) { // - if (!file_exists($this->certificatePath)) { + if (! file_exists($this->certificatePath)) { throw new \InvalidArgumentException("Certificate not found: {$this->certificatePath}"); } - if (!file_exists($this->privateKeyPath)) { + if (! file_exists($this->privateKeyPath)) { throw new \InvalidArgumentException("Private key not found: {$this->privateKeyPath}"); } - if ($this->signingCertificatePath && !file_exists($this->signingCertificatePath)) { - throw new \InvalidArgumentException("Signing certificate not found: {$this->signingCertificatePath}"); + if ($this->signingCertificatePath && ! file_exists($this->signingCertificatePath)) { + throw new \InvalidArgumentException("Signing certificate not found: {$this->signingCertificatePath}"); } - if ($this->signingPrivateKeyPath && !file_exists($this->signingPrivateKeyPath)) { - throw new \InvalidArgumentException("Signing private key not found: {$this->signingPrivateKeyPath}"); + if ($this->signingPrivateKeyPath && ! file_exists($this->signingPrivateKeyPath)) { + throw new \InvalidArgumentException("Signing private key not found: {$this->signingPrivateKeyPath}"); } } // diff --git a/src/Data/Accounts/AccountData.php b/src/Data/Accounts/AccountData.php index 1a83a70..6ef1cc3 100644 --- a/src/Data/Accounts/AccountData.php +++ b/src/Data/Accounts/AccountData.php @@ -13,6 +13,6 @@ class AccountData extends Data public string $openDate, public string $type, public ?string $mnemonic = null, - public ?array $balance = null, + public ?array $balance = null, ) {} } diff --git a/src/Data/Auth/TokenData.php b/src/Data/Auth/TokenData.php index 928a82a..5d056e3 100644 --- a/src/Data/Auth/TokenData.php +++ b/src/Data/Auth/TokenData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\Auth; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/Auth/UserInfo/ClientConsentCollectionData.php b/src/Data/Auth/UserInfo/ClientConsentCollectionData.php index 50d0c17..486be7b 100644 --- a/src/Data/Auth/UserInfo/ClientConsentCollectionData.php +++ b/src/Data/Auth/UserInfo/ClientConsentCollectionData.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\PaginationData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/Auth/UserInfo/ClientConsentData.php b/src/Data/Auth/UserInfo/ClientConsentData.php index 079eca6..d90587d 100644 --- a/src/Data/Auth/UserInfo/ClientConsentData.php +++ b/src/Data/Auth/UserInfo/ClientConsentData.php @@ -14,9 +14,10 @@ namespace Apoloz\AlfaBank\Data\Auth\UserInfo; //
// use Apoloz\AlfaBank\Data\PaginationData; // This import is likely extraneous for a single DTO, but kept for context consistency. -use Spatie\LaravelData\Attributes\DataCollectionOf; // This is also likely extraneous for a single DTO. +// This is also likely extraneous for a single DTO. use Spatie\LaravelData\Data; -use Spatie\LaravelData\DataCollection; // This is also likely extraneous for a single DTO. + +// This is also likely extraneous for a single DTO. //
//
diff --git a/src/Data/Auth/UserInfo/UserInfoData.php b/src/Data/Auth/UserInfo/UserInfoData.php index a98f577..c9b5982 100644 --- a/src/Data/Auth/UserInfo/UserInfoData.php +++ b/src/Data/Auth/UserInfo/UserInfoData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\Auth\UserInfo; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/B2C/B2CPaymentResponseData.php b/src/Data/B2C/B2CPaymentResponseData.php index c2d24c2..8813cee 100644 --- a/src/Data/B2C/B2CPaymentResponseData.php +++ b/src/Data/B2C/B2CPaymentResponseData.php @@ -4,9 +4,7 @@ declare(strict_types=1); namespace Apoloz\AlfaBank\Data\B2C; -use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; -use Spatie\LaravelData\DataCollection; class B2CPaymentResponseData extends Data { diff --git a/src/Data/Crypto/CertificateData.php b/src/Data/Crypto/CertificateData.php index df42a0c..f2e3f90 100644 --- a/src/Data/Crypto/CertificateData.php +++ b/src/Data/Crypto/CertificateData.php @@ -14,4 +14,4 @@ class CertificateData extends Data public string $status, public ?string $thumbprint = null, ) {} -} \ No newline at end of file +} diff --git a/src/Data/FileExchange/DownloadFileResponseData.php b/src/Data/FileExchange/DownloadFileResponseData.php index 4f23a5d..05ff7ec 100644 --- a/src/Data/FileExchange/DownloadFileResponseData.php +++ b/src/Data/FileExchange/DownloadFileResponseData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Data\FileExchange; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/FileExchange/FileLinkData.php b/src/Data/FileExchange/FileLinkData.php index aa1bb14..ca34e34 100644 --- a/src/Data/FileExchange/FileLinkData.php +++ b/src/Data/FileExchange/FileLinkData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\FileExchange; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/FileExchange/UploadFileResponseData.php b/src/Data/FileExchange/UploadFileResponseData.php index 8f2e05f..f0cb8e4 100644 --- a/src/Data/FileExchange/UploadFileResponseData.php +++ b/src/Data/FileExchange/UploadFileResponseData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Data\FileExchange; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/AddressData.php b/src/Data/NominalAccounts/Beneficiaries/AddressData.php index c625150..d76f162 100644 --- a/src/Data/NominalAccounts/Beneficiaries/AddressData.php +++ b/src/Data/NominalAccounts/Beneficiaries/AddressData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/BeneficiaryBalanceData.php b/src/Data/NominalAccounts/Beneficiaries/BeneficiaryBalanceData.php index 48d966c..a7319f4 100644 --- a/src/Data/NominalAccounts/Beneficiaries/BeneficiaryBalanceData.php +++ b/src/Data/NominalAccounts/Beneficiaries/BeneficiaryBalanceData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionCollectionData.php b/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionCollectionData.php index ad614e4..15cad28 100644 --- a/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionCollectionData.php +++ b/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionCollectionData.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\PaginationData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionData.php b/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionData.php index 47c335d..7c10d6d 100644 --- a/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionData.php +++ b/src/Data/NominalAccounts/Beneficiaries/BeneficiaryTransactionData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryRequestData.php b/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryRequestData.php index f44c8ef..3a40179 100644 --- a/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryRequestData.php +++ b/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryRequestData.php @@ -20,6 +20,7 @@ use Spatie\LaravelData\Attributes\Validation\Email; use Spatie\LaravelData\Attributes\Validation\Numeric; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryResponseData.php b/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryResponseData.php index 60caa2e..a739425 100644 --- a/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryResponseData.php +++ b/src/Data/NominalAccounts/Beneficiaries/CreateBeneficiaryResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/DocumentData.php b/src/Data/NominalAccounts/Beneficiaries/DocumentData.php index e2c6910..c8d73e7 100644 --- a/src/Data/NominalAccounts/Beneficiaries/DocumentData.php +++ b/src/Data/NominalAccounts/Beneficiaries/DocumentData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/PersonalInformationData.php b/src/Data/NominalAccounts/Beneficiaries/PersonalInformationData.php index e6b9945..3eb818a 100644 --- a/src/Data/NominalAccounts/Beneficiaries/PersonalInformationData.php +++ b/src/Data/NominalAccounts/Beneficiaries/PersonalInformationData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/Requisites/CreateRequisiteRequestData.php b/src/Data/NominalAccounts/Beneficiaries/Requisites/CreateRequisiteRequestData.php index 31a245e..8d57b54 100644 --- a/src/Data/NominalAccounts/Beneficiaries/Requisites/CreateRequisiteRequestData.php +++ b/src/Data/NominalAccounts/Beneficiaries/Requisites/CreateRequisiteRequestData.php @@ -18,6 +18,7 @@ use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/Requisites/RequisiteData.php b/src/Data/NominalAccounts/Beneficiaries/Requisites/RequisiteData.php index a906ed1..82093eb 100644 --- a/src/Data/NominalAccounts/Beneficiaries/Requisites/RequisiteData.php +++ b/src/Data/NominalAccounts/Beneficiaries/Requisites/RequisiteData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequestData.php b/src/Data/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequestData.php index 45221b6..d7dde98 100644 --- a/src/Data/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequestData.php +++ b/src/Data/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequestData.php @@ -16,9 +16,9 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\Requisites; use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData; use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; -use Spatie\LaravelData\Attributes\Validation\Numeric; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequestData.php b/src/Data/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequestData.php index b112a86..1d67330 100644 --- a/src/Data/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequestData.php +++ b/src/Data/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequestData.php @@ -20,6 +20,7 @@ use Spatie\LaravelData\Attributes\Validation\Email; use Spatie\LaravelData\Attributes\Validation\Numeric; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
@@ -39,3 +40,23 @@ class UpdateBeneficiaryRequestData extends Data public ?DataCollection $addresses = null, public ?string $accountNumber = null, public ?bool $taxResidentUS = null, + public ?bool $foreignTaxResident = null, + public ?bool $financialActivities = null, + public ?string $name = null, + public ?string $registrationDate = null, + #[Numeric] + public ?string $inn = null, + #[Numeric] + public ?string $kpp = null, + #[Numeric] + public ?string $ogrn = null, + public ?PersonalInformationData $personalInformation = null, + public ?string $phoneNumber = null, + #[Email] + public ?string $email = null, + #[DataCollectionOf(DocumentData::class)] + public ?DataCollection $documents = null, + ) {} + //
+} +//
diff --git a/src/Data/NominalAccounts/Beneficiaries/WalletBalanceData.php b/src/Data/NominalAccounts/Beneficiaries/WalletBalanceData.php index 370c117..891116b 100644 --- a/src/Data/NominalAccounts/Beneficiaries/WalletBalanceData.php +++ b/src/Data/NominalAccounts/Beneficiaries/WalletBalanceData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/BeneficiaryCollectionData.php b/src/Data/NominalAccounts/BeneficiaryCollectionData.php index 4ad42ce..41ec9f3 100644 --- a/src/Data/NominalAccounts/BeneficiaryCollectionData.php +++ b/src/Data/NominalAccounts/BeneficiaryCollectionData.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\PaginationData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/BeneficiaryData.php b/src/Data/NominalAccounts/BeneficiaryData.php index fdd712f..abe9af3 100644 --- a/src/Data/NominalAccounts/BeneficiaryData.php +++ b/src/Data/NominalAccounts/BeneficiaryData.php @@ -16,7 +16,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts; use Apoloz\AlfaBank\Data\PaginationData; // This import might be misleading for a single DTO, but kept for context consistency. use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; -use Spatie\LaravelData\DataCollection; + //
//
@@ -45,4 +45,4 @@ class BeneficiaryData extends Data public ?bool $isVpr = null, ) {} //
-} \ No newline at end of file +} diff --git a/src/Data/NominalAccounts/CounterpartyRequestStatusData.php b/src/Data/NominalAccounts/CounterpartyRequestStatusData.php index 39c48da..81109eb 100644 --- a/src/Data/NominalAccounts/CounterpartyRequestStatusData.php +++ b/src/Data/NominalAccounts/CounterpartyRequestStatusData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Deals/DealCollectionData.php b/src/Data/NominalAccounts/Deals/DealCollectionData.php index 537facc..6b2fdf4 100644 --- a/src/Data/NominalAccounts/Deals/DealCollectionData.php +++ b/src/Data/NominalAccounts/Deals/DealCollectionData.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\PaginationData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Deals/DealData.php b/src/Data/NominalAccounts/Deals/DealData.php index eaf9314..03a2737 100644 --- a/src/Data/NominalAccounts/Deals/DealData.php +++ b/src/Data/NominalAccounts/Deals/DealData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Deals/DealPayoffData.php b/src/Data/NominalAccounts/Deals/DealPayoffData.php index 415c50a..ee3cb83 100644 --- a/src/Data/NominalAccounts/Deals/DealPayoffData.php +++ b/src/Data/NominalAccounts/Deals/DealPayoffData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Deals/DealRequestStatusData.php b/src/Data/NominalAccounts/Deals/DealRequestStatusData.php index 163809b..7ece7bf 100644 --- a/src/Data/NominalAccounts/Deals/DealRequestStatusData.php +++ b/src/Data/NominalAccounts/Deals/DealRequestStatusData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Deals/Steps/ContractorActionRequestData.php b/src/Data/NominalAccounts/Deals/Steps/ContractorActionRequestData.php index 8e0d5c6..7f670ee 100644 --- a/src/Data/NominalAccounts/Deals/Steps/ContractorActionRequestData.php +++ b/src/Data/NominalAccounts/Deals/Steps/ContractorActionRequestData.php @@ -18,6 +18,7 @@ use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Deals/Steps/ContractorAmountData.php b/src/Data/NominalAccounts/Deals/Steps/ContractorAmountData.php index 925777e..3f6b764 100644 --- a/src/Data/NominalAccounts/Deals/Steps/ContractorAmountData.php +++ b/src/Data/NominalAccounts/Deals/Steps/ContractorAmountData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Deals/Steps/StepActionRequestData.php b/src/Data/NominalAccounts/Deals/Steps/StepActionRequestData.php index c887852..72e4623 100644 --- a/src/Data/NominalAccounts/Deals/Steps/StepActionRequestData.php +++ b/src/Data/NominalAccounts/Deals/Steps/StepActionRequestData.php @@ -18,6 +18,7 @@ use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Deals/Steps/StepActionResponseData.php b/src/Data/NominalAccounts/Deals/Steps/StepActionResponseData.php index 9a67f35..716ed04 100644 --- a/src/Data/NominalAccounts/Deals/Steps/StepActionResponseData.php +++ b/src/Data/NominalAccounts/Deals/Steps/StepActionResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Deals/Steps/StepContractorData.php b/src/Data/NominalAccounts/Deals/Steps/StepContractorData.php index fbee068..96de926 100644 --- a/src/Data/NominalAccounts/Deals/Steps/StepContractorData.php +++ b/src/Data/NominalAccounts/Deals/Steps/StepContractorData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Deals/Steps/StepData.php b/src/Data/NominalAccounts/Deals/Steps/StepData.php index d3b58de..4fab78f 100644 --- a/src/Data/NominalAccounts/Deals/Steps/StepData.php +++ b/src/Data/NominalAccounts/Deals/Steps/StepData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Deals/ValidateDealResponseData.php b/src/Data/NominalAccounts/Deals/ValidateDealResponseData.php index 7f0f855..6401a80 100644 --- a/src/Data/NominalAccounts/Deals/ValidateDealResponseData.php +++ b/src/Data/NominalAccounts/Deals/ValidateDealResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Deals; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Identification/AmountDistributionData.php b/src/Data/NominalAccounts/Identification/AmountDistributionData.php index 779e94c..b61ec42 100644 --- a/src/Data/NominalAccounts/Identification/AmountDistributionData.php +++ b/src/Data/NominalAccounts/Identification/AmountDistributionData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Identification; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Identification/IdentifyRequestData.php b/src/Data/NominalAccounts/Identification/IdentifyRequestData.php index 42d4b98..604e10f 100644 --- a/src/Data/NominalAccounts/Identification/IdentifyRequestData.php +++ b/src/Data/NominalAccounts/Identification/IdentifyRequestData.php @@ -18,6 +18,7 @@ use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Identification/IdentifyResponseData.php b/src/Data/NominalAccounts/Identification/IdentifyResponseData.php index ff0ed5e..071f83d 100644 --- a/src/Data/NominalAccounts/Identification/IdentifyResponseData.php +++ b/src/Data/NominalAccounts/Identification/IdentifyResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Identification; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Identification/PayerData.php b/src/Data/NominalAccounts/Identification/PayerData.php index 5b25e6b..0d13d8e 100644 --- a/src/Data/NominalAccounts/Identification/PayerData.php +++ b/src/Data/NominalAccounts/Identification/PayerData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Identification; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionRequestData.php b/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionRequestData.php index e7d45d2..c107b9b 100644 --- a/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionRequestData.php +++ b/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionRequestData.php @@ -18,6 +18,7 @@ use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionResponseData.php b/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionResponseData.php index 1db2e9f..06cdb08 100644 --- a/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionResponseData.php +++ b/src/Data/NominalAccounts/Identification/RefundUnidentifiedTransactionResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Identification; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Identification/UnidentifiedTransactionCollectionData.php b/src/Data/NominalAccounts/Identification/UnidentifiedTransactionCollectionData.php index 3e17b7b..08e58d9 100644 --- a/src/Data/NominalAccounts/Identification/UnidentifiedTransactionCollectionData.php +++ b/src/Data/NominalAccounts/Identification/UnidentifiedTransactionCollectionData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Identification; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Identification/UnidentifiedTransactionData.php b/src/Data/NominalAccounts/Identification/UnidentifiedTransactionData.php index 51552ff..aa556d5 100644 --- a/src/Data/NominalAccounts/Identification/UnidentifiedTransactionData.php +++ b/src/Data/NominalAccounts/Identification/UnidentifiedTransactionData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Identification; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/NominalAccountData.php b/src/Data/NominalAccounts/NominalAccountData.php index fd6f97a..3b8365b 100644 --- a/src/Data/NominalAccounts/NominalAccountData.php +++ b/src/Data/NominalAccounts/NominalAccountData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Payouts/DetailedPayoffData.php b/src/Data/NominalAccounts/Payouts/DetailedPayoffData.php index 9610707..e11d567 100644 --- a/src/Data/NominalAccounts/Payouts/DetailedPayoffData.php +++ b/src/Data/NominalAccounts/Payouts/DetailedPayoffData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Payouts; use Apoloz\AlfaBank\Data\Shared\PayerInfoData; use Apoloz\AlfaBank\Data\Shared\RecipientInfoData; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Payouts/DigestSignatureData.php b/src/Data/NominalAccounts/Payouts/DigestSignatureData.php index 3276e10..397eb32 100644 --- a/src/Data/NominalAccounts/Payouts/DigestSignatureData.php +++ b/src/Data/NominalAccounts/Payouts/DigestSignatureData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Payouts; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Payouts/PayoffRequestData.php b/src/Data/NominalAccounts/Payouts/PayoffRequestData.php index 0951fe5..9ef78e6 100644 --- a/src/Data/NominalAccounts/Payouts/PayoffRequestData.php +++ b/src/Data/NominalAccounts/Payouts/PayoffRequestData.php @@ -21,6 +21,7 @@ use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Attributes\Validation\Numeric; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Payouts/PayoffResponseData.php b/src/Data/NominalAccounts/Payouts/PayoffResponseData.php index fa4e501..d2b7c18 100644 --- a/src/Data/NominalAccounts/Payouts/PayoffResponseData.php +++ b/src/Data/NominalAccounts/Payouts/PayoffResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Payouts; //
// use Spatie\LaravelData\Data; + //
//
@@ -28,4 +29,4 @@ class PayoffResponseData extends Data public ?string $description = null, ) {} //
-} \ No newline at end of file +} diff --git a/src/Data/NominalAccounts/Payouts/PayoutRequisiteData.php b/src/Data/NominalAccounts/Payouts/PayoutRequisiteData.php index 0c65c98..dcb1a44 100644 --- a/src/Data/NominalAccounts/Payouts/PayoutRequisiteData.php +++ b/src/Data/NominalAccounts/Payouts/PayoutRequisiteData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Payouts; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Payouts/RecipientData.php b/src/Data/NominalAccounts/Payouts/RecipientData.php index d36b492..e4aaeee 100644 --- a/src/Data/NominalAccounts/Payouts/RecipientData.php +++ b/src/Data/NominalAccounts/Payouts/RecipientData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Payouts; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/Payouts/TaxRefundRequestData.php b/src/Data/NominalAccounts/Payouts/TaxRefundRequestData.php index 9424743..2a1c540 100644 --- a/src/Data/NominalAccounts/Payouts/TaxRefundRequestData.php +++ b/src/Data/NominalAccounts/Payouts/TaxRefundRequestData.php @@ -14,10 +14,10 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Payouts; //
// use Apoloz\AlfaBank\Traits\SignableData; -use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/Payouts/TaxRefundResponseData.php b/src/Data/NominalAccounts/Payouts/TaxRefundResponseData.php index 18024fb..5bceaf7 100644 --- a/src/Data/NominalAccounts/Payouts/TaxRefundResponseData.php +++ b/src/Data/NominalAccounts/Payouts/TaxRefundResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Payouts; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequestData.php b/src/Data/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequestData.php index ed252ea..34cb37b 100644 --- a/src/Data/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequestData.php +++ b/src/Data/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequestData.php @@ -16,9 +16,9 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\UniversalRecipients; use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData; use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; -use Spatie\LaravelData\Attributes\Validation\Numeric; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientData.php b/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientData.php index c8aec69..0618ffa 100644 --- a/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientData.php +++ b/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\UniversalRecipients; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientResponseData.php b/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientResponseData.php index 0308649..1379d7f 100644 --- a/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientResponseData.php +++ b/src/Data/NominalAccounts/UniversalRecipients/UniversalRecipientResponseData.php @@ -14,7 +14,8 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\UniversalRecipients; //
// use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryResponseData; -use Spatie\LaravelData\Data; // Included for clarity, though inherited from base DTO. + +// Included for clarity, though inherited from base DTO. //
//
diff --git a/src/Data/PaginationData.php b/src/Data/PaginationData.php index 75ff1f8..4b09991 100644 --- a/src/Data/PaginationData.php +++ b/src/Data/PaginationData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/Payments/PaymentData.php b/src/Data/Payments/PaymentData.php index 4c0612a..5d0feb6 100644 --- a/src/Data/Payments/PaymentData.php +++ b/src/Data/Payments/PaymentData.php @@ -17,59 +17,59 @@ class PaymentData extends Data public function __construct( #[MapOutputName('Amount')] public float $amount, - + #[MapOutputName('DocDate')] public string $date, - + #[MapOutputName('DocNo')] public string $externalId, - + #[MapOutputName('OperationCode')] public string $operationCode, - + #[MapOutputName('PayeeAccount')] public string $payeeAccount, - + #[MapOutputName('PayeeBankBic'), Numeric, Size(9)] public string $payeeBankBic, - + #[MapOutputName('PayeeName')] public string $payeeName, - + #[MapOutputName('PayerAccount')] public string $payerAccount, - + #[MapOutputName('PayerBankBic'), Numeric, Size(9)] public string $payerBankBic, - + #[MapOutputName('PayerBankCorrAccount')] public string $payerBankCorrAccount, - + #[MapOutputName('PayerInn'), Numeric] public string $payerInn, - + #[MapOutputName('PayerName')] public string $payerName, - + #[MapOutputName('Priority')] public string $priority, - + #[MapOutputName('Purpose')] public string $purpose, - + #[MapOutputName('Number')] public ?string $number = null, - + #[MapOutputName('PayeeKpp')] public ?string $payeeKpp = null, - + #[MapOutputName('PayeeBankCorrAccount')] public ?string $payeeBankCorrAccount = null, - + #[MapOutputName('PaymentType')] public ?string $paymentType = null, - + #[MapOutputName('DigestSignatures'), DataCollectionOf(DigestSignatureData::class)] public ?DataCollection $digestSignatures = null, ) {} -} \ No newline at end of file +} diff --git a/src/Data/Sandbox/Payments/CreateRubPaymentRequestData.php b/src/Data/Sandbox/Payments/CreateRubPaymentRequestData.php index e448daa..b9bebd1 100644 --- a/src/Data/Sandbox/Payments/CreateRubPaymentRequestData.php +++ b/src/Data/Sandbox/Payments/CreateRubPaymentRequestData.php @@ -18,6 +18,7 @@ use Apoloz\AlfaBank\Traits\SignableData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/Shared/PayerInfoData.php b/src/Data/Shared/PayerInfoData.php index 2c001a4..9dc38e8 100644 --- a/src/Data/Shared/PayerInfoData.php +++ b/src/Data/Shared/PayerInfoData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Data\Shared; use Spatie\LaravelData\Attributes\Validation\Numeric; use Spatie\LaravelData\Attributes\Validation\Size; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/Statement/AmountData.php b/src/Data/Statement/AmountData.php index 37e4d30..791b66d 100644 --- a/src/Data/Statement/AmountData.php +++ b/src/Data/Statement/AmountData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\Statement; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/Statement/RurTransferData.php b/src/Data/Statement/RurTransferData.php index 30f122d..fe21781 100644 --- a/src/Data/Statement/RurTransferData.php +++ b/src/Data/Statement/RurTransferData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\Statement; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/Statement/TransactionCollectionData.php b/src/Data/Statement/TransactionCollectionData.php index f032618..4f3df08 100644 --- a/src/Data/Statement/TransactionCollectionData.php +++ b/src/Data/Statement/TransactionCollectionData.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\PaginationData; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Data/Statement/TransactionData.php b/src/Data/Statement/TransactionData.php index f7f0346..606cb02 100644 --- a/src/Data/Statement/TransactionData.php +++ b/src/Data/Statement/TransactionData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Data\Statement; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Data/WebhookCollectionData.php b/src/Data/WebhookCollectionData.php index 52967c6..1641573 100644 --- a/src/Data/WebhookCollectionData.php +++ b/src/Data/WebhookCollectionData.php @@ -2,8 +2,8 @@ namespace Apoloz\AlfaBank\Data; -use Spatie\LaravelData\Data; use Spatie\LaravelData\Attributes\DataCollectionOf; +use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; class WebhookCollectionData extends Data diff --git a/src/Data/Webhooks/Payloads/BaasWebhookData.php b/src/Data/Webhooks/Payloads/BaasWebhookData.php index fa091a3..939c44e 100644 --- a/src/Data/Webhooks/Payloads/BaasWebhookData.php +++ b/src/Data/Webhooks/Payloads/BaasWebhookData.php @@ -20,4 +20,4 @@ class BaasWebhookData extends BaseWebhookData organizationId: $organizationId ); } -} \ No newline at end of file +} diff --git a/src/Data/Webhooks/Payloads/BaseWebhookData.php b/src/Data/Webhooks/Payloads/BaseWebhookData.php index 831ef48..093c6fe 100644 --- a/src/Data/Webhooks/Payloads/BaseWebhookData.php +++ b/src/Data/Webhooks/Payloads/BaseWebhookData.php @@ -14,4 +14,4 @@ class BaseWebhookData extends Data public ?string $eventTime = null, public ?string $organizationId = null, ) {} -} \ No newline at end of file +} diff --git a/src/Data/Webhooks/Payloads/SbpWebhookData.php b/src/Data/Webhooks/Payloads/SbpWebhookData.php index 4989b3b..2e3be36 100644 --- a/src/Data/Webhooks/Payloads/SbpWebhookData.php +++ b/src/Data/Webhooks/Payloads/SbpWebhookData.php @@ -20,4 +20,4 @@ class SbpWebhookData extends BaseWebhookData organizationId: $organizationId ); } -} \ No newline at end of file +} diff --git a/src/Exceptions/AlfaBankException.php b/src/Exceptions/AlfaBankException.php index 323b116..165df1b 100644 --- a/src/Exceptions/AlfaBankException.php +++ b/src/Exceptions/AlfaBankException.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Exceptions; //
// use Saloon\Http\Response; + //
//
diff --git a/src/Http/Middleware/AlfaResponseMiddleware.php b/src/Http/Middleware/AlfaResponseMiddleware.php index 391b74a..7662232 100644 --- a/src/Http/Middleware/AlfaResponseMiddleware.php +++ b/src/Http/Middleware/AlfaResponseMiddleware.php @@ -1,4 +1,5 @@ use Apoloz\AlfaBank\Exceptions\AlfaBankException; use Saloon\Http\Response; + //
//
@@ -24,7 +26,7 @@ class AlfaResponseMiddleware public function __invoke(Response $response): void { $contentType = $response->header('Content-Type') ?? ''; - + if (str_contains($contentType, 'application/json')) { $data = $response->json(); @@ -38,10 +40,10 @@ class AlfaResponseMiddleware } // 2. Handle SBP specific errors - if (isset($data['ErrorCode']) && (string)$data['ErrorCode'] !== '0') { + if (isset($data['ErrorCode']) && (string) $data['ErrorCode'] !== '0') { throw new AlfaBankException( $response, - (string)$data['ErrorCode'], + (string) $data['ErrorCode'], $data['message'] ?? 'No message' ); } diff --git a/src/Http/Middleware/LoggingMiddleware.php b/src/Http/Middleware/LoggingMiddleware.php index 9662599..da2c82b 100644 --- a/src/Http/Middleware/LoggingMiddleware.php +++ b/src/Http/Middleware/LoggingMiddleware.php @@ -45,6 +45,7 @@ class LoggingMiddleware implements RequestMiddleware, ResponseMiddleware if (isset($headers['Authorization'])) { $headers['Authorization'] = 'Bearer *****'; } + return $headers; } //
@@ -53,7 +54,9 @@ class LoggingMiddleware implements RequestMiddleware, ResponseMiddleware // protected function maskBody(mixed $body): mixed { - if (!is_array($body)) return $body; + if (! is_array($body)) { + return $body; + } $sensitiveKeys = ['pan', 'cvc', 'digestSignatures', 'client_secret', 'refresh_token', 'access_token']; @@ -64,6 +67,7 @@ class LoggingMiddleware implements RequestMiddleware, ResponseMiddleware $body[$key] = $this->maskBody($value); } } + return $body; } //
diff --git a/src/Http/Middleware/LoggingRequestMiddleware.php b/src/Http/Middleware/LoggingRequestMiddleware.php index 4652967..6d28384 100644 --- a/src/Http/Middleware/LoggingRequestMiddleware.php +++ b/src/Http/Middleware/LoggingRequestMiddleware.php @@ -25,12 +25,15 @@ class LoggingRequestMiddleware implements RequestMiddleware if (isset($headers['Authorization'])) { $headers['Authorization'] = 'Bearer *****'; } + return $headers; } protected function maskBody(mixed $body): mixed { - if (!is_array($body)) return $body; + if (! is_array($body)) { + return $body; + } $sensitiveKeys = ['pan', 'cvc', 'digestSignatures', 'client_secret', 'refresh_token', 'access_token']; @@ -41,6 +44,7 @@ class LoggingRequestMiddleware implements RequestMiddleware $body[$key] = $this->maskBody($value); } } + return $body; } } diff --git a/src/Http/Middleware/LoggingResponseMiddleware.php b/src/Http/Middleware/LoggingResponseMiddleware.php index 4885359..d091084 100644 --- a/src/Http/Middleware/LoggingResponseMiddleware.php +++ b/src/Http/Middleware/LoggingResponseMiddleware.php @@ -21,7 +21,9 @@ class LoggingResponseMiddleware implements ResponseMiddleware protected function maskBody(mixed $body): mixed { - if (!is_array($body)) return $body; + if (! is_array($body)) { + return $body; + } $sensitiveKeys = ['pan', 'cvc', 'digestSignatures', 'client_secret', 'refresh_token', 'access_token']; @@ -32,6 +34,7 @@ class LoggingResponseMiddleware implements ResponseMiddleware $body[$key] = $this->maskBody($value); } } + return $body; } } diff --git a/src/Http/Middleware/RequestIdMiddleware.php b/src/Http/Middleware/RequestIdMiddleware.php index ce5401d..41f4ecc 100644 --- a/src/Http/Middleware/RequestIdMiddleware.php +++ b/src/Http/Middleware/RequestIdMiddleware.php @@ -14,7 +14,7 @@ class RequestIdMiddleware implements RequestMiddleware { public function __invoke(PendingRequest $pendingRequest): void { - if (!$pendingRequest->headers()->get('X-Request-ID')) { + if (! $pendingRequest->headers()->get('X-Request-ID')) { $pendingRequest->headers()->add('X-Request-ID', Uuid::v4()); } } diff --git a/src/Http/Middleware/VerifyJwsResponseMiddleware.php b/src/Http/Middleware/VerifyJwsResponseMiddleware.php index 4bb1871..d3dca56 100644 --- a/src/Http/Middleware/VerifyJwsResponseMiddleware.php +++ b/src/Http/Middleware/VerifyJwsResponseMiddleware.php @@ -17,8 +17,8 @@ class VerifyJwsResponseMiddleware { $contentType = $response->header('Content-Type'); - if (str_contains((string)$contentType, 'application/jose')) { - if (!$this->publicKey) { + if (str_contains((string) $contentType, 'application/jose')) { + if (! $this->publicKey) { return $response; } @@ -26,12 +26,12 @@ class VerifyJwsResponseMiddleware $decoded = JwsSigner::verify($jws, $this->publicKey); if ($decoded) { - // In Saloon v3, we can't easily "fake" an existing response object in a type-safe way + // In Saloon v3, we can't easily "fake" an existing response object in a type-safe way // without internal access. We will wrap the data and the user should use $response->json(). - // However, for the sake of PHPStan and clean architecture, we should use the response's - // internal body repository if we really need to overwrite it, or better - + // However, for the sake of PHPStan and clean architecture, we should use the response's + // internal body repository if we really need to overwrite it, or better - // let the user handle the decoded data from a custom DTO. - // To fix the immediate error, we'll return the response as is, + // To fix the immediate error, we'll return the response as is, // but JWS verification is still performed. return $response; } diff --git a/src/Http/Pagination/AlfaOffsetPaginator.php b/src/Http/Pagination/AlfaOffsetPaginator.php index 0a62621..32906e5 100644 --- a/src/Http/Pagination/AlfaOffsetPaginator.php +++ b/src/Http/Pagination/AlfaOffsetPaginator.php @@ -29,7 +29,7 @@ class AlfaOffsetPaginator extends OffsetPaginator protected function isLastPage(Response $response): bool { $items = $this->getPageItems($response, $this->request); - + return count($items) < $this->perPageLimit; } @@ -44,7 +44,7 @@ class AlfaOffsetPaginator extends OffsetPaginator } } catch (\Throwable $e) { // Fallback to raw json if DTO fails - echo "DTO Error: " . $e->getMessage() . "\n"; + echo 'DTO Error: ' . $e->getMessage() . "\n"; } } @@ -52,13 +52,21 @@ class AlfaOffsetPaginator extends OffsetPaginator $json = $response->json(); // Common keys in Alfa API - if (isset($json['transactions'])) return $json['transactions']; - if (isset($json['payments'])) return $json['payments']; - if (isset($json['accounts'])) return $json['accounts']; - + if (isset($json['transactions'])) { + return $json['transactions']; + } + if (isset($json['payments'])) { + return $json['payments']; + } + if (isset($json['accounts'])) { + return $json['accounts']; + } + // If it's a direct array (some endpoints) - if (array_is_list($json)) return $json; + if (array_is_list($json)) { + return $json; + } return []; } -} \ No newline at end of file +} diff --git a/src/Laravel/AlfaBankServiceProvider.php b/src/Laravel/AlfaBankServiceProvider.php index 7009c2f..b849dca 100644 --- a/src/Laravel/AlfaBankServiceProvider.php +++ b/src/Laravel/AlfaBankServiceProvider.php @@ -17,13 +17,14 @@ use Apoloz\AlfaBank\Contracts\SignerInterface; use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; use Apoloz\AlfaBank\Enums\Environment; +use Apoloz\AlfaBank\Laravel\Http\Controllers\AlfaWebhookController; +use Apoloz\AlfaBank\Laravel\Middleware\VerifyAlfaWebhook; +use Apoloz\AlfaBank\Sbp\SbpConnector; use Apoloz\AlfaBank\Services\OpenSslCmsSigner; use Apoloz\AlfaBank\Services\PhpseclibCardEncryptor; -use Apoloz\AlfaBank\Sbp\SbpConnector; -use Apoloz\AlfaBank\Laravel\Middleware\VerifyAlfaWebhook; -use Apoloz\AlfaBank\Laravel\Http\Controllers\AlfaWebhookController; -use Illuminate\Support\ServiceProvider; use Illuminate\Support\Facades\Route; +use Illuminate\Support\ServiceProvider; + //
class AlfaBankServiceProvider extends ServiceProvider @@ -37,6 +38,7 @@ class AlfaBankServiceProvider extends ServiceProvider $this->app->singleton('alfa.baas.config', function ($app) { $conf = $app['config']['alfa-bank.baas']; + return new AlfaConfig( baseUrl: $conf['environment'] === 'production' ? Environment::PRODUCTION->value : Environment::SANDBOX->value, certificatePath: $conf['certificate_path'], @@ -55,13 +57,14 @@ class AlfaBankServiceProvider extends ServiceProvider $config = $app->make('alfa.baas.config'); $cert = $config->signingCertificatePath ?: $config->certificatePath; $key = $config->signingPrivateKeyPath ?: $config->privateKeyPath; - + return new OpenSslCmsSigner($cert, $key); }); - + $this->app->bind(EncryptorInterface::class, function ($app) { $key = $app['config']['alfa-bank.encryption.card_public_key'] ?? ''; - return new PhpseclibCardEncryptor($key); + + return new PhpseclibCardEncryptor($key); }); $this->app->singleton(AlfaBankConnector::class, function ($app) { @@ -74,6 +77,7 @@ class AlfaBankServiceProvider extends ServiceProvider $this->app->singleton('alfa.sbp.config', function ($app) { $conf = $app['config']['alfa-bank.sbp']; + return new AlfaConfig( baseUrl: $conf['environment'] === 'production' ? Environment::SBP_PRODUCTION->value : Environment::SBP_SANDBOX->value, certificatePath: $conf['certificate_path'], @@ -86,6 +90,7 @@ class AlfaBankServiceProvider extends ServiceProvider $this->app->singleton(SbpConnector::class, function ($app) { $config = $app['config']['alfa-bank.sbp']; + return new SbpConnector( alfaConfig: $app->make('alfa.sbp.config'), keyNameAlias: $config['key_name_alias'] ?? null @@ -112,7 +117,7 @@ class AlfaBankServiceProvider extends ServiceProvider if ($this->app->bound('router')) { $router = $this->app->make('router'); $router->aliasMiddleware('alfa.webhook', VerifyAlfaWebhook::class); - + Route::macro('alfaWebhooks', function (string $url) { return Route::post($url, AlfaWebhookController::class) ->name('alfa.webhooks') diff --git a/src/Laravel/Commands/CheckConnectionCommand.php b/src/Laravel/Commands/CheckConnectionCommand.php index bd9576d..917704e 100644 --- a/src/Laravel/Commands/CheckConnectionCommand.php +++ b/src/Laravel/Commands/CheckConnectionCommand.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Laravel\Commands; use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Sbp\SbpConnector; use Illuminate\Console\Command; + //
//
@@ -25,6 +26,7 @@ class CheckConnectionCommand extends Command //
// protected $signature = 'alfa:check'; + protected $description = 'Verify Alfa Bank SDK configuration and mTLS certificates'; //
@@ -50,61 +52,68 @@ class CheckConnectionCommand extends Command $keyPath = (string) config("{$configKey}.private_key_path"); // 1. Check Files - if (!file_exists($certPath)) { + if (! file_exists($certPath)) { $this->error("❌ Certificate not found at: {$certPath}"); + return; } else { - $this->comment("✅ Certificate found"); + $this->comment('✅ Certificate found'); } - if (!file_exists($keyPath)) { + if (! file_exists($keyPath)) { $this->error("❌ Private Key not found at: {$keyPath}"); + return; } else { - $this->comment("✅ Private Key found"); + $this->comment('✅ Private Key found'); } // 2. Validate Cert Expiry $certContent = (string) file_get_contents($certPath); $certInfo = openssl_x509_parse($certContent); - + if ($certInfo && isset($certInfo['validTo_time_t'])) { $validTo = new \DateTimeImmutable('@' . $certInfo['validTo_time_t']); - $now = new \DateTimeImmutable(); + $now = new \DateTimeImmutable; if ($validTo < $now) { - $this->error("❌ Certificate EXPIRED on: " . $validTo->format('Y-m-d H:i:s')); + $this->error('❌ Certificate EXPIRED on: ' . $validTo->format('Y-m-d H:i:s')); } else { $diff = $now->diff($validTo); $days = $diff->days; - $this->comment("✅ Certificate valid until: " . $validTo->format('Y-m-d') . " ({$days} days remaining)"); + $this->comment('✅ Certificate valid until: ' . $validTo->format('Y-m-d') . " ({$days} days remaining)"); } } else { - $this->warn("⚠️ Could not parse certificate date."); + $this->warn('⚠️ Could not parse certificate date.'); } // 3. Attempt Connection (Ping) - $this->comment("Attempting TLS Handshake..."); - + $this->comment('Attempting TLS Handshake...'); + try { // We resolve the connector from container to use the config - $connector = $name === 'BaaS (Nominal Accounts)' - ? app(AlfaBankConnector::class) + $connector = $name === 'BaaS (Nominal Accounts)' + ? app(AlfaBankConnector::class) : app(SbpConnector::class); // Simple GET to the base URL (or a health endpoint) just to test SSL handshake // We don't need a valid token, we just want to see if we get a 401/403 instead of a connection error - $connector->send(new class extends \Saloon\Http\Request { + $connector->send(new class extends \Saloon\Http\Request + { protected \Saloon\Enums\Method $method = \Saloon\Enums\Method::GET; - public function resolveEndpoint(): string { return '/'; } + + public function resolveEndpoint(): string + { + return '/'; + } }); - + // If we are here, SSL worked! - $this->info("✅ Connection Successful! (Handshake completed)"); + $this->info('✅ Connection Successful! (Handshake completed)'); } catch (\Exception $e) { // Check if it's an SSL error if (str_contains($e->getMessage(), 'certificate') || str_contains($e->getMessage(), 'SSL')) { - $this->error("❌ SSL/TLS Error: " . $e->getMessage()); + $this->error('❌ SSL/TLS Error: ' . $e->getMessage()); } else { // Other errors (like 404/401) mean SSL worked but endpoint failed, which is GOOD for this check $this->info("✅ Connection Successful! (Server responded: {$e->getMessage()})"); diff --git a/src/Laravel/Events/AlfaWebhookReceived.php b/src/Laravel/Events/AlfaWebhookReceived.php index ec2c5cf..6601145 100644 --- a/src/Laravel/Events/AlfaWebhookReceived.php +++ b/src/Laravel/Events/AlfaWebhookReceived.php @@ -15,4 +15,4 @@ class AlfaWebhookReceived public function __construct( public BaseWebhookData $webhook ) {} -} \ No newline at end of file +} diff --git a/src/Laravel/Facades/AlfaBank.php b/src/Laravel/Facades/AlfaBank.php index 5b21546..d929f23 100644 --- a/src/Laravel/Facades/AlfaBank.php +++ b/src/Laravel/Facades/AlfaBank.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Apoloz\AlfaBank\Laravel\Facades; -use Apoloz\AlfaBank\Core\AlfaBankConnector; use Illuminate\Support\Facades\Facade; /** diff --git a/src/Laravel/Facades/Sbp.php b/src/Laravel/Facades/Sbp.php index 2ea5d0b..427c3ce 100644 --- a/src/Laravel/Facades/Sbp.php +++ b/src/Laravel/Facades/Sbp.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Apoloz\AlfaBank\Laravel\Facades; -use Apoloz\AlfaBank\Sbp\SbpConnector; use Illuminate\Support\Facades\Facade; /** diff --git a/src/Laravel/Http/Controllers/AlfaWebhookController.php b/src/Laravel/Http/Controllers/AlfaWebhookController.php index 11987f8..82ea1c7 100644 --- a/src/Laravel/Http/Controllers/AlfaWebhookController.php +++ b/src/Laravel/Http/Controllers/AlfaWebhookController.php @@ -33,7 +33,7 @@ class AlfaWebhookController extends Controller protected function processEvent(array $payload): void { $webhookDto = WebhookFactory::create($payload); - + AlfaWebhookReceived::dispatch($webhookDto); } } diff --git a/src/Laravel/Middleware/VerifyAlfaWebhook.php b/src/Laravel/Middleware/VerifyAlfaWebhook.php index 31c12a9..b9956ce 100644 --- a/src/Laravel/Middleware/VerifyAlfaWebhook.php +++ b/src/Laravel/Middleware/VerifyAlfaWebhook.php @@ -29,16 +29,16 @@ class VerifyAlfaWebhook $publicKeyPath = config('alfa-bank.webhook.alfa_public_key'); if ($publicKeyPath && file_exists($publicKeyPath)) { $signature = $request->header('x-jws-signature') ?: $request->getContent(); - + // If content is a JWS string (3 parts separated by dot) if (is_string($signature) && count(explode('.', $signature)) === 3) { $publicKey = file_get_contents($publicKeyPath); $verified = \Apoloz\AlfaBank\Utils\JwsSigner::verify($signature, $publicKey); - - if (!$verified) { + + if (! $verified) { return response()->json(['error' => 'Invalid Webhook Signature'], 401); } - + // Replace request content with verified payload $request->merge($verified); } diff --git a/src/Requests/Accounts/GetAccountsRequest.php b/src/Requests/Accounts/GetAccountsRequest.php index 9ef572f..c966214 100644 --- a/src/Requests/Accounts/GetAccountsRequest.php +++ b/src/Requests/Accounts/GetAccountsRequest.php @@ -31,13 +31,13 @@ class GetAccountsRequest extends Request implements Paginatable return '/api/pp/v1/accounts'; } - protected function defaultQuery(): array - { - return $this->getPaginationQuery(); - } - public function createDtoFromResponse(Response $response): DataCollection { return AccountData::collect($response->json('accounts'), DataCollection::class); } -} \ No newline at end of file + + protected function defaultQuery(): array + { + return $this->getPaginationQuery(); + } +} diff --git a/src/Requests/Aff/CheckComplianceRequest.php b/src/Requests/Aff/CheckComplianceRequest.php index 43d3bd9..7c64408 100644 --- a/src/Requests/Aff/CheckComplianceRequest.php +++ b/src/Requests/Aff/CheckComplianceRequest.php @@ -23,6 +23,11 @@ class CheckComplianceRequest extends Request return '/api/aff/jp/v1/creditors/compliance'; } + public function createDtoFromResponse(Response $response): AffResponseData + { + return AffResponseData::from($response->json()); + } + protected function defaultQuery(): array { return [ @@ -30,9 +35,4 @@ class CheckComplianceRequest extends Request 'name' => $this->name, ]; } - - public function createDtoFromResponse(Response $response): AffResponseData - { - return AffResponseData::from($response->json()); - } } diff --git a/src/Requests/Aff/CreateRegisterRequest.php b/src/Requests/Aff/CreateRegisterRequest.php index f5ea3b5..0483308 100644 --- a/src/Requests/Aff/CreateRegisterRequest.php +++ b/src/Requests/Aff/CreateRegisterRequest.php @@ -27,13 +27,13 @@ class CreateRegisterRequest extends Request implements HasBody return '/api/aff/jp/v1/registers'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): AffResponseData { return AffResponseData::from($response->json()); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/Aff/DownloadRegisterDocumentsRequest.php b/src/Requests/Aff/DownloadRegisterDocumentsRequest.php index 0ce1c5f..eea0bbd 100644 --- a/src/Requests/Aff/DownloadRegisterDocumentsRequest.php +++ b/src/Requests/Aff/DownloadRegisterDocumentsRequest.php @@ -29,4 +29,4 @@ class DownloadRegisterDocumentsRequest extends Request 'size' => strlen($response->body()), ]); } -} \ No newline at end of file +} diff --git a/src/Requests/Aff/GetPaymentStatusRequest.php b/src/Requests/Aff/GetPaymentStatusRequest.php index dcc0d91..0fcd18b 100644 --- a/src/Requests/Aff/GetPaymentStatusRequest.php +++ b/src/Requests/Aff/GetPaymentStatusRequest.php @@ -26,4 +26,4 @@ class GetPaymentStatusRequest extends Request { return AffResponseData::from($response->json()); } -} \ No newline at end of file +} diff --git a/src/Requests/Aff/SignRegisterRequest.php b/src/Requests/Aff/SignRegisterRequest.php index 1ffd32d..21baf2a 100644 --- a/src/Requests/Aff/SignRegisterRequest.php +++ b/src/Requests/Aff/SignRegisterRequest.php @@ -27,15 +27,15 @@ class SignRegisterRequest extends Request implements HasBody return '/api/aff/jp/v1/registers/sign'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from([ 'success' => $response->successful(), ]); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/Auth/GetTokenRequest.php b/src/Requests/Auth/GetTokenRequest.php index 614f316..61d9773 100644 --- a/src/Requests/Auth/GetTokenRequest.php +++ b/src/Requests/Auth/GetTokenRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasFormBody; + //
//
@@ -55,6 +56,14 @@ class GetTokenRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): TokenData + { + return TokenData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -64,7 +73,7 @@ class GetTokenRequest extends Request implements HasBody 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, ]; - + if ($this->grantType === 'authorization_code') { $body['code'] = $this->code; $body['redirect_uri'] = $this->redirectUri; @@ -77,12 +86,4 @@ class GetTokenRequest extends Request implements HasBody return $body; } //
- - //
- // - public function createDtoFromResponse(Response $response): TokenData - { - return TokenData::from($response->json()); - } - //
} diff --git a/src/Requests/Auth/RefreshClientSecretRequest.php b/src/Requests/Auth/RefreshClientSecretRequest.php index f2509a4..81bdab2 100644 --- a/src/Requests/Auth/RefreshClientSecretRequest.php +++ b/src/Requests/Auth/RefreshClientSecretRequest.php @@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Auth\ClientSecretData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/Auth/RevokeTokenRequest.php b/src/Requests/Auth/RevokeTokenRequest.php index faaf0e5..a7eff56 100644 --- a/src/Requests/Auth/RevokeTokenRequest.php +++ b/src/Requests/Auth/RevokeTokenRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasFormBody; + //
//
@@ -52,6 +53,12 @@ class RevokeTokenRequest extends Request implements HasBody } //
+ public function createDtoFromResponse(Response $response): GeneralStatusData + { + return GeneralStatusData::from(['success' => $response->successful()]); + } + //
+ //
// protected function defaultBody(): array @@ -63,10 +70,4 @@ class RevokeTokenRequest extends Request implements HasBody 'token_type_hint' => $this->tokenTypeHint, ]); } - //
- - public function createDtoFromResponse(Response $response): GeneralStatusData - { - return GeneralStatusData::from(['success' => $response->successful()]); - } } diff --git a/src/Requests/Auth/UserInfo/GetClientConsentsRequest.php b/src/Requests/Auth/UserInfo/GetClientConsentsRequest.php index 3fdd90b..bffbc27 100644 --- a/src/Requests/Auth/UserInfo/GetClientConsentsRequest.php +++ b/src/Requests/Auth/UserInfo/GetClientConsentsRequest.php @@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Auth\UserInfo\ClientConsentCollectionData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -47,6 +48,14 @@ class GetClientConsentsRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): ClientConsentCollectionData + { + return ClientConsentCollectionData::from($response->json()); + } + //
+ //
// protected function defaultQuery(): array @@ -58,15 +67,7 @@ class GetClientConsentsRequest extends Request 'isActive' => $this->isActive, 'limit' => $this->limit, 'offset' => $this->offset, - ], fn($value) => $value !== null); - } - //
- - //
- // - public function createDtoFromResponse(Response $response): ClientConsentCollectionData - { - return ClientConsentCollectionData::from($response->json()); + ], fn ($value) => $value !== null); } //
} diff --git a/src/Requests/Auth/UserInfo/GetUserInfoRequest.php b/src/Requests/Auth/UserInfo/GetUserInfoRequest.php index 2d21d89..5704459 100644 --- a/src/Requests/Auth/UserInfo/GetUserInfoRequest.php +++ b/src/Requests/Auth/UserInfo/GetUserInfoRequest.php @@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Auth\UserInfo\UserInfoData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -33,6 +34,26 @@ class GetUserInfoRequest extends Request { return '/oidc/userinfo'; } + + //
+ // + public function createDtoFromResponse(Response $response): UserInfoData + { + $jwt = $response->body(); + $parts = explode('.', $jwt); + + if (count($parts) === 3) { + $payload = json_decode(base64_decode($parts[1]), true); + + return UserInfoData::from($payload); + } + + // Fallback or throw error? + // If the response is not a valid JWT (e.g. error json), Saloon might have handled it if we throw on error status. + // But if it's 200 OK and not a JWT, it's unexpected. + + throw new \Exception('Invalid UserInfo response format. Expected JWT.'); + } //
//
@@ -43,24 +64,5 @@ class GetUserInfoRequest extends Request 'Accept' => 'application/jwt', // As per doc ]; } - - //
- // - public function createDtoFromResponse(Response $response): UserInfoData - { - $jwt = $response->body(); - $parts = explode('.', $jwt); - - if (count($parts) === 3) { - $payload = json_decode(base64_decode($parts[1]), true); - return UserInfoData::from($payload); - } - - // Fallback or throw error? - // If the response is not a valid JWT (e.g. error json), Saloon might have handled it if we throw on error status. - // But if it's 200 OK and not a JWT, it's unexpected. - - throw new \Exception("Invalid UserInfo response format. Expected JWT."); - } //
} diff --git a/src/Requests/B2B_1C/CheckMerchantRequest.php b/src/Requests/B2B_1C/CheckMerchantRequest.php index ca60cfc..c904372 100644 --- a/src/Requests/B2B_1C/CheckMerchantRequest.php +++ b/src/Requests/B2B_1C/CheckMerchantRequest.php @@ -23,15 +23,15 @@ class CheckMerchantRequest extends Request return "/api/1c/merchants/{$this->merchantId}"; } + public function createDtoFromResponse(Response $response): MerchantData + { + return MerchantData::from($response->json()); + } + protected function defaultHeaders(): array { return [ 'Authorization-1C' => $this->auth1C, ]; } - - public function createDtoFromResponse(Response $response): MerchantData - { - return MerchantData::from($response->json()); - } } diff --git a/src/Requests/B2B_1C/GetPaymentLinkRequest.php b/src/Requests/B2B_1C/GetPaymentLinkRequest.php index 9321ecb..15682a1 100644 --- a/src/Requests/B2B_1C/GetPaymentLinkRequest.php +++ b/src/Requests/B2B_1C/GetPaymentLinkRequest.php @@ -23,15 +23,15 @@ class GetPaymentLinkRequest extends Request return "/api/1c/payment-link/{$this->qrId}"; } + public function createDtoFromResponse(Response $response): PaymentLinkData + { + return PaymentLinkData::from($response->json()); + } + protected function defaultHeaders(): array { return [ 'Authorization-1C' => $this->auth1C, ]; } - - public function createDtoFromResponse(Response $response): PaymentLinkData - { - return PaymentLinkData::from($response->json()); - } } diff --git a/src/Requests/B2B_1C/SearchPaymentsRequest.php b/src/Requests/B2B_1C/SearchPaymentsRequest.php index 5943e0a..db9a97f 100644 --- a/src/Requests/B2B_1C/SearchPaymentsRequest.php +++ b/src/Requests/B2B_1C/SearchPaymentsRequest.php @@ -28,6 +28,11 @@ class SearchPaymentsRequest extends Request implements HasBody return '/api/1c/payments/search'; } + public function createDtoFromResponse(Response $response): DataCollection + { + return Payment1CData::collect($response->json(), DataCollection::class); + } + protected function defaultHeaders(): array { return [ @@ -39,9 +44,4 @@ class SearchPaymentsRequest extends Request implements HasBody { return $this->data; } - - public function createDtoFromResponse(Response $response): DataCollection - { - return Payment1CData::collect($response->json(), DataCollection::class); - } } diff --git a/src/Requests/B2C/CreateB2CPaymentRequest.php b/src/Requests/B2C/CreateB2CPaymentRequest.php index 4e3c0ed..dabc8e9 100644 --- a/src/Requests/B2C/CreateB2CPaymentRequest.php +++ b/src/Requests/B2C/CreateB2CPaymentRequest.php @@ -27,13 +27,13 @@ class CreateB2CPaymentRequest extends Request implements HasBody return '/api/b2cpay/jp/v1/payments'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): B2CPaymentResponseData { return B2CPaymentResponseData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/B2C/GetB2CPaymentReportRequest.php b/src/Requests/B2C/GetB2CPaymentReportRequest.php index 62fb76c..e18988a 100644 --- a/src/Requests/B2C/GetB2CPaymentReportRequest.php +++ b/src/Requests/B2C/GetB2CPaymentReportRequest.php @@ -26,6 +26,11 @@ class GetB2CPaymentReportRequest extends Request return '/api/b2cpay/jp/v1/payments'; } + public function createDtoFromResponse(Response $response): B2CPaymentReportData + { + return B2CPaymentReportData::from($response->json()); + } + protected function defaultQuery(): array { return array_filter([ @@ -36,9 +41,4 @@ class GetB2CPaymentReportRequest extends Request 'transactionId' => $this->transactionId, ]); } - - public function createDtoFromResponse(Response $response): B2CPaymentReportData - { - return B2CPaymentReportData::from($response->json()); - } } diff --git a/src/Requests/Claims/ResolveClaimRequest.php b/src/Requests/Claims/ResolveClaimRequest.php index 3034c2b..25e5e42 100644 --- a/src/Requests/Claims/ResolveClaimRequest.php +++ b/src/Requests/Claims/ResolveClaimRequest.php @@ -28,13 +28,13 @@ class ResolveClaimRequest extends Request implements HasBody return "/api/claims/pp/v1/claims/{$this->claimId}"; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from(['success' => $response->successful()]); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/CloudSignature/ConfirmSigningWithSmsRequest.php b/src/Requests/CloudSignature/ConfirmSigningWithSmsRequest.php index 48b14fc..819dd52 100644 --- a/src/Requests/CloudSignature/ConfirmSigningWithSmsRequest.php +++ b/src/Requests/CloudSignature/ConfirmSigningWithSmsRequest.php @@ -27,15 +27,15 @@ class ConfirmSigningWithSmsRequest extends Request implements HasBody return "/api/jp/v3/signature/requests/operations/{$this->operationId}"; } + public function createDtoFromResponse(Response $response): GeneralStatusData + { + return GeneralStatusData::from(['success' => $response->successful()]); + } + protected function defaultBody(): array { return [ 'smsCode' => $this->smsCode, ]; } - - public function createDtoFromResponse(Response $response): GeneralStatusData - { - return GeneralStatusData::from(['success' => $response->successful()]); - } } diff --git a/src/Requests/CloudSignature/IssueRsaCertificateRequest.php b/src/Requests/CloudSignature/IssueRsaCertificateRequest.php index 7507d45..299bf02 100644 --- a/src/Requests/CloudSignature/IssueRsaCertificateRequest.php +++ b/src/Requests/CloudSignature/IssueRsaCertificateRequest.php @@ -27,6 +27,11 @@ class IssueRsaCertificateRequest extends Request implements HasBody return '/api/jp/v3/signature/rsa-certificates/requests/issue'; } + public function createDtoFromResponse(Response $response): CloudSignatureResponseData + { + return CloudSignatureResponseData::from($response->json()); + } + protected function defaultBody(): array { return array_filter([ @@ -34,9 +39,4 @@ class IssueRsaCertificateRequest extends Request implements HasBody 'pkcs10Content' => $this->pkcs10Content, ]); } - - public function createDtoFromResponse(Response $response): CloudSignatureResponseData - { - return CloudSignatureResponseData::from($response->json()); - } } diff --git a/src/Requests/Crypto/GetCertificatesRequest.php b/src/Requests/Crypto/GetCertificatesRequest.php index 19ae8d7..d8ab788 100644 --- a/src/Requests/Crypto/GetCertificatesRequest.php +++ b/src/Requests/Crypto/GetCertificatesRequest.php @@ -23,4 +23,4 @@ class GetCertificatesRequest extends Request { return CertificateData::collect($response->json('certificates') ?? [], DataCollection::class); } -} \ No newline at end of file +} diff --git a/src/Requests/Crypto/UpdateCertificateRequest.php b/src/Requests/Crypto/UpdateCertificateRequest.php index 5c3daee..1f9782d 100644 --- a/src/Requests/Crypto/UpdateCertificateRequest.php +++ b/src/Requests/Crypto/UpdateCertificateRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -49,6 +50,14 @@ class UpdateCertificateRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): CertificateData + { + return CertificateData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -60,12 +69,4 @@ class UpdateCertificateRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): CertificateData - { - return CertificateData::from($response->json()); - } - //
} diff --git a/src/Requests/Crypto/UploadCertificateRequest.php b/src/Requests/Crypto/UploadCertificateRequest.php index e6ff4ac..7f8b870 100644 --- a/src/Requests/Crypto/UploadCertificateRequest.php +++ b/src/Requests/Crypto/UploadCertificateRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,6 +48,14 @@ class UploadCertificateRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): CertificateData + { + return CertificateData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -57,12 +66,4 @@ class UploadCertificateRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): CertificateData - { - return CertificateData::from($response->json()); - } - //
} diff --git a/src/Requests/DFA/GetDfaInitialPlacementListRequest.php b/src/Requests/DFA/GetDfaInitialPlacementListRequest.php index 58b57ce..c598703 100644 --- a/src/Requests/DFA/GetDfaInitialPlacementListRequest.php +++ b/src/Requests/DFA/GetDfaInitialPlacementListRequest.php @@ -31,13 +31,13 @@ class GetDfaInitialPlacementListRequest extends Request implements Paginatable return '/api/dfa/gd/v1/dfa-profile/initial-placement-list'; } - protected function defaultQuery(): array - { - return $this->getPaginationQuery(); - } - public function createDtoFromResponse(Response $response): DataCollection { return DfaInitialPlacementData::collect($response->json('items') ?? [], DataCollection::class); } + + protected function defaultQuery(): array + { + return $this->getPaginationQuery(); + } } diff --git a/src/Requests/DebitCards/CreateDebitCardApplicationRequest.php b/src/Requests/DebitCards/CreateDebitCardApplicationRequest.php index 41047c2..270b2a0 100644 --- a/src/Requests/DebitCards/CreateDebitCardApplicationRequest.php +++ b/src/Requests/DebitCards/CreateDebitCardApplicationRequest.php @@ -27,13 +27,13 @@ class CreateDebitCardApplicationRequest extends Request implements HasBody return '/api/pp/v1/debit-cards/application'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): DebitCardApplicationResponseData { return DebitCardApplicationResponseData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/Escrow/GetEscrowOrdersRequest.php b/src/Requests/Escrow/GetEscrowOrdersRequest.php index f52e236..45e6e99 100644 --- a/src/Requests/Escrow/GetEscrowOrdersRequest.php +++ b/src/Requests/Escrow/GetEscrowOrdersRequest.php @@ -33,6 +33,11 @@ class GetEscrowOrdersRequest extends Request implements Paginatable return '/api/escrow-orders'; } + public function createDtoFromResponse(Response $response): DataCollection + { + return EscrowOrderData::collect($response->json('orders') ?? [], DataCollection::class); + } + protected function defaultQuery(): array { return array_merge([ @@ -40,9 +45,4 @@ class GetEscrowOrdersRequest extends Request implements Paginatable 'filterToDate' => $this->filterToDate, ], $this->getPaginationQuery()); } - - public function createDtoFromResponse(Response $response): DataCollection - { - return EscrowOrderData::collect($response->json('orders') ?? [], DataCollection::class); - } } diff --git a/src/Requests/FileExchange/DownloadFileRequest.php b/src/Requests/FileExchange/DownloadFileRequest.php index 57af502..b34bf65 100644 --- a/src/Requests/FileExchange/DownloadFileRequest.php +++ b/src/Requests/FileExchange/DownloadFileRequest.php @@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\Shared\DownloadedFileData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -41,6 +42,15 @@ class DownloadFileRequest extends Request } //
+ public function createDtoFromResponse(Response $response): DownloadedFileData + { + return DownloadedFileData::from([ + 'content' => $response->body(), + 'size' => strlen($response->body()), + ]); + } + //
+ //
// protected function defaultHeaders(): array @@ -49,13 +59,4 @@ class DownloadFileRequest extends Request 'Accept' => '*/*', ]; } - //
- - public function createDtoFromResponse(Response $response): DownloadedFileData - { - return DownloadedFileData::from([ - 'content' => $response->body(), - 'size' => strlen($response->body()), - ]); - } } diff --git a/src/Requests/FileExchange/UploadFileRequest.php b/src/Requests/FileExchange/UploadFileRequest.php index a0164b1..69970c3 100644 --- a/src/Requests/FileExchange/UploadFileRequest.php +++ b/src/Requests/FileExchange/UploadFileRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasStreamBody; + //
//
@@ -47,13 +48,19 @@ class UploadFileRequest extends Request implements HasBody } //
+ public function createDtoFromResponse(Response $response): GeneralStatusData + { + return GeneralStatusData::from(['success' => $response->successful()]); + } + //
+ //
// protected function defaultHeaders(): array { return [ 'Accept' => '*/*', - 'Content-Length' => (string)$this->fileSize, + 'Content-Length' => (string) $this->fileSize, 'Content-Type' => 'application/octet-stream', ]; } @@ -65,10 +72,4 @@ class UploadFileRequest extends Request implements HasBody { return $this->fileStream; } - //
- - public function createDtoFromResponse(Response $response): GeneralStatusData - { - return GeneralStatusData::from(['success' => $response->successful()]); - } } diff --git a/src/Requests/Files/UploadFileRequest.php b/src/Requests/Files/UploadFileRequest.php index 58dffc9..110d82d 100644 --- a/src/Requests/Files/UploadFileRequest.php +++ b/src/Requests/Files/UploadFileRequest.php @@ -16,8 +16,8 @@ class UploadFileRequest extends Request implements HasBody protected Method $method = Method::PUT; /** - * @param string $url Full pre-signed URL from Alfa Bank - * @param mixed $resource File resource or stream + * @param string $url Full pre-signed URL from Alfa Bank + * @param mixed $resource File resource or stream */ public function __construct( protected string $url, diff --git a/src/Requests/Logistics/ExecuteOrderActionRequest.php b/src/Requests/Logistics/ExecuteOrderActionRequest.php index ca65c98..0832d40 100644 --- a/src/Requests/Logistics/ExecuteOrderActionRequest.php +++ b/src/Requests/Logistics/ExecuteOrderActionRequest.php @@ -31,13 +31,13 @@ class ExecuteOrderActionRequest extends Request implements HasBody return "/api/logistics/jp/v1/partners/channels/{$this->channelId}/providers/{$this->providerId}/orders/{$this->orderId}/actions/{$this->action}"; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from(['success' => $response->successful()]); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/Logistics/GetDeliveriesRequest.php b/src/Requests/Logistics/GetDeliveriesRequest.php index b8e1fc0..93fb618 100644 --- a/src/Requests/Logistics/GetDeliveriesRequest.php +++ b/src/Requests/Logistics/GetDeliveriesRequest.php @@ -25,6 +25,11 @@ class GetDeliveriesRequest extends Request return '/api/logistics/jp/v1/partners/deliveries'; } + public function createDtoFromResponse(Response $response): DataCollection + { + return DeliveryData::collect($response->json('items') ?? [], DataCollection::class); + } + protected function defaultQuery(): array { return [ @@ -33,9 +38,4 @@ class GetDeliveriesRequest extends Request 'offset' => $this->offset, ]; } - - public function createDtoFromResponse(Response $response): DataCollection - { - return DeliveryData::collect($response->json('items') ?? [], DataCollection::class); - } } diff --git a/src/Requests/Loyalty/GetLoyaltyTransactionsRequest.php b/src/Requests/Loyalty/GetLoyaltyTransactionsRequest.php index 1f57de0..632be5b 100644 --- a/src/Requests/Loyalty/GetLoyaltyTransactionsRequest.php +++ b/src/Requests/Loyalty/GetLoyaltyTransactionsRequest.php @@ -28,13 +28,13 @@ class GetLoyaltyTransactionsRequest extends Request implements HasBody return '/api/pp/v1/bonus-account-transactions'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): DataCollection { return LoyaltyTransactionData::collect($response->json('transactions') ?? [], DataCollection::class); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/NominalAccounts/Beneficiaries/CreateBeneficiaryRequest.php b/src/Requests/NominalAccounts/Beneficiaries/CreateBeneficiaryRequest.php index 1244748..8d51188 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/CreateBeneficiaryRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/CreateBeneficiaryRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: CreateBeneficiaryRequestData DTO. // OUTPUTS: CreateBeneficiaryResponseData DTO. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries; //
@@ -18,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,14 +48,6 @@ class CreateBeneficiaryRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): CreateBeneficiaryResponseData @@ -61,4 +55,12 @@ class CreateBeneficiaryRequest extends Request implements HasBody return CreateBeneficiaryResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiariesRequest.php b/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiariesRequest.php index e7ae32a..1acfff1 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiariesRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiariesRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Various filter and pagination parameters. // OUTPUTS: BeneficiaryCollectionData DTO. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries; //
@@ -44,6 +45,14 @@ class GetBeneficiariesRequest extends Request implements Paginatable { return '/api/na/jp/v1/beneficiaries'; } + //
+ + //
+ // + public function createDtoFromResponse(Response $response): BeneficiaryCollectionData + { + return BeneficiaryCollectionData::from($response->json()); + } protected function defaultQuery(): array { @@ -59,12 +68,4 @@ class GetBeneficiariesRequest extends Request implements Paginatable ], $this->getPaginationQuery()); } //
- - //
- // - public function createDtoFromResponse(Response $response): BeneficiaryCollectionData - { - return BeneficiaryCollectionData::from($response->json()); - } - //
} diff --git a/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryBalanceRequest.php b/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryBalanceRequest.php index 90cbe93..0623fb5 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryBalanceRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryBalanceRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Beneficiary ID, account number, and date. // OUTPUTS: BeneficiaryBalanceData DTO. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\BeneficiaryBalanceData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -43,6 +45,14 @@ class GetBeneficiaryBalanceRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): BeneficiaryBalanceData + { + return BeneficiaryBalanceData::from($response->json()); + } + //
+ //
// protected function defaultQuery(): array @@ -53,12 +63,4 @@ class GetBeneficiaryBalanceRequest extends Request ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): BeneficiaryBalanceData - { - return BeneficiaryBalanceData::from($response->json()); - } - //
} diff --git a/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryTransactionsRequest.php b/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryTransactionsRequest.php index 66bca1c..5545e39 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryTransactionsRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/GetBeneficiaryTransactionsRequest.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\BeneficiaryTransactionCol use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -47,6 +48,14 @@ class GetBeneficiaryTransactionsRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): BeneficiaryTransactionCollectionData + { + return BeneficiaryTransactionCollectionData::from($response->json()); + } + //
+ //
// protected function defaultQuery(): array @@ -59,13 +68,5 @@ class GetBeneficiaryTransactionsRequest extends Request ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): BeneficiaryTransactionCollectionData - { - return BeneficiaryTransactionCollectionData::from($response->json()); - } - //
} //
diff --git a/src/Requests/NominalAccounts/Beneficiaries/Requisites/AddRequisiteRequest.php b/src/Requests/NominalAccounts/Beneficiaries/Requisites/AddRequisiteRequest.php index a3d2830..979f8b4 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/Requisites/AddRequisiteRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/Requisites/AddRequisiteRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -48,14 +49,6 @@ class AddRequisiteRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): RequisiteData @@ -63,4 +56,12 @@ class AddRequisiteRequest extends Request implements HasBody return RequisiteData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Beneficiaries/Requisites/GetRequisitesRequest.php b/src/Requests/NominalAccounts/Beneficiaries/Requisites/GetRequisitesRequest.php index fea0077..c607ce3 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/Requisites/GetRequisitesRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/Requisites/GetRequisitesRequest.php @@ -17,6 +17,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Requests/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequest.php b/src/Requests/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequest.php index fd6b22d..bfd28ec 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/Requisites/UpdateRequisiteRequest.php @@ -36,13 +36,13 @@ class UpdateRequisiteRequest extends Request implements HasBody return "/api/na/jp/v1/beneficiaries/{$this->beneficiaryId}/requisites/{$this->requisiteId}"; } - protected function defaultBody(): array - { - return $this->data; - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from(['success' => $response->successful()]); } + + protected function defaultBody(): array + { + return $this->data; + } } diff --git a/src/Requests/NominalAccounts/Beneficiaries/ScoreBeneficiaryRequest.php b/src/Requests/NominalAccounts/Beneficiaries/ScoreBeneficiaryRequest.php index ce0a895..6de0efe 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/ScoreBeneficiaryRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/ScoreBeneficiaryRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Beneficiary ID (string). // OUTPUTS: CreateBeneficiaryResponseData DTO (confirming the scoring operation's status). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryResponse use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequest.php b/src/Requests/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequest.php index d59e73f..f3b7093 100644 --- a/src/Requests/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequest.php +++ b/src/Requests/NominalAccounts/Beneficiaries/UpdateBeneficiaryRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Beneficiary ID and an UpdateBeneficiaryRequestData DTO. // OUTPUTS: CreateBeneficiaryResponseData DTO (confirming the update operation's status). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries; //
@@ -18,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,14 +49,6 @@ class UpdateBeneficiaryRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): CreateBeneficiaryResponseData @@ -62,4 +56,12 @@ class UpdateBeneficiaryRequest extends Request implements HasBody return CreateBeneficiaryResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Deals/AddDealRequest.php b/src/Requests/NominalAccounts/Deals/AddDealRequest.php index 8a49efb..c2a85ac 100644 --- a/src/Requests/NominalAccounts/Deals/AddDealRequest.php +++ b/src/Requests/NominalAccounts/Deals/AddDealRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Account number, expiration date, and a collection of digest signatures. // OUTPUTS: DealData (DTO) of the newly created deal. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals; //
@@ -20,6 +21,7 @@ use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\DataCollection; + //
//
@@ -54,6 +56,14 @@ class AddDealRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): DealData + { + return DealData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -65,12 +75,4 @@ class AddDealRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): DealData - { - return DealData::from($response->json()); - } - //
} diff --git a/src/Requests/NominalAccounts/Deals/DealActionRequest.php b/src/Requests/NominalAccounts/Deals/DealActionRequest.php index deed7cc..efaa41c 100644 --- a/src/Requests/NominalAccounts/Deals/DealActionRequest.php +++ b/src/Requests/NominalAccounts/Deals/DealActionRequest.php @@ -31,13 +31,13 @@ class DealActionRequest extends Request implements HasBody return "/api/na/jp/v1/deals/{$this->dealId}/actions/{$this->action}"; } - protected function defaultBody(): array - { - return $this->data; - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from(['success' => $response->successful()]); } + + protected function defaultBody(): array + { + return $this->data; + } } diff --git a/src/Requests/NominalAccounts/Deals/GetDealPayoffsRequest.php b/src/Requests/NominalAccounts/Deals/GetDealPayoffsRequest.php index e8c254d..a4a4d62 100644 --- a/src/Requests/NominalAccounts/Deals/GetDealPayoffsRequest.php +++ b/src/Requests/NominalAccounts/Deals/GetDealPayoffsRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Deal ID (string). // OUTPUTS: A collection of DealPayoffData DTOs. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals; //
@@ -16,6 +17,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Requests/NominalAccounts/Deals/GetDealRequest.php b/src/Requests/NominalAccounts/Deals/GetDealRequest.php index 232765b..11bd032 100644 --- a/src/Requests/NominalAccounts/Deals/GetDealRequest.php +++ b/src/Requests/NominalAccounts/Deals/GetDealRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Deal ID (string). // OUTPUTS: DealData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\DealData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Deals/GetDealRequestStatusRequest.php b/src/Requests/NominalAccounts/Deals/GetDealRequestStatusRequest.php index debafe6..a7fbd77 100644 --- a/src/Requests/NominalAccounts/Deals/GetDealRequestStatusRequest.php +++ b/src/Requests/NominalAccounts/Deals/GetDealRequestStatusRequest.php @@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\DealRequestStatusData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Deals/GetDealsRequest.php b/src/Requests/NominalAccounts/Deals/GetDealsRequest.php index 6464005..299165d 100644 --- a/src/Requests/NominalAccounts/Deals/GetDealsRequest.php +++ b/src/Requests/NominalAccounts/Deals/GetDealsRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Account number, pagination parameters (limit, offset). // OUTPUTS: DealCollectionData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\DealCollectionData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -43,6 +45,14 @@ class GetDealsRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): DealCollectionData + { + return DealCollectionData::from($response->json()); + } + //
+ //
// protected function defaultQuery(): array @@ -54,12 +64,4 @@ class GetDealsRequest extends Request ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): DealCollectionData - { - return DealCollectionData::from($response->json()); - } - //
} diff --git a/src/Requests/NominalAccounts/Deals/Steps/GetStepContractorsRequest.php b/src/Requests/NominalAccounts/Deals/Steps/GetStepContractorsRequest.php index a3e9ba5..9a88261 100644 --- a/src/Requests/NominalAccounts/Deals/Steps/GetStepContractorsRequest.php +++ b/src/Requests/NominalAccounts/Deals/Steps/GetStepContractorsRequest.php @@ -17,6 +17,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Spatie\LaravelData\DataCollection; + //
//
@@ -46,6 +47,14 @@ class GetStepContractorsRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): DataCollection + { + return StepContractorData::collect($response->json(), DataCollection::class); + } + //
+ //
// protected function defaultQuery(): array @@ -56,12 +65,4 @@ class GetStepContractorsRequest extends Request ]); } //
- - //
- // - public function createDtoFromResponse(Response $response): DataCollection - { - return StepContractorData::collect($response->json(), DataCollection::class); - } - //
} diff --git a/src/Requests/NominalAccounts/Deals/Steps/GetStepRequest.php b/src/Requests/NominalAccounts/Deals/Steps/GetStepRequest.php index 3b08b3a..0a565d5 100644 --- a/src/Requests/NominalAccounts/Deals/Steps/GetStepRequest.php +++ b/src/Requests/NominalAccounts/Deals/Steps/GetStepRequest.php @@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps\StepData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Deals/Steps/GetStepsRequest.php b/src/Requests/NominalAccounts/Deals/Steps/GetStepsRequest.php index 7a4b8b7..1803b36 100644 --- a/src/Requests/NominalAccounts/Deals/Steps/GetStepsRequest.php +++ b/src/Requests/NominalAccounts/Deals/Steps/GetStepsRequest.php @@ -17,6 +17,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Spatie\LaravelData\DataCollection; + //
//
@@ -45,6 +46,14 @@ class GetStepsRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): DataCollection + { + return StepData::collect($response->json(), DataCollection::class); + } + //
+ //
// protected function defaultQuery(): array @@ -55,12 +64,4 @@ class GetStepsRequest extends Request ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): DataCollection - { - return StepData::collect($response->json(), DataCollection::class); - } - //
} diff --git a/src/Requests/NominalAccounts/Deals/Steps/ManageContractorRequest.php b/src/Requests/NominalAccounts/Deals/Steps/ManageContractorRequest.php index 77f80f1..0711c24 100644 --- a/src/Requests/NominalAccounts/Deals/Steps/ManageContractorRequest.php +++ b/src/Requests/NominalAccounts/Deals/Steps/ManageContractorRequest.php @@ -36,13 +36,13 @@ class ManageContractorRequest extends Request implements HasBody return "/api/na/jp/v1/deals/{$this->dealId}/steps/{$this->stepId}/contractors"; } - protected function defaultBody(): array - { - return $this->data; - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from(['success' => $response->successful()]); } + + protected function defaultBody(): array + { + return $this->data; + } } diff --git a/src/Requests/NominalAccounts/Deals/Steps/ManageStepRequest.php b/src/Requests/NominalAccounts/Deals/Steps/ManageStepRequest.php index db68cfe..b16b0a6 100644 --- a/src/Requests/NominalAccounts/Deals/Steps/ManageStepRequest.php +++ b/src/Requests/NominalAccounts/Deals/Steps/ManageStepRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,14 +48,6 @@ class ManageStepRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): StepActionResponseData @@ -62,4 +55,12 @@ class ManageStepRequest extends Request implements HasBody return StepActionResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Deals/ValidateDealRequest.php b/src/Requests/NominalAccounts/Deals/ValidateDealRequest.php index 237904b..9459cca 100644 --- a/src/Requests/NominalAccounts/Deals/ValidateDealRequest.php +++ b/src/Requests/NominalAccounts/Deals/ValidateDealRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Deal ID (string). // OUTPUTS: ValidateDealResponseData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Deals; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Deals\ValidateDealResponseData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/GetCounterpartyRequestStatusRequest.php b/src/Requests/NominalAccounts/GetCounterpartyRequestStatusRequest.php index d0bf864..c41c1e2 100644 --- a/src/Requests/NominalAccounts/GetCounterpartyRequestStatusRequest.php +++ b/src/Requests/NominalAccounts/GetCounterpartyRequestStatusRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Request ID (string). // OUTPUTS: CounterpartyRequestStatusData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\CounterpartyRequestStatusData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/GetNominalAccountsRequest.php b/src/Requests/NominalAccounts/GetNominalAccountsRequest.php index caeb1f8..8feda5f 100644 --- a/src/Requests/NominalAccounts/GetNominalAccountsRequest.php +++ b/src/Requests/NominalAccounts/GetNominalAccountsRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: None (implicitly uses connector's authentication). // OUTPUTS: A collection of NominalAccountData DTOs. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts; //
@@ -37,16 +38,16 @@ class GetNominalAccountsRequest extends Request return '/api/na/jp/v1/nominal-accounts'; } - protected function defaultQuery(): array - { - return $this->getPaginationQuery(); - } - //
// public function createDtoFromResponse(Response $response): DataCollection { return NominalAccountData::collect($response->json(), DataCollection::class); } + + protected function defaultQuery(): array + { + return $this->getPaginationQuery(); + } //
} diff --git a/src/Requests/NominalAccounts/Identification/GetIdentifyStatusRequest.php b/src/Requests/NominalAccounts/Identification/GetIdentifyStatusRequest.php index 1b6ea67..96f9ffd 100644 --- a/src/Requests/NominalAccounts/Identification/GetIdentifyStatusRequest.php +++ b/src/Requests/NominalAccounts/Identification/GetIdentifyStatusRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Unidentified transaction ID and the specific identification request ID. // OUTPUTS: IdentifyResponseData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Identification\IdentifyResponseData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Identification/GetUnidentifiedTransactionsRequest.php b/src/Requests/NominalAccounts/Identification/GetUnidentifiedTransactionsRequest.php index e30dc8a..a4bac2b 100644 --- a/src/Requests/NominalAccounts/Identification/GetUnidentifiedTransactionsRequest.php +++ b/src/Requests/NominalAccounts/Identification/GetUnidentifiedTransactionsRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Account number, and optional pagination parameters. // OUTPUTS: UnidentifiedTransactionCollectionData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Identification\UnidentifiedTransactionC use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -43,6 +45,14 @@ class GetUnidentifiedTransactionsRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): UnidentifiedTransactionCollectionData + { + return UnidentifiedTransactionCollectionData::from($response->json()); + } + //
+ //
// protected function defaultQuery(): array @@ -54,12 +64,4 @@ class GetUnidentifiedTransactionsRequest extends Request ]); } //
- - //
- // - public function createDtoFromResponse(Response $response): UnidentifiedTransactionCollectionData - { - return UnidentifiedTransactionCollectionData::from($response->json()); - } - //
} diff --git a/src/Requests/NominalAccounts/Identification/IdentifyTransactionRequest.php b/src/Requests/NominalAccounts/Identification/IdentifyTransactionRequest.php index 55a639b..9f6bd46 100644 --- a/src/Requests/NominalAccounts/Identification/IdentifyTransactionRequest.php +++ b/src/Requests/NominalAccounts/Identification/IdentifyTransactionRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Unidentified transaction ID, and an IdentifyRequestData DTO. // OUTPUTS: IdentifyResponseData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification; //
@@ -18,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,14 +49,6 @@ class IdentifyTransactionRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): IdentifyResponseData @@ -62,4 +56,12 @@ class IdentifyTransactionRequest extends Request implements HasBody return IdentifyResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Identification/RefundUnidentifiedTransactionRequest.php b/src/Requests/NominalAccounts/Identification/RefundUnidentifiedTransactionRequest.php index 4184876..5a91104 100644 --- a/src/Requests/NominalAccounts/Identification/RefundUnidentifiedTransactionRequest.php +++ b/src/Requests/NominalAccounts/Identification/RefundUnidentifiedTransactionRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Unidentified transaction ID, and RefundUnidentifiedTransactionRequestData DTO. // OUTPUTS: RefundUnidentifiedTransactionResponseData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Identification; //
@@ -18,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,14 +49,6 @@ class RefundUnidentifiedTransactionRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): RefundUnidentifiedTransactionResponseData @@ -62,4 +56,12 @@ class RefundUnidentifiedTransactionRequest extends Request implements HasBody return RefundUnidentifiedTransactionResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Payouts/CreatePayoffRequest.php b/src/Requests/NominalAccounts/Payouts/CreatePayoffRequest.php index 05b8725..9446af0 100644 --- a/src/Requests/NominalAccounts/Payouts/CreatePayoffRequest.php +++ b/src/Requests/NominalAccounts/Payouts/CreatePayoffRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: PayoffRequestData DTO. // OUTPUTS: PayoffResponseData DTO. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts; //
@@ -18,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,14 +48,6 @@ class CreatePayoffRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): PayoffResponseData @@ -61,4 +55,12 @@ class CreatePayoffRequest extends Request implements HasBody return PayoffResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Payouts/CreateTaxRefundRequest.php b/src/Requests/NominalAccounts/Payouts/CreateTaxRefundRequest.php index 65ab88b..452437d 100644 --- a/src/Requests/NominalAccounts/Payouts/CreateTaxRefundRequest.php +++ b/src/Requests/NominalAccounts/Payouts/CreateTaxRefundRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: TaxRefundRequestData DTO. // OUTPUTS: TaxRefundResponseData DTO. */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts; //
@@ -18,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,14 +48,6 @@ class CreateTaxRefundRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): TaxRefundResponseData @@ -61,4 +55,12 @@ class CreateTaxRefundRequest extends Request implements HasBody return TaxRefundResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/Payouts/GetPayoffRequest.php b/src/Requests/NominalAccounts/Payouts/GetPayoffRequest.php index b63524c..aac46f6 100644 --- a/src/Requests/NominalAccounts/Payouts/GetPayoffRequest.php +++ b/src/Requests/NominalAccounts/Payouts/GetPayoffRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Payoff ID (string). // OUTPUTS: DetailedPayoffData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DetailedPayoffData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Payouts/GetPayoffStatusRequest.php b/src/Requests/NominalAccounts/Payouts/GetPayoffStatusRequest.php index 4018abc..b89c194 100644 --- a/src/Requests/NominalAccounts/Payouts/GetPayoffStatusRequest.php +++ b/src/Requests/NominalAccounts/Payouts/GetPayoffStatusRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Payoff ID (string). // OUTPUTS: PayoffResponseData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\PayoffResponseData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Payouts/GetTaxRefundStatusRequest.php b/src/Requests/NominalAccounts/Payouts/GetTaxRefundStatusRequest.php index 9fa1e6e..7a4dc1a 100644 --- a/src/Requests/NominalAccounts/Payouts/GetTaxRefundStatusRequest.php +++ b/src/Requests/NominalAccounts/Payouts/GetTaxRefundStatusRequest.php @@ -7,6 +7,7 @@ declare(strict_types=1); // INPUTS: Tax refund ID (string). // OUTPUTS: TaxRefundResponseData (DTO). */ + namespace Apoloz\AlfaBank\Requests\NominalAccounts\Payouts; //
@@ -15,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\TaxRefundResponseData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/Payouts/PayoffAcceptRequest.php b/src/Requests/NominalAccounts/Payouts/PayoffAcceptRequest.php index c89dbd8..b03824e 100644 --- a/src/Requests/NominalAccounts/Payouts/PayoffAcceptRequest.php +++ b/src/Requests/NominalAccounts/Payouts/PayoffAcceptRequest.php @@ -27,15 +27,15 @@ class PayoffAcceptRequest extends Request implements HasBody return "/api/na/jp/v1/payoffs/{$this->payoffId}/accept"; } + public function createDtoFromResponse(Response $response): ResultResponseData + { + return ResultResponseData::from($response->json()); + } + protected function defaultBody(): array { return [ 'accept' => $this->accept, ]; } - - public function createDtoFromResponse(Response $response): ResultResponseData - { - return ResultResponseData::from($response->json()); - } -} \ No newline at end of file +} diff --git a/src/Requests/NominalAccounts/Payouts/TaxRefundAcceptRequest.php b/src/Requests/NominalAccounts/Payouts/TaxRefundAcceptRequest.php index 2f49203..0f23c58 100644 --- a/src/Requests/NominalAccounts/Payouts/TaxRefundAcceptRequest.php +++ b/src/Requests/NominalAccounts/Payouts/TaxRefundAcceptRequest.php @@ -27,15 +27,15 @@ class TaxRefundAcceptRequest extends Request implements HasBody return "/api/na/jp/v1/tax-refund/{$this->taxRefundId}/accept"; } + public function createDtoFromResponse(Response $response): ResultResponseData + { + return ResultResponseData::from($response->json()); + } + protected function defaultBody(): array { return [ 'accept' => $this->accept, ]; } - - public function createDtoFromResponse(Response $response): ResultResponseData - { - return ResultResponseData::from($response->json()); - } -} \ No newline at end of file +} diff --git a/src/Requests/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequest.php b/src/Requests/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequest.php index fc2dcb9..35cd374 100644 --- a/src/Requests/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequest.php +++ b/src/Requests/NominalAccounts/UniversalRecipients/CreateUniversalRecipientRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,14 +48,6 @@ class CreateUniversalRecipientRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): UniversalRecipientResponseData @@ -62,4 +55,12 @@ class CreateUniversalRecipientRequest extends Request implements HasBody return UniversalRecipientResponseData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientRequest.php b/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientRequest.php index 2513be6..3c78c78 100644 --- a/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientRequest.php +++ b/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientRequest.php @@ -16,6 +16,7 @@ use Apoloz\AlfaBank\Data\NominalAccounts\UniversalRecipients\UniversalRecipientD use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
diff --git a/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientsRequest.php b/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientsRequest.php index 761dae9..396b823 100644 --- a/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientsRequest.php +++ b/src/Requests/NominalAccounts/UniversalRecipients/GetUniversalRecipientsRequest.php @@ -17,6 +17,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Spatie\LaravelData\DataCollection; + //
//
@@ -48,6 +49,14 @@ class GetUniversalRecipientsRequest extends Request } //
+ //
+ // + public function createDtoFromResponse(Response $response): DataCollection + { + return UniversalRecipientData::collect($response->json('universalRecipients'), DataCollection::class); + } + //
+ //
// protected function defaultQuery(): array @@ -59,15 +68,7 @@ class GetUniversalRecipientsRequest extends Request 'offset' => $this->offset, 'isActive' => $this->isActive, 'date' => $this->date, - ], fn($val) => $val !== null); - } - //
- - //
- // - public function createDtoFromResponse(Response $response): DataCollection - { - return UniversalRecipientData::collect($response->json('universalRecipients'), DataCollection::class); + ], fn ($val) => $val !== null); } //
} diff --git a/src/Requests/NominalAccounts/UniversalRecipients/Requisites/AddUniversalRecipientRequisiteRequest.php b/src/Requests/NominalAccounts/UniversalRecipients/Requisites/AddUniversalRecipientRequisiteRequest.php index 838c320..a611fbf 100644 --- a/src/Requests/NominalAccounts/UniversalRecipients/Requisites/AddUniversalRecipientRequisiteRequest.php +++ b/src/Requests/NominalAccounts/UniversalRecipients/Requisites/AddUniversalRecipientRequisiteRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -48,14 +49,6 @@ class AddUniversalRecipientRequisiteRequest extends Request implements HasBody } //
- //
- // - protected function defaultBody(): array - { - return $this->data->toArray(); - } - //
- //
// public function createDtoFromResponse(Response $response): RequisiteData @@ -63,4 +56,12 @@ class AddUniversalRecipientRequisiteRequest extends Request implements HasBody return RequisiteData::from($response->json()); } //
+ + //
+ // + protected function defaultBody(): array + { + return $this->data->toArray(); + } + //
} diff --git a/src/Requests/NominalAccounts/UniversalRecipients/Requisites/GetUniversalRecipientRequisitesRequest.php b/src/Requests/NominalAccounts/UniversalRecipients/Requisites/GetUniversalRecipientRequisitesRequest.php index c404aa6..d4d44c1 100644 --- a/src/Requests/NominalAccounts/UniversalRecipients/Requisites/GetUniversalRecipientRequisitesRequest.php +++ b/src/Requests/NominalAccounts/UniversalRecipients/Requisites/GetUniversalRecipientRequisitesRequest.php @@ -17,6 +17,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Spatie\LaravelData\DataCollection; + //
//
diff --git a/src/Requests/NominalAccounts/UniversalRecipients/Requisites/UpdateUniversalRecipientRequisiteRequest.php b/src/Requests/NominalAccounts/UniversalRecipients/Requisites/UpdateUniversalRecipientRequisiteRequest.php index 594a036..577cbc6 100644 --- a/src/Requests/NominalAccounts/UniversalRecipients/Requisites/UpdateUniversalRecipientRequisiteRequest.php +++ b/src/Requests/NominalAccounts/UniversalRecipients/Requisites/UpdateUniversalRecipientRequisiteRequest.php @@ -36,13 +36,13 @@ class UpdateUniversalRecipientRequisiteRequest extends Request implements HasBod return "/api/na/jp/v1/universal-recipients/{$this->universalRecipientId}/requisites/{$this->universalRecipientId}"; } - protected function defaultBody(): array - { - return $this->data; - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from(['success' => $response->successful()]); } + + protected function defaultBody(): array + { + return $this->data; + } } diff --git a/src/Requests/Orders/CreateAfishaOrderRequest.php b/src/Requests/Orders/CreateAfishaOrderRequest.php index 940a8bf..4a241d4 100644 --- a/src/Requests/Orders/CreateAfishaOrderRequest.php +++ b/src/Requests/Orders/CreateAfishaOrderRequest.php @@ -27,13 +27,13 @@ class CreateAfishaOrderRequest extends Request implements HasBody return '/api/order-core/pp/v1/afisha/orders'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): OrderResponseData { return OrderResponseData::from($response->json()); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/Orders/CreateTravelOrderRequest.php b/src/Requests/Orders/CreateTravelOrderRequest.php index 84b5658..b875ea8 100644 --- a/src/Requests/Orders/CreateTravelOrderRequest.php +++ b/src/Requests/Orders/CreateTravelOrderRequest.php @@ -27,13 +27,13 @@ class CreateTravelOrderRequest extends Request implements HasBody return '/api/order-core/pp/v1/travel/orders'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): OrderResponseData { return OrderResponseData::from($response->json()); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/Partner/CreateIndividualRequest.php b/src/Requests/Partner/CreateIndividualRequest.php index f88e994..dd4d10c 100644 --- a/src/Requests/Partner/CreateIndividualRequest.php +++ b/src/Requests/Partner/CreateIndividualRequest.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Apoloz\AlfaBank\Requests\Partner; -use Spatie\LaravelData\Data; use Saloon\Contracts\Body\HasBody; use Saloon\Enums\Method; use Saloon\Http\Request; diff --git a/src/Requests/Partner/GetPartnerApplicationsRequest.php b/src/Requests/Partner/GetPartnerApplicationsRequest.php index d79acb1..20b0618 100644 --- a/src/Requests/Partner/GetPartnerApplicationsRequest.php +++ b/src/Requests/Partner/GetPartnerApplicationsRequest.php @@ -26,6 +26,11 @@ class GetPartnerApplicationsRequest extends Request return '/api/partner/jp/v1/individuals'; } + public function createDtoFromResponse(Response $response): DataCollection + { + return PartnerApplicationData::collect($response->json('items') ?? [], DataCollection::class); + } + protected function defaultQuery(): array { return array_filter([ @@ -35,9 +40,4 @@ class GetPartnerApplicationsRequest extends Request 'offset' => $this->offset, ]); } - - public function createDtoFromResponse(Response $response): DataCollection - { - return PartnerApplicationData::collect($response->json('items') ?? [], DataCollection::class); - } } diff --git a/src/Requests/Payments/CreatePaymentRequest.php b/src/Requests/Payments/CreatePaymentRequest.php index af7af51..143d35d 100644 --- a/src/Requests/Payments/CreatePaymentRequest.php +++ b/src/Requests/Payments/CreatePaymentRequest.php @@ -27,11 +27,6 @@ class CreatePaymentRequest extends Request implements HasBody return '/api/jp/v2/payments'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): PaymentResponseData { return PaymentResponseData::from([ @@ -39,4 +34,9 @@ class CreatePaymentRequest extends Request implements HasBody 'status' => $response->status() === 201 ? 'CREATED' : 'ERROR', ]); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/Poa/CreatePoaRequest.php b/src/Requests/Poa/CreatePoaRequest.php index fbe68d6..66dc188 100644 --- a/src/Requests/Poa/CreatePoaRequest.php +++ b/src/Requests/Poa/CreatePoaRequest.php @@ -27,4 +27,4 @@ class CreatePoaRequest extends Request { return PoaResponseData::from($response->json()); } -} \ No newline at end of file +} diff --git a/src/Requests/Poa/GetPoaRequestStatusRequest.php b/src/Requests/Poa/GetPoaRequestStatusRequest.php index fcdfe2b..5cf261a 100644 --- a/src/Requests/Poa/GetPoaRequestStatusRequest.php +++ b/src/Requests/Poa/GetPoaRequestStatusRequest.php @@ -26,4 +26,4 @@ class GetPoaRequestStatusRequest extends Request { return PoaResponseData::from($response->json()); } -} \ No newline at end of file +} diff --git a/src/Requests/Registries/CreateRegistryRequest.php b/src/Requests/Registries/CreateRegistryRequest.php index e3caef7..20f1e0b 100644 --- a/src/Requests/Registries/CreateRegistryRequest.php +++ b/src/Requests/Registries/CreateRegistryRequest.php @@ -27,13 +27,13 @@ class CreateRegistryRequest extends Request implements HasBody return '/api/jp/v1/registries'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): RegistryResponseData { return RegistryResponseData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/Registries/CreateSelfEncashmentRegistryRequest.php b/src/Requests/Registries/CreateSelfEncashmentRegistryRequest.php index 716915a..86d4c4c 100644 --- a/src/Requests/Registries/CreateSelfEncashmentRegistryRequest.php +++ b/src/Requests/Registries/CreateSelfEncashmentRegistryRequest.php @@ -27,13 +27,13 @@ class CreateSelfEncashmentRegistryRequest extends Request implements HasBody return '/api/jp/v1/self-encashment/registries'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): RegistryResponseData { return RegistryResponseData::from($response->json()); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/Registries/SignRegistryRequest.php b/src/Requests/Registries/SignRegistryRequest.php index e82881c..831b459 100644 --- a/src/Requests/Registries/SignRegistryRequest.php +++ b/src/Requests/Registries/SignRegistryRequest.php @@ -30,17 +30,17 @@ class SignRegistryRequest extends Request implements HasBody return "/api/jp/v1/registries/{$this->registryId}/signatures"; } - protected function defaultBody(): array - { - return [ - 'digestSignatures' => $this->signatures->toArray(), - ]; - } - public function createDtoFromResponse(Response $response): GeneralStatusData { return GeneralStatusData::from([ 'success' => $response->successful(), ]); } + + protected function defaultBody(): array + { + return [ + 'digestSignatures' => $this->signatures->toArray(), + ]; + } } diff --git a/src/Requests/Reports/CreateAccountBalanceReportRequest.php b/src/Requests/Reports/CreateAccountBalanceReportRequest.php index 20388f8..cb03762 100644 --- a/src/Requests/Reports/CreateAccountBalanceReportRequest.php +++ b/src/Requests/Reports/CreateAccountBalanceReportRequest.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Apoloz\AlfaBank\Requests\Reports; -use Apoloz\AlfaBank\Data\Reports\AccountBalanceReportData; use Apoloz\AlfaBank\Data\Registries\RegistryResponseData; +use Apoloz\AlfaBank\Data\Reports\AccountBalanceReportData; use Saloon\Contracts\Body\HasBody; use Saloon\Enums\Method; use Saloon\Http\Request; @@ -26,16 +26,17 @@ class CreateAccountBalanceReportRequest extends Request implements HasBody public function resolveEndpoint(): string { $path = $this->language === 'eng' ? 'eng' : 'rus'; - return "/api/pp/v1/reports/type/account/balance/{$path}"; - } - protected function defaultBody(): array - { - return $this->data->toArray(); + return "/api/pp/v1/reports/type/account/balance/{$path}"; } public function createDtoFromResponse(Response $response): RegistryResponseData { return RegistryResponseData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/Salary/CreateAccountApplicationRequest.php b/src/Requests/Salary/CreateAccountApplicationRequest.php index 560c999..bdde66e 100644 --- a/src/Requests/Salary/CreateAccountApplicationRequest.php +++ b/src/Requests/Salary/CreateAccountApplicationRequest.php @@ -28,6 +28,11 @@ class CreateAccountApplicationRequest extends Request implements HasBody return '/api/jp/v1/salary-project/accounts/applications'; } + public function createDtoFromResponse(Response $response): SalaryApplicationResponseData + { + return SalaryApplicationResponseData::from($response->json()); + } + protected function defaultHeaders(): array { return array_filter([ @@ -39,9 +44,4 @@ class CreateAccountApplicationRequest extends Request implements HasBody { return $this->data->toArray(); } - - public function createDtoFromResponse(Response $response): SalaryApplicationResponseData - { - return SalaryApplicationResponseData::from($response->json()); - } } diff --git a/src/Requests/Salary/CreatePayrollApplicationRequest.php b/src/Requests/Salary/CreatePayrollApplicationRequest.php index 07794a5..9f55a26 100644 --- a/src/Requests/Salary/CreatePayrollApplicationRequest.php +++ b/src/Requests/Salary/CreatePayrollApplicationRequest.php @@ -28,6 +28,11 @@ class CreatePayrollApplicationRequest extends Request implements HasBody return '/api/jp/v1/salary-project/payroll/applications'; } + public function createDtoFromResponse(Response $response): SalaryApplicationResponseData + { + return SalaryApplicationResponseData::from($response->json()); + } + protected function defaultHeaders(): array { return array_filter([ @@ -39,9 +44,4 @@ class CreatePayrollApplicationRequest extends Request implements HasBody { return $this->data->toArray(); } - - public function createDtoFromResponse(Response $response): SalaryApplicationResponseData - { - return SalaryApplicationResponseData::from($response->json()); - } } diff --git a/src/Requests/Sandbox/Payments/CreateRubPaymentRequest.php b/src/Requests/Sandbox/Payments/CreateRubPaymentRequest.php index b9f9704..e56562b 100644 --- a/src/Requests/Sandbox/Payments/CreateRubPaymentRequest.php +++ b/src/Requests/Sandbox/Payments/CreateRubPaymentRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,16 +48,16 @@ class CreateRubPaymentRequest extends Request implements HasBody } //
+ public function createDtoFromResponse(Response $response): GeneralStatusData + { + return GeneralStatusData::from(['success' => $response->successful()]); + } + //
+ //
// protected function defaultBody(): array { return $this->data->toArray(); } - //
- - public function createDtoFromResponse(Response $response): GeneralStatusData - { - return GeneralStatusData::from(['success' => $response->successful()]); - } } diff --git a/src/Requests/Sandbox/SignatureEncryptionTestRequest.php b/src/Requests/Sandbox/SignatureEncryptionTestRequest.php index 6673b93..f5d2379 100644 --- a/src/Requests/Sandbox/SignatureEncryptionTestRequest.php +++ b/src/Requests/Sandbox/SignatureEncryptionTestRequest.php @@ -16,10 +16,10 @@ class SignatureEncryptionTestRequest extends Request implements HasBody protected Method $method = Method::POST; /** - * @param string $data Raw content (JWS, TEXT or XML) - * @param string $format json|text|xml - * @param string $requestSecurity NO|SIGNATURE|ENCRYPTION - * @param string $responseSecurity NO|SIGNATURE|ENCRYPTION + * @param string $data Raw content (JWS, TEXT or XML) + * @param string $format json|text|xml + * @param string $requestSecurity NO|SIGNATURE|ENCRYPTION + * @param string $responseSecurity NO|SIGNATURE|ENCRYPTION */ public function __construct( protected string $data, @@ -51,4 +51,4 @@ class SignatureEncryptionTestRequest extends Request implements HasBody { return $this->data; } -} \ No newline at end of file +} diff --git a/src/Requests/Sandbox/TriggerWebhookEventRequest.php b/src/Requests/Sandbox/TriggerWebhookEventRequest.php index b390ec6..4db5cd6 100644 --- a/src/Requests/Sandbox/TriggerWebhookEventRequest.php +++ b/src/Requests/Sandbox/TriggerWebhookEventRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,12 @@ class TriggerWebhookEventRequest extends Request implements HasBody } //
+ public function createDtoFromResponse(Response $response): GeneralStatusData + { + return GeneralStatusData::from(['success' => $response->successful()]); + } + //
+ //
// protected function defaultBody(): array @@ -54,10 +61,4 @@ class TriggerWebhookEventRequest extends Request implements HasBody 'object' => $this->object, ]; } - //
- - public function createDtoFromResponse(Response $response): GeneralStatusData - { - return GeneralStatusData::from(['success' => $response->successful()]); - } } diff --git a/src/Requests/Scoring/GetComplianceScoreRequest.php b/src/Requests/Scoring/GetComplianceScoreRequest.php index 64cd550..be30d62 100644 --- a/src/Requests/Scoring/GetComplianceScoreRequest.php +++ b/src/Requests/Scoring/GetComplianceScoreRequest.php @@ -22,15 +22,15 @@ class GetComplianceScoreRequest extends Request return '/api/mathmod-scorings/jp/v1/compliance'; } + public function createDtoFromResponse(Response $response): ComplianceScoreData + { + return ComplianceScoreData::from($response->json()); + } + protected function defaultQuery(): array { return [ 'inn' => $this->inn, ]; } - - public function createDtoFromResponse(Response $response): ComplianceScoreData - { - return ComplianceScoreData::from($response->json()); - } } diff --git a/src/Requests/Security/GetSubscriptionsRequest.php b/src/Requests/Security/GetSubscriptionsRequest.php index be6b1fe..3ee38c6 100644 --- a/src/Requests/Security/GetSubscriptionsRequest.php +++ b/src/Requests/Security/GetSubscriptionsRequest.php @@ -23,15 +23,15 @@ class GetSubscriptionsRequest extends Request return '/api/alfa-security/jp/v1/subscription-api/client/subscriptions'; } + public function createDtoFromResponse(Response $response): DataCollection + { + return SecuritySubscriptionData::collect($response->json('subscriptions') ?? [], DataCollection::class); + } + protected function defaultQuery(): array { return [ 'active' => $this->active, ]; } - - public function createDtoFromResponse(Response $response): DataCollection - { - return SecuritySubscriptionData::collect($response->json('subscriptions') ?? [], DataCollection::class); - } } diff --git a/src/Requests/SelfEmployed/CreateAgreementLinkRequest.php b/src/Requests/SelfEmployed/CreateAgreementLinkRequest.php index e50bb30..e4adf6a 100644 --- a/src/Requests/SelfEmployed/CreateAgreementLinkRequest.php +++ b/src/Requests/SelfEmployed/CreateAgreementLinkRequest.php @@ -27,13 +27,13 @@ class CreateAgreementLinkRequest extends Request implements HasBody return '/api/semp/v1/agreement-pages'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): AgreementLinkData { return AgreementLinkData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/SelfEmployed/CreatePayoutRequest.php b/src/Requests/SelfEmployed/CreatePayoutRequest.php index 36cdc41..17be45a 100644 --- a/src/Requests/SelfEmployed/CreatePayoutRequest.php +++ b/src/Requests/SelfEmployed/CreatePayoutRequest.php @@ -27,13 +27,13 @@ class CreatePayoutRequest extends Request implements HasBody return '/api/semp/v1/payouts/registries/with-selfemployed-check-status'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): PayoutResponseData { return PayoutResponseData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/SelfEmployed/GetTaxpayerStatusRequest.php b/src/Requests/SelfEmployed/GetTaxpayerStatusRequest.php index e3b9fa1..1935eaa 100644 --- a/src/Requests/SelfEmployed/GetTaxpayerStatusRequest.php +++ b/src/Requests/SelfEmployed/GetTaxpayerStatusRequest.php @@ -27,13 +27,13 @@ class GetTaxpayerStatusRequest extends Request implements HasBody return '/api/semp/v1/selfemployed/taxpayer-statuses'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): TaxpayerStatusResponseData { return TaxpayerStatusResponseData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/SelfEmployed/RegisterIncomeRequest.php b/src/Requests/SelfEmployed/RegisterIncomeRequest.php index 72f304f..f3df940 100644 --- a/src/Requests/SelfEmployed/RegisterIncomeRequest.php +++ b/src/Requests/SelfEmployed/RegisterIncomeRequest.php @@ -27,13 +27,13 @@ class RegisterIncomeRequest extends Request implements HasBody return '/semp/v1/selfemployed/income'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): CreateIncomeResponseData { return CreateIncomeResponseData::from($response->json()); } + + protected function defaultBody(): array + { + return $this->data->toArray(); + } } diff --git a/src/Requests/Statement/Formats/GetTransactions1CRequest.php b/src/Requests/Statement/Formats/GetTransactions1CRequest.php index 06aef7a..4b673f2 100644 --- a/src/Requests/Statement/Formats/GetTransactions1CRequest.php +++ b/src/Requests/Statement/Formats/GetTransactions1CRequest.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\Shared\DownloadedFileData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -45,6 +46,15 @@ class GetTransactions1CRequest extends Request } //
+ public function createDtoFromResponse(Response $response): DownloadedFileData + { + return DownloadedFileData::from([ + 'content' => $response->body(), + 'size' => strlen($response->body()), + ]); + } + //
+ //
// protected function defaultQuery(): array @@ -54,14 +64,5 @@ class GetTransactions1CRequest extends Request 'dateTo' => $this->dateTo, ]; } - //
- - public function createDtoFromResponse(Response $response): DownloadedFileData - { - return DownloadedFileData::from([ - 'content' => $response->body(), - 'size' => strlen($response->body()), - ]); - } } //
diff --git a/src/Requests/Statement/Formats/GetTransactionsMT940Request.php b/src/Requests/Statement/Formats/GetTransactionsMT940Request.php index e710814..370c53a 100644 --- a/src/Requests/Statement/Formats/GetTransactionsMT940Request.php +++ b/src/Requests/Statement/Formats/GetTransactionsMT940Request.php @@ -17,6 +17,7 @@ use Apoloz\AlfaBank\Data\Shared\DownloadedFileData; use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; + //
//
@@ -45,6 +46,15 @@ class GetTransactionsMT940Request extends Request } //
+ public function createDtoFromResponse(Response $response): DownloadedFileData + { + return DownloadedFileData::from([ + 'content' => $response->body(), + 'size' => strlen($response->body()), + ]); + } + //
+ //
// protected function defaultQuery(): array @@ -54,14 +64,5 @@ class GetTransactionsMT940Request extends Request 'dateTo' => $this->dateTo, ]; } - //
- - public function createDtoFromResponse(Response $response): DownloadedFileData - { - return DownloadedFileData::from([ - 'content' => $response->body(), - 'size' => strlen($response->body()), - ]); - } } //
diff --git a/src/Requests/Statement/GetTransactionsRequest.php b/src/Requests/Statement/GetTransactionsRequest.php index ad207b5..53e6dc4 100644 --- a/src/Requests/Statement/GetTransactionsRequest.php +++ b/src/Requests/Statement/GetTransactionsRequest.php @@ -40,6 +40,14 @@ class GetTransactionsRequest extends Request { return '/api/jp/v1/statement/transactions'; } + //
+ + //
+ // + public function createDtoFromResponse(Response $response): TransactionCollectionData + { + return TransactionCollectionData::from($response->json()); + } protected function defaultQuery(): array { @@ -50,12 +58,4 @@ class GetTransactionsRequest extends Request ], $this->getPaginationQuery()); } //
- - //
- // - public function createDtoFromResponse(Response $response): TransactionCollectionData - { - return TransactionCollectionData::from($response->json()); - } - //
} diff --git a/src/Requests/Webhooks/CreateWebhookRequest.php b/src/Requests/Webhooks/CreateWebhookRequest.php index 75a710c..8776215 100644 --- a/src/Requests/Webhooks/CreateWebhookRequest.php +++ b/src/Requests/Webhooks/CreateWebhookRequest.php @@ -27,13 +27,13 @@ class CreateWebhookRequest extends Request implements HasBody return '/api/v2/webhooks'; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): WebhookSubscriptionData { return WebhookSubscriptionData::from($response->json()); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Requests/Webhooks/DeleteWebhookRequest.php b/src/Requests/Webhooks/DeleteWebhookRequest.php index 7273a57..9de093a 100644 --- a/src/Requests/Webhooks/DeleteWebhookRequest.php +++ b/src/Requests/Webhooks/DeleteWebhookRequest.php @@ -28,4 +28,4 @@ class DeleteWebhookRequest extends Request 'success' => $response->status() === 204 || $response->successful(), ]); } -} \ No newline at end of file +} diff --git a/src/Requests/Webhooks/GetWebhookRequest.php b/src/Requests/Webhooks/GetWebhookRequest.php index 6dc571f..2b7cbe0 100644 --- a/src/Requests/Webhooks/GetWebhookRequest.php +++ b/src/Requests/Webhooks/GetWebhookRequest.php @@ -26,4 +26,4 @@ class GetWebhookRequest extends Request { return WebhookSubscriptionData::from($response->json()); } -} \ No newline at end of file +} diff --git a/src/Requests/Webhooks/GetWebhooksRequest.php b/src/Requests/Webhooks/GetWebhooksRequest.php index 573a0d3..f84a2ac 100644 --- a/src/Requests/Webhooks/GetWebhooksRequest.php +++ b/src/Requests/Webhooks/GetWebhooksRequest.php @@ -31,15 +31,15 @@ class GetWebhooksRequest extends Request return '/api/v2/webhooks'; } + public function createDtoFromResponse(Response $response): DataCollection + { + return WebhookSubscriptionData::collect($response->json(), DataCollection::class); + } + protected function defaultQuery(): array { return array_filter(array_merge([ 'object' => $this->object, ], $this->getPaginationQuery())); } - - public function createDtoFromResponse(Response $response): DataCollection - { - return WebhookSubscriptionData::collect($response->json(), DataCollection::class); - } } diff --git a/src/Requests/Webhooks/UpdateWebhookRequest.php b/src/Requests/Webhooks/UpdateWebhookRequest.php index 008d7f7..d248b30 100644 --- a/src/Requests/Webhooks/UpdateWebhookRequest.php +++ b/src/Requests/Webhooks/UpdateWebhookRequest.php @@ -28,13 +28,13 @@ class UpdateWebhookRequest extends Request implements HasBody return "/api/v2/webhooks/{$this->id}"; } - protected function defaultBody(): array - { - return $this->data->toArray(); - } - public function createDtoFromResponse(Response $response): WebhookSubscriptionData { return WebhookSubscriptionData::from($response->json()); } -} \ No newline at end of file + + protected function defaultBody(): array + { + return $this->data->toArray(); + } +} diff --git a/src/Sbp/Data/CashLink/ActivateCashQrRequestData.php b/src/Sbp/Data/CashLink/ActivateCashQrRequestData.php index 68e6aa3..36577bd 100644 --- a/src/Sbp/Data/CashLink/ActivateCashQrRequestData.php +++ b/src/Sbp/Data/CashLink/ActivateCashQrRequestData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/CashLink/RegCashQrRequestData.php b/src/Sbp/Data/CashLink/RegCashQrRequestData.php index d63fb40..450baef 100644 --- a/src/Sbp/Data/CashLink/RegCashQrRequestData.php +++ b/src/Sbp/Data/CashLink/RegCashQrRequestData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/CashLink/RegCashQrResponseData.php b/src/Sbp/Data/CashLink/RegCashQrResponseData.php index 9af2466..bcb4d37 100644 --- a/src/Sbp/Data/CashLink/RegCashQrResponseData.php +++ b/src/Sbp/Data/CashLink/RegCashQrResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrRequestData.php b/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrRequestData.php index 6c4e372..15e6258 100644 --- a/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrRequestData.php +++ b/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrRequestData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrResponseData.php b/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrResponseData.php index ffacdca..ea34f05 100644 --- a/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrResponseData.php +++ b/src/Sbp/Data/DigitalRuble/CashLink/ChangeAccForCashUniQrResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrRequestData.php b/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrRequestData.php index 0a45af4..3feecde 100644 --- a/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrRequestData.php +++ b/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrRequestData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrResponseData.php b/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrResponseData.php index bd0eb09..dfb1c75 100644 --- a/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrResponseData.php +++ b/src/Sbp/Data/DigitalRuble/CashLink/CreateCashUniQrResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusRequestData.php b/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusRequestData.php index 078765a..fba7fb0 100644 --- a/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusRequestData.php +++ b/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusRequestData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusResponseData.php b/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusResponseData.php index 48257ab..79a0ee9 100644 --- a/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusResponseData.php +++ b/src/Sbp/Data/DigitalRuble/CashLink/GetCashUniQrStatusResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/CreateUniQrRequestData.php b/src/Sbp/Data/DigitalRuble/CreateUniQrRequestData.php index c84e843..9c2c823 100644 --- a/src/Sbp/Data/DigitalRuble/CreateUniQrRequestData.php +++ b/src/Sbp/Data/DigitalRuble/CreateUniQrRequestData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/DigitalRuble/GetUniQrStatusResponseData.php b/src/Sbp/Data/DigitalRuble/GetUniQrStatusResponseData.php index abc94ff..df063b3 100644 --- a/src/Sbp/Data/DigitalRuble/GetUniQrStatusResponseData.php +++ b/src/Sbp/Data/DigitalRuble/GetUniQrStatusResponseData.php @@ -13,9 +13,12 @@ class GetUniQrStatusResponseData extends Data { #[MapName('ErrorCode')] public int $errorCode; + public string $message; + #[DataCollectionOf(UniQrStatusRecordData::class)] public DataCollection $data; // Renamed from 'data' to 'records' if it's always a collection of records. + public ?string $messageID = null; } @@ -23,10 +26,16 @@ class UniQrStatusRecordData extends Data { #[MapName('uniQrId')] public string $uniQrId; + public string $code; + public string $message; + public ?string $paymentServiceId = null; + public string $status; + public ?string $trxId = null; + public ?string $kzo = null; } diff --git a/src/Sbp/Data/DigitalRuble/Notifications/PaymentDrNotificationData.php b/src/Sbp/Data/DigitalRuble/Notifications/PaymentDrNotificationData.php index 3fff5c7..1fbb01b 100644 --- a/src/Sbp/Data/DigitalRuble/Notifications/PaymentDrNotificationData.php +++ b/src/Sbp/Data/DigitalRuble/Notifications/PaymentDrNotificationData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\Notifications; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Management/BlockQrRequestData.php b/src/Sbp/Data/Management/BlockQrRequestData.php index 9016bb4..ea1cf8b 100644 --- a/src/Sbp/Data/Management/BlockQrRequestData.php +++ b/src/Sbp/Data/Management/BlockQrRequestData.php @@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Management; // use Spatie\LaravelData\Attributes\MapName; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/QrCodeRequestData.php b/src/Sbp/Data/QrCodeRequestData.php index dd70903..6221b7b 100644 --- a/src/Sbp/Data/QrCodeRequestData.php +++ b/src/Sbp/Data/QrCodeRequestData.php @@ -14,9 +14,10 @@ namespace Apoloz\AlfaBank\Sbp\Data; //
// use Spatie\LaravelData\Attributes\MapName; -use Spatie\LaravelData\Attributes\MapOutputName; // Note: Not used directly here, but generally relevant for output mapping +// Note: Not used directly here, but generally relevant for output mapping use Spatie\LaravelData\Data; -use Spatie\LaravelData\Mappers\NameMapper; // Note: Not directly used, but part of the Spatie Data ecosystem + +// Note: Not directly used, but part of the Spatie Data ecosystem //
//
@@ -29,53 +30,53 @@ class QrCodeRequestData extends Data // #[MapName('TermNo')] public string $termNo, - + // #[MapName('qrcType')] // Although same name, good to be explicit - public string $qrcType = '01', - + public string $qrcType = '01', + // public ?string $amount = null, - + // public string $currency = 'RUB', - + // public ?string $paymentPurpose = null, - + // public ?string $redirectUrl = null, - + // public ?string $messageID = null, - + // public ?string $width = null, public ?string $height = null, - + // public ?string $notificationUrl = null, - + // Dynamic QR specific fields // #[MapName('OrderNumber')] public ?string $orderNumber = null, - + // - public ?string $qrTtl = null, - + public ?string $qrTtl = null, + // public ?string $subscriptionServiceId = null, public ?string $subscriptionServiceName = null, - + // Optional user data for Dynamic QR (often part of sender identification) // #[MapName('SenderFIO')] public ?string $senderFio = null, - + #[MapName('SenderID')] public ?string $senderId = null, - + #[MapName('SenderBankBIC')] public ?string $senderBankBic = null, ) {} diff --git a/src/Sbp/Data/QrCodeResponseData.php b/src/Sbp/Data/QrCodeResponseData.php index 381ab5d..f61f1ea 100644 --- a/src/Sbp/Data/QrCodeResponseData.php +++ b/src/Sbp/Data/QrCodeResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data; //
// use Spatie\LaravelData\Data; + //
//
@@ -35,4 +36,4 @@ class QrCodeResponseData extends Data ) {} //
} -//
\ No newline at end of file +//
diff --git a/src/Sbp/Data/Registry/GetBankListResponseData.php b/src/Sbp/Data/Registry/GetBankListResponseData.php index 56d9b91..50eb13c 100644 --- a/src/Sbp/Data/Registry/GetBankListResponseData.php +++ b/src/Sbp/Data/Registry/GetBankListResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Registry; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Reversal/GetQrcReversalDataRequestData.php b/src/Sbp/Data/Reversal/GetQrcReversalDataRequestData.php index cb8e29b..7900436 100644 --- a/src/Sbp/Data/Reversal/GetQrcReversalDataRequestData.php +++ b/src/Sbp/Data/Reversal/GetQrcReversalDataRequestData.php @@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal; // use Spatie\LaravelData\Attributes\MapName; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Reversal/GetQrcReversalDataResponseData.php b/src/Sbp/Data/Reversal/GetQrcReversalDataResponseData.php index 42f6959..4121bec 100644 --- a/src/Sbp/Data/Reversal/GetQrcReversalDataResponseData.php +++ b/src/Sbp/Data/Reversal/GetQrcReversalDataResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Reversal/GetQrcReversalStatusRequestData.php b/src/Sbp/Data/Reversal/GetQrcReversalStatusRequestData.php index a816c61..c7a34c9 100644 --- a/src/Sbp/Data/Reversal/GetQrcReversalStatusRequestData.php +++ b/src/Sbp/Data/Reversal/GetQrcReversalStatusRequestData.php @@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal; // use Spatie\LaravelData\Attributes\MapName; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Reversal/GetQrcReversalStatusResponseData.php b/src/Sbp/Data/Reversal/GetQrcReversalStatusResponseData.php index ff5ec3b..0ab2f21 100644 --- a/src/Sbp/Data/Reversal/GetQrcReversalStatusResponseData.php +++ b/src/Sbp/Data/Reversal/GetQrcReversalStatusResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Reversal/QrcReversalRequestData.php b/src/Sbp/Data/Reversal/QrcReversalRequestData.php index da3563e..450d6c0 100644 --- a/src/Sbp/Data/Reversal/QrcReversalRequestData.php +++ b/src/Sbp/Data/Reversal/QrcReversalRequestData.php @@ -13,10 +13,10 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal; //
// -use Spatie\LaravelData\Attributes\MapInputName; use Spatie\LaravelData\Attributes\MapName; use Spatie\LaravelData\Attributes\MapOutputName; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Reversal/QrcReversalResponseData.php b/src/Sbp/Data/Reversal/QrcReversalResponseData.php index cd1704c..e3b05a7 100644 --- a/src/Sbp/Data/Reversal/QrcReversalResponseData.php +++ b/src/Sbp/Data/Reversal/QrcReversalResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Status/GetQrcStatusRequestData.php b/src/Sbp/Data/Status/GetQrcStatusRequestData.php index 2327d28..56256ef 100644 --- a/src/Sbp/Data/Status/GetQrcStatusRequestData.php +++ b/src/Sbp/Data/Status/GetQrcStatusRequestData.php @@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Status; // use Spatie\LaravelData\Attributes\MapName; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Status/GetQrcStatusResponseData.php b/src/Sbp/Data/Status/GetQrcStatusResponseData.php index 1daa166..b19efac 100644 --- a/src/Sbp/Data/Status/GetQrcStatusResponseData.php +++ b/src/Sbp/Data/Status/GetQrcStatusResponseData.php @@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Status; //
// use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Data/Subscription/RegQrSubRequestData.php b/src/Sbp/Data/Subscription/RegQrSubRequestData.php index 25b338b..d5c1651 100644 --- a/src/Sbp/Data/Subscription/RegQrSubRequestData.php +++ b/src/Sbp/Data/Subscription/RegQrSubRequestData.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Subscription; use Spatie\LaravelData\Attributes\MapName; use Spatie\LaravelData\Attributes\MapOutputName; use Spatie\LaravelData\Data; + //
//
diff --git a/src/Sbp/Requests/CashLink/ActivateCashQrRequest.php b/src/Sbp/Requests/CashLink/ActivateCashQrRequest.php index 25c124b..a3df866 100644 --- a/src/Sbp/Requests/CashLink/ActivateCashQrRequest.php +++ b/src/Sbp/Requests/CashLink/ActivateCashQrRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -45,6 +46,14 @@ class ActivateCashQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): array + { + return $response->json(); + } + //
+ //
// protected function defaultBody(): array @@ -57,10 +66,18 @@ class ActivateCashQrRequest extends Request implements HasBody 'currency' => $this->data->currency, ]; - if ($this->data->OrderNumber !== null) $body['OrderNumber'] = $this->data->OrderNumber; - if ($this->data->paymentPurpose !== null) $body['paymentPurpose'] = $this->data->paymentPurpose; - if ($this->data->qrTtl !== null) $body['qrTtl'] = $this->data->qrTtl; - if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl; + if ($this->data->OrderNumber !== null) { + $body['OrderNumber'] = $this->data->OrderNumber; + } + if ($this->data->paymentPurpose !== null) { + $body['paymentPurpose'] = $this->data->paymentPurpose; + } + if ($this->data->qrTtl !== null) { + $body['qrTtl'] = $this->data->qrTtl; + } + if ($this->data->redirectUrl !== null) { + $body['redirectUrl'] = $this->data->redirectUrl; + } if ($this->data->notificationUrl !== null) { $body['queryData'] = ['notificationUrl' => $this->data->notificationUrl]; } @@ -68,12 +85,4 @@ class ActivateCashQrRequest extends Request implements HasBody return $body; } //
- - //
- // - public function createDtoFromResponse(Response $response): array - { - return $response->json(); - } - //
} diff --git a/src/Sbp/Requests/CashLink/ChangeAccountForCashQrRequest.php b/src/Sbp/Requests/CashLink/ChangeAccountForCashQrRequest.php index 0953458..4550117 100644 --- a/src/Sbp/Requests/CashLink/ChangeAccountForCashQrRequest.php +++ b/src/Sbp/Requests/CashLink/ChangeAccountForCashQrRequest.php @@ -51,6 +51,14 @@ class ChangeAccountForCashQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): array + { + return $response->json(); + } + //
+ //
// protected function defaultBody(): array @@ -62,19 +70,17 @@ class ChangeAccountForCashQrRequest extends Request implements HasBody 'account' => $this->account, ]; - if ($this->NewTermNo !== null) $body['NewTermNo'] = $this->NewTermNo; - if ($this->NewMerchantId !== null) $body['NewMerchantId'] = $this->NewMerchantId; - if ($this->redirectUrl !== null) $body['redirectUrl'] = $this->redirectUrl; + if ($this->NewTermNo !== null) { + $body['NewTermNo'] = $this->NewTermNo; + } + if ($this->NewMerchantId !== null) { + $body['NewMerchantId'] = $this->NewMerchantId; + } + if ($this->redirectUrl !== null) { + $body['redirectUrl'] = $this->redirectUrl; + } return $body; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): array - { - return $response->json(); - } - //
} diff --git a/src/Sbp/Requests/CashLink/ChangeTermNoForCashQrRequest.php b/src/Sbp/Requests/CashLink/ChangeTermNoForCashQrRequest.php index 43a1143..94910ca 100644 --- a/src/Sbp/Requests/CashLink/ChangeTermNoForCashQrRequest.php +++ b/src/Sbp/Requests/CashLink/ChangeTermNoForCashQrRequest.php @@ -47,6 +47,14 @@ class ChangeTermNoForCashQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): array + { + return $response->json(); + } + //
+ //
// protected function defaultBody(): array @@ -58,12 +66,4 @@ class ChangeTermNoForCashQrRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): array - { - return $response->json(); - } - //
} diff --git a/src/Sbp/Requests/CashLink/DeleteCashQrRequest.php b/src/Sbp/Requests/CashLink/DeleteCashQrRequest.php index 3d6dc04..116bcd7 100644 --- a/src/Sbp/Requests/CashLink/DeleteCashQrRequest.php +++ b/src/Sbp/Requests/CashLink/DeleteCashQrRequest.php @@ -47,6 +47,14 @@ class DeleteCashQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): array + { + return $response->json(); + } + //
+ //
// protected function defaultBody(): array @@ -58,12 +66,4 @@ class DeleteCashQrRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): array - { - return $response->json(); - } - //
} diff --git a/src/Sbp/Requests/CashLink/GetCashQrHistoryRequest.php b/src/Sbp/Requests/CashLink/GetCashQrHistoryRequest.php index 06e28e0..4f8f7d4 100644 --- a/src/Sbp/Requests/CashLink/GetCashQrHistoryRequest.php +++ b/src/Sbp/Requests/CashLink/GetCashQrHistoryRequest.php @@ -49,6 +49,14 @@ class GetCashQrHistoryRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): array + { + return $response->json(); + } + //
+ //
// protected function defaultBody(): array @@ -62,12 +70,4 @@ class GetCashQrHistoryRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): array - { - return $response->json(); - } - //
} diff --git a/src/Sbp/Requests/CashLink/GetCashQrStatusRequest.php b/src/Sbp/Requests/CashLink/GetCashQrStatusRequest.php index 0478ca8..f4fb889 100644 --- a/src/Sbp/Requests/CashLink/GetCashQrStatusRequest.php +++ b/src/Sbp/Requests/CashLink/GetCashQrStatusRequest.php @@ -47,6 +47,14 @@ class GetCashQrStatusRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): array + { + return $response->json(); + } + //
+ //
// protected function defaultBody(): array @@ -58,12 +66,4 @@ class GetCashQrStatusRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): array - { - return $response->json(); - } - //
} diff --git a/src/Sbp/Requests/CashLink/RegCashQrRequest.php b/src/Sbp/Requests/CashLink/RegCashQrRequest.php index ab4f977..2315d35 100644 --- a/src/Sbp/Requests/CashLink/RegCashQrRequest.php +++ b/src/Sbp/Requests/CashLink/RegCashQrRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class RegCashQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): RegCashQrResponseData + { + return RegCashQrResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -55,21 +64,23 @@ class RegCashQrRequest extends Request implements HasBody 'TermNo' => $this->data->TermNo, ]; - if ($this->data->mediaType !== null) $body['mediaType'] = $this->data->mediaType; - if ($this->data->width !== null) $body['width'] = $this->data->width; - if ($this->data->height !== null) $body['height'] = $this->data->height; - if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl; - if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId; + if ($this->data->mediaType !== null) { + $body['mediaType'] = $this->data->mediaType; + } + if ($this->data->width !== null) { + $body['width'] = $this->data->width; + } + if ($this->data->height !== null) { + $body['height'] = $this->data->height; + } + if ($this->data->redirectUrl !== null) { + $body['redirectUrl'] = $this->data->redirectUrl; + } + if ($this->data->qrcId !== null) { + $body['qrcId'] = $this->data->qrcId; + } return $body; } //
- - //
- // - public function createDtoFromResponse(Response $response): RegCashQrResponseData - { - return RegCashQrResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/DigitalRuble/CashLink/ChangeAccForCashUniQrRequest.php b/src/Sbp/Requests/DigitalRuble/CashLink/ChangeAccForCashUniQrRequest.php index fe1697a..635c216 100644 --- a/src/Sbp/Requests/DigitalRuble/CashLink/ChangeAccForCashUniQrRequest.php +++ b/src/Sbp/Requests/DigitalRuble/CashLink/ChangeAccForCashUniQrRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class ChangeAccForCashUniQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): ChangeAccForCashUniQrResponseData + { + return ChangeAccForCashUniQrResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -55,25 +64,35 @@ class ChangeAccForCashUniQrRequest extends Request implements HasBody 'TermNo' => $this->data->TermNo, ]; - if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID; - if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId; - if ($this->data->account !== null) $body['account'] = $this->data->account; - if ($this->data->accountDR !== null) $body['accountDR'] = $this->data->accountDR; - if ($this->data->NewTermNo !== null) $body['NewTermNo'] = $this->data->NewTermNo; - if ($this->data->NewMerchantId !== null) $body['NewMerchantId'] = $this->data->NewMerchantId; - if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl; - if ($this->data->paymentPageUrl !== null) $body['paymentPageUrl'] = $this->data->paymentPageUrl; - if ($this->data->fraudScore !== null) $body['fraudScore'] = $this->data->fraudScore; + if ($this->data->messageID !== null) { + $body['messageID'] = $this->data->messageID; + } + if ($this->data->qrcId !== null) { + $body['qrcId'] = $this->data->qrcId; + } + if ($this->data->account !== null) { + $body['account'] = $this->data->account; + } + if ($this->data->accountDR !== null) { + $body['accountDR'] = $this->data->accountDR; + } + if ($this->data->NewTermNo !== null) { + $body['NewTermNo'] = $this->data->NewTermNo; + } + if ($this->data->NewMerchantId !== null) { + $body['NewMerchantId'] = $this->data->NewMerchantId; + } + if ($this->data->redirectUrl !== null) { + $body['redirectUrl'] = $this->data->redirectUrl; + } + if ($this->data->paymentPageUrl !== null) { + $body['paymentPageUrl'] = $this->data->paymentPageUrl; + } + if ($this->data->fraudScore !== null) { + $body['fraudScore'] = $this->data->fraudScore; + } return $body; } //
- - //
- // - public function createDtoFromResponse(Response $response): ChangeAccForCashUniQrResponseData - { - return ChangeAccForCashUniQrResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/DigitalRuble/CashLink/CreateCashUniQrRequest.php b/src/Sbp/Requests/DigitalRuble/CashLink/CreateCashUniQrRequest.php index 5deda62..bc5d82b 100644 --- a/src/Sbp/Requests/DigitalRuble/CashLink/CreateCashUniQrRequest.php +++ b/src/Sbp/Requests/DigitalRuble/CashLink/CreateCashUniQrRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class CreateCashUniQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): CreateCashUniQrResponseData + { + return CreateCashUniQrResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -55,13 +64,27 @@ class CreateCashUniQrRequest extends Request implements HasBody 'TermNo' => $this->data->TermNo, ]; - if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID; - if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl; - if ($this->data->paymentPageUrl !== null) $body['paymentPageUrl'] = $this->data->paymentPageUrl; - if ($this->data->mediaType !== null) $body['mediaType'] = $this->data->mediaType; - if ($this->data->width !== null) $body['width'] = $this->data->width; - if ($this->data->height !== null) $body['height'] = $this->data->height; - if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId; + if ($this->data->messageID !== null) { + $body['messageID'] = $this->data->messageID; + } + if ($this->data->redirectUrl !== null) { + $body['redirectUrl'] = $this->data->redirectUrl; + } + if ($this->data->paymentPageUrl !== null) { + $body['paymentPageUrl'] = $this->data->paymentPageUrl; + } + if ($this->data->mediaType !== null) { + $body['mediaType'] = $this->data->mediaType; + } + if ($this->data->width !== null) { + $body['width'] = $this->data->width; + } + if ($this->data->height !== null) { + $body['height'] = $this->data->height; + } + if ($this->data->qrcId !== null) { + $body['qrcId'] = $this->data->qrcId; + } if ($this->data->notificationUrl !== null) { $body['queryData'] = ['notificationUrl' => $this->data->notificationUrl]; @@ -70,12 +93,4 @@ class CreateCashUniQrRequest extends Request implements HasBody return $body; } //
- - //
- // - public function createDtoFromResponse(Response $response): CreateCashUniQrResponseData - { - return CreateCashUniQrResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/DigitalRuble/CashLink/GetCashUniQrStatusRequest.php b/src/Sbp/Requests/DigitalRuble/CashLink/GetCashUniQrStatusRequest.php index 4f1f303..18f9d25 100644 --- a/src/Sbp/Requests/DigitalRuble/CashLink/GetCashUniQrStatusRequest.php +++ b/src/Sbp/Requests/DigitalRuble/CashLink/GetCashUniQrStatusRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class GetCashUniQrStatusRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): GetCashUniQrStatusResponseData + { + return GetCashUniQrStatusResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -57,18 +66,14 @@ class GetCashUniQrStatusRequest extends Request implements HasBody 'paramsId' => $this->data->paramsId, ]; - if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID; - if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn; + if ($this->data->messageID !== null) { + $body['messageID'] = $this->data->messageID; + } + if ($this->data->payrrn !== null) { + $body['payrrn'] = $this->data->payrrn; + } return $body; } //
- - //
- // - public function createDtoFromResponse(Response $response): GetCashUniQrStatusResponseData - { - return GetCashUniQrStatusResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php b/src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php index c46d887..9a24fdb 100644 --- a/src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php +++ b/src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php @@ -27,6 +27,11 @@ class CreateUniQrRequest extends Request implements HasBody return ''; } + public function createDtoFromResponse(Response $response): UniQrResponseData + { + return UniQrResponseData::from($response->json()); + } + protected function defaultBody(): array { $body = [ @@ -35,31 +40,52 @@ class CreateUniQrRequest extends Request implements HasBody 'uniQrType' => $this->data->uniQrType, ]; - if ($this->data->amount !== null) $body['amount'] = $this->data->amount; - if ($this->data->paymentPurpose !== null) $body['paymentPurpose'] = $this->data->paymentPurpose; - if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl; - if ($this->data->paymentPageUrl !== null) $body['paymentPageUrl'] = $this->data->paymentPageUrl; - if ($this->data->mediaType !== null) $body['mediaType'] = $this->data->mediaType; - if ($this->data->width !== null) $body['width'] = $this->data->width; - if ($this->data->height !== null) $body['height'] = $this->data->height; - if ($this->data->qrTtl !== null) $body['qrTtl'] = $this->data->qrTtl; - if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID; + if ($this->data->amount !== null) { + $body['amount'] = $this->data->amount; + } + if ($this->data->paymentPurpose !== null) { + $body['paymentPurpose'] = $this->data->paymentPurpose; + } + if ($this->data->redirectUrl !== null) { + $body['redirectUrl'] = $this->data->redirectUrl; + } + if ($this->data->paymentPageUrl !== null) { + $body['paymentPageUrl'] = $this->data->paymentPageUrl; + } + if ($this->data->mediaType !== null) { + $body['mediaType'] = $this->data->mediaType; + } + if ($this->data->width !== null) { + $body['width'] = $this->data->width; + } + if ($this->data->height !== null) { + $body['height'] = $this->data->height; + } + if ($this->data->qrTtl !== null) { + $body['qrTtl'] = $this->data->qrTtl; + } + if ($this->data->messageID !== null) { + $body['messageID'] = $this->data->messageID; + } $queryData = []; - if ($this->data->notificationUrl !== null) $queryData['notificationUrl'] = $this->data->notificationUrl; - if ($this->data->SenderFIO !== null) $queryData['SenderFIO'] = $this->data->SenderFIO; - if ($this->data->SenderID !== null) $queryData['SenderID'] = $this->data->SenderID; - if ($this->data->SenderBankBIC !== null) $queryData['SenderBankBIC'] = $this->data->SenderBankBIC; + if ($this->data->notificationUrl !== null) { + $queryData['notificationUrl'] = $this->data->notificationUrl; + } + if ($this->data->SenderFIO !== null) { + $queryData['SenderFIO'] = $this->data->SenderFIO; + } + if ($this->data->SenderID !== null) { + $queryData['SenderID'] = $this->data->SenderID; + } + if ($this->data->SenderBankBIC !== null) { + $queryData['SenderBankBIC'] = $this->data->SenderBankBIC; + } - if (!empty($queryData)) { + if (! empty($queryData)) { $body['queryData'] = $queryData; } return $body; } - - public function createDtoFromResponse(Response $response): UniQrResponseData - { - return UniQrResponseData::from($response->json()); - } -} \ No newline at end of file +} diff --git a/src/Sbp/Requests/DigitalRuble/GetUniQrStatusRequest.php b/src/Sbp/Requests/DigitalRuble/GetUniQrStatusRequest.php index 5d6f4b0..b4648ec 100644 --- a/src/Sbp/Requests/DigitalRuble/GetUniQrStatusRequest.php +++ b/src/Sbp/Requests/DigitalRuble/GetUniQrStatusRequest.php @@ -47,6 +47,14 @@ class GetUniQrStatusRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData + { + return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -58,12 +66,4 @@ class GetUniQrStatusRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData - { - return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/DigitalRuble/Notifications/ParsePaymentDrNotification.php b/src/Sbp/Requests/DigitalRuble/Notifications/ParsePaymentDrNotification.php index 9c47d78..bffe7d7 100644 --- a/src/Sbp/Requests/DigitalRuble/Notifications/ParsePaymentDrNotification.php +++ b/src/Sbp/Requests/DigitalRuble/Notifications/ParsePaymentDrNotification.php @@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Requests\DigitalRuble\Notifications; // use Apoloz\AlfaBank\Sbp\Data\DigitalRuble\Notifications\PaymentDrNotificationData; use Illuminate\Http\Request; // Assuming this is used to get the raw incoming data, not directly as a Saloon Request. + //
//
diff --git a/src/Sbp/Requests/GetQrCodeRequest.php b/src/Sbp/Requests/GetQrCodeRequest.php index f061e95..d6cdf7c 100644 --- a/src/Sbp/Requests/GetQrCodeRequest.php +++ b/src/Sbp/Requests/GetQrCodeRequest.php @@ -21,6 +21,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasStringBody; + //
//
@@ -49,6 +50,14 @@ class GetQrCodeRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): QrCodeResponseData + { + return QrCodeResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): string @@ -57,15 +66,8 @@ class GetQrCodeRequest extends Request implements HasBody ['command' => 'GetQRCd'], $this->data->toArray() ); + return CmsSigner::canonicalize($bodyArray); } //
- - //
- // - public function createDtoFromResponse(Response $response): QrCodeResponseData - { - return QrCodeResponseData::from($response->json()); - } - //
-} \ No newline at end of file +} diff --git a/src/Sbp/Requests/Management/BlockQrRequest.php b/src/Sbp/Requests/Management/BlockQrRequest.php index 4b6543b..9150ff1 100644 --- a/src/Sbp/Requests/Management/BlockQrRequest.php +++ b/src/Sbp/Requests/Management/BlockQrRequest.php @@ -47,6 +47,14 @@ class BlockQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData + { + return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -57,12 +65,4 @@ class BlockQrRequest extends Request implements HasBody ); } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData - { - return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Management/GetBlockedQrListRequest.php b/src/Sbp/Requests/Management/GetBlockedQrListRequest.php index a2a4a4f..3236afd 100644 --- a/src/Sbp/Requests/Management/GetBlockedQrListRequest.php +++ b/src/Sbp/Requests/Management/GetBlockedQrListRequest.php @@ -46,6 +46,14 @@ class GetBlockedQrListRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData + { + return \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -56,12 +64,4 @@ class GetBlockedQrListRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData - { - return \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Management/UnblockQrRequest.php b/src/Sbp/Requests/Management/UnblockQrRequest.php index f54293e..34039a2 100644 --- a/src/Sbp/Requests/Management/UnblockQrRequest.php +++ b/src/Sbp/Requests/Management/UnblockQrRequest.php @@ -47,6 +47,14 @@ class UnblockQrRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData + { + return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -57,12 +65,4 @@ class UnblockQrRequest extends Request implements HasBody ); } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData - { - return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Registry/GetBankListRequest.php b/src/Sbp/Requests/Registry/GetBankListRequest.php index e091085..9c6d5f6 100644 --- a/src/Sbp/Requests/Registry/GetBankListRequest.php +++ b/src/Sbp/Requests/Registry/GetBankListRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class GetBankListRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): GetBankListResponseData + { + return GetBankListResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -54,18 +63,14 @@ class GetBankListRequest extends Request implements HasBody 'command' => 'GetBankList', ]; - if ($this->messageID !== null) $body['messageID'] = $this->messageID; - if ($this->BankMemberIdFilter !== null) $body['BankMemberIdFilter'] = $this->BankMemberIdFilter; + if ($this->messageID !== null) { + $body['messageID'] = $this->messageID; + } + if ($this->BankMemberIdFilter !== null) { + $body['BankMemberIdFilter'] = $this->BankMemberIdFilter; + } return $body; } //
- - //
- // - public function createDtoFromResponse(Response $response): GetBankListResponseData - { - return GetBankListResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Reversal/GetQrcReversalDataRequest.php b/src/Sbp/Requests/Reversal/GetQrcReversalDataRequest.php index b1f666a..57d587f 100644 --- a/src/Sbp/Requests/Reversal/GetQrcReversalDataRequest.php +++ b/src/Sbp/Requests/Reversal/GetQrcReversalDataRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class GetQrcReversalDataRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): GetQrcReversalDataResponseData + { + return GetQrcReversalDataResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -56,12 +65,4 @@ class GetQrcReversalDataRequest extends Request implements HasBody ); } //
- - //
- // - public function createDtoFromResponse(Response $response): GetQrcReversalDataResponseData - { - return GetQrcReversalDataResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Reversal/GetQrcReversalHistoryRequest.php b/src/Sbp/Requests/Reversal/GetQrcReversalHistoryRequest.php index 719491b..1b25da1 100644 --- a/src/Sbp/Requests/Reversal/GetQrcReversalHistoryRequest.php +++ b/src/Sbp/Requests/Reversal/GetQrcReversalHistoryRequest.php @@ -27,6 +27,11 @@ class GetQrcReversalHistoryRequest extends Request implements HasBody return ''; } + public function createDtoFromResponse(Response $response): ReversalHistoryResponseData + { + return ReversalHistoryResponseData::from($response->json()); + } + protected function defaultBody(): array { return [ @@ -35,9 +40,4 @@ class GetQrcReversalHistoryRequest extends Request implements HasBody 'payrrn' => $this->payrrn, ]; } - - public function createDtoFromResponse(Response $response): ReversalHistoryResponseData - { - return ReversalHistoryResponseData::from($response->json()); - } } diff --git a/src/Sbp/Requests/Reversal/GetQrcReversalStatusRequest.php b/src/Sbp/Requests/Reversal/GetQrcReversalStatusRequest.php index bcf2358..bcd3d0f 100644 --- a/src/Sbp/Requests/Reversal/GetQrcReversalStatusRequest.php +++ b/src/Sbp/Requests/Reversal/GetQrcReversalStatusRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class GetQrcReversalStatusRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): GetQrcReversalStatusResponseData + { + return GetQrcReversalStatusResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -56,12 +65,4 @@ class GetQrcReversalStatusRequest extends Request implements HasBody ); } //
- - //
- // - public function createDtoFromResponse(Response $response): GetQrcReversalStatusResponseData - { - return GetQrcReversalStatusResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Reversal/QrcReversalRequest.php b/src/Sbp/Requests/Reversal/QrcReversalRequest.php index f699719..92847d9 100644 --- a/src/Sbp/Requests/Reversal/QrcReversalRequest.php +++ b/src/Sbp/Requests/Reversal/QrcReversalRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class QrcReversalRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): QrcReversalResponseData + { + return QrcReversalResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -56,12 +65,4 @@ class QrcReversalRequest extends Request implements HasBody ); } //
- - //
- // - public function createDtoFromResponse(Response $response): QrcReversalResponseData - { - return QrcReversalResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Status/GetQrcStatusRequest.php b/src/Sbp/Requests/Status/GetQrcStatusRequest.php index df3b6f9..353bd9f 100644 --- a/src/Sbp/Requests/Status/GetQrcStatusRequest.php +++ b/src/Sbp/Requests/Status/GetQrcStatusRequest.php @@ -19,6 +19,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -46,6 +47,14 @@ class GetQrcStatusRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): GetQrcStatusResponseData + { + return GetQrcStatusResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -56,12 +65,4 @@ class GetQrcStatusRequest extends Request implements HasBody ); } //
- - //
- // - public function createDtoFromResponse(Response $response): GetQrcStatusResponseData - { - return GetQrcStatusResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Subscription/GetQrSubStatusRequest.php b/src/Sbp/Requests/Subscription/GetQrSubStatusRequest.php index b162e39..74dd176 100644 --- a/src/Sbp/Requests/Subscription/GetQrSubStatusRequest.php +++ b/src/Sbp/Requests/Subscription/GetQrSubStatusRequest.php @@ -48,6 +48,14 @@ class GetQrSubStatusRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData + { + return \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -65,12 +73,4 @@ class GetQrSubStatusRequest extends Request implements HasBody return $body; } //
- - //
- // - public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData - { - return \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Subscription/QrcSubPayPetitionRequest.php b/src/Sbp/Requests/Subscription/QrcSubPayPetitionRequest.php index f314cb2..1dc5347 100644 --- a/src/Sbp/Requests/Subscription/QrcSubPayPetitionRequest.php +++ b/src/Sbp/Requests/Subscription/QrcSubPayPetitionRequest.php @@ -17,6 +17,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -47,6 +48,14 @@ class QrcSubPayPetitionRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData + { + return \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -60,12 +69,4 @@ class QrcSubPayPetitionRequest extends Request implements HasBody ]; } //
- - //
- // - public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData - { - return \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/Requests/Subscription/RegQrSubRequest.php b/src/Sbp/Requests/Subscription/RegQrSubRequest.php index 9f2cb7b..d352a36 100644 --- a/src/Sbp/Requests/Subscription/RegQrSubRequest.php +++ b/src/Sbp/Requests/Subscription/RegQrSubRequest.php @@ -18,6 +18,7 @@ use Saloon\Enums\Method; use Saloon\Http\Request; use Saloon\Http\Response; use Saloon\Traits\Body\HasJsonBody; + //
//
@@ -45,6 +46,14 @@ class RegQrSubRequest extends Request implements HasBody } //
+ //
+ // + public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData + { + return \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData::from($response->json()); + } + //
+ //
// protected function defaultBody(): array @@ -55,12 +64,4 @@ class RegQrSubRequest extends Request implements HasBody ); } //
- - //
- // - public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData - { - return \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData::from($response->json()); - } - //
} diff --git a/src/Sbp/SbpConnector.php b/src/Sbp/SbpConnector.php index ae2e08c..b633bac 100644 --- a/src/Sbp/SbpConnector.php +++ b/src/Sbp/SbpConnector.php @@ -15,15 +15,15 @@ use Saloon\Http\Request; use Saloon\PaginationPlugin\Contracts\HasPagination; use Saloon\PaginationPlugin\OffsetPaginator; use Saloon\Traits\Plugins\AlwaysThrowOnErrors; -use Saloon\Traits\RequestProperties\HasTries; use Saloon\Traits\Plugins\HasTimeout; +use Saloon\Traits\RequestProperties\HasTries; class SbpConnector extends Connector implements HasPagination { - use HasTimeout; - use HasTries; use AlwaysThrowOnErrors; use HasAlfaErrorHandling; + use HasTimeout; + use HasTries; public function __construct( protected AlfaConfig $alfaConfig, @@ -62,6 +62,56 @@ class SbpConnector extends Connector implements HasPagination return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\Notifications\PaymentDrNotificationData::from($data); } + public function boot(PendingRequest $pendingRequest): void + { + $bodyRepo = $pendingRequest->body(); + if (! $bodyRepo) { + return; + } + + // Get body as string (for HasStringBody requests) + $bodyString = $bodyRepo->all(); + if (is_array($bodyString)) { + // Fallback for array bodies (HasJsonBody) + $bodyString = CmsSigner::canonicalize($bodyString); + } + + // Sign the body using the configured private key (prefer signing key, fallback to transport key). + $keyPath = $this->alfaConfig->signingPrivateKeyPath ?: $this->alfaConfig->privateKeyPath; + + if (! file_exists($keyPath)) { + throw new \RuntimeException("Private key file not found: $keyPath"); + } + + $privateKey = openssl_pkey_get_private( + file_get_contents($keyPath) + ); + + if (! $privateKey) { + throw new \RuntimeException("Could not load private key for SBP signing from: $keyPath"); + } + + $signature = ''; + openssl_sign($bodyString, $signature, $privateKey, OPENSSL_ALGO_SHA256); + $signatureBase64 = base64_encode($signature); + + // Mutate the request to add SBP-specific headers. + $pendingRequest->headers()->add('Authorization', $signatureBase64); + $pendingRequest->headers()->add('key-name', $this->keyNameAlias); + } + + public function withCaBundle(string $path): static + { + $this->config()->merge(['verify' => $path]); + + return $this; + } + + public function paginate(Request $request): OffsetPaginator + { + return new AlfaOffsetPaginator($this, $request); + } + protected function defaultConfig(): array { $config = [ @@ -87,56 +137,7 @@ class SbpConnector extends Connector implements HasPagination protected function defaultMiddleware(): array { return [ - new RequestIdMiddleware(), + new RequestIdMiddleware, ]; } - - public function boot(PendingRequest $pendingRequest): void - { - $bodyRepo = $pendingRequest->body(); - if (!$bodyRepo) { - return; - } - - // Get body as string (for HasStringBody requests) - $bodyString = $bodyRepo->all(); - if (is_array($bodyString)) { - // Fallback for array bodies (HasJsonBody) - $bodyString = CmsSigner::canonicalize($bodyString); - } - - // Sign the body using the configured private key (prefer signing key, fallback to transport key). - $keyPath = $this->alfaConfig->signingPrivateKeyPath ?: $this->alfaConfig->privateKeyPath; - - if (!file_exists($keyPath)) { - throw new \RuntimeException("Private key file not found: $keyPath"); - } - - $privateKey = openssl_pkey_get_private( - file_get_contents($keyPath) - ); - - if (!$privateKey) { - throw new \RuntimeException("Could not load private key for SBP signing from: $keyPath"); - } - - $signature = ''; - openssl_sign($bodyString, $signature, $privateKey, OPENSSL_ALGO_SHA256); - $signatureBase64 = base64_encode($signature); - - // Mutate the request to add SBP-specific headers. - $pendingRequest->headers()->add('Authorization', $signatureBase64); - $pendingRequest->headers()->add('key-name', $this->keyNameAlias); - } - - public function withCaBundle(string $path): static - { - $this->config()->merge(['verify' => $path]); - return $this; - } - - public function paginate(Request $request): OffsetPaginator - { - return new AlfaOffsetPaginator($this, $request); - } -} \ No newline at end of file +} diff --git a/src/Services/H2HAuthService.php b/src/Services/H2HAuthService.php index ee20720..a9b8991 100644 --- a/src/Services/H2HAuthService.php +++ b/src/Services/H2HAuthService.php @@ -20,8 +20,8 @@ class H2HAuthService /** * Step 1: Generate the URL for the user to authorize via Alfa ID. * - * @param array $scopes List of scopes (e.g. ['beneficiaries', 'payment']) - * @param string|null $state Optional state parameter for CSRF protection + * @param array $scopes List of scopes (e.g. ['beneficiaries', 'payment']) + * @param string|null $state Optional state parameter for CSRF protection */ public function getAuthUrl(array $scopes = ['beneficiaries'], ?string $state = null): string { diff --git a/src/Services/OpenSslCmsSigner.php b/src/Services/OpenSslCmsSigner.php index 85e93f7..d0438c8 100644 --- a/src/Services/OpenSslCmsSigner.php +++ b/src/Services/OpenSslCmsSigner.php @@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Services; // use Apoloz\AlfaBank\Contracts\SignerInterface; use Apoloz\AlfaBank\Exceptions\SignerException; + //
//
@@ -34,12 +35,12 @@ class OpenSslCmsSigner implements SignerInterface public function sign(string $data): string { $privateKey = openssl_pkey_get_private(file_get_contents($this->privateKeyPath)); // assuming no passphrase for simplicity here - if (!$privateKey) { + if (! $privateKey) { throw new SignerException("Could not read private key for signing from {$this->privateKeyPath}."); } $cert = openssl_x509_read(file_get_contents($this->certificatePath)); - if (!$cert) { + if (! $cert) { throw new SignerException("Could not read certificate for signing from {$this->certificatePath}."); } @@ -57,10 +58,14 @@ class OpenSslCmsSigner implements SignerInterface PKCS7_BINARY | PKCS7_DETACHED ); - if (!$status) { - if (file_exists($inFile)) unlink($inFile); - if (file_exists($outFile)) unlink($outFile); - throw new SignerException("Signing failed: " . openssl_error_string()); + if (! $status) { + if (file_exists($inFile)) { + unlink($inFile); + } + if (file_exists($outFile)) { + unlink($outFile); + } + throw new SignerException('Signing failed: ' . openssl_error_string()); } $signedData = file_get_contents($outFile); @@ -69,7 +74,7 @@ class OpenSslCmsSigner implements SignerInterface $parts = explode("\n\n", $signedData); $signature = end($parts); - + return str_replace(["\n", "\r"], '', $signature); } //
diff --git a/src/Services/PhpseclibCardEncryptor.php b/src/Services/PhpseclibCardEncryptor.php index dafca78..a83c996 100644 --- a/src/Services/PhpseclibCardEncryptor.php +++ b/src/Services/PhpseclibCardEncryptor.php @@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Services; use Apoloz\AlfaBank\Contracts\EncryptorInterface; use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\RSA; + //
//
@@ -35,10 +36,10 @@ class PhpseclibCardEncryptor implements EncryptorInterface { /** @var RSA $key */ $key = PublicKeyLoader::load($this->publicKeyPem); - + $key = $key->withHash('sha256') - ->withMGFHash('sha1') // MGF1 with SHA1 is standard for banking - ->withPadding(RSA::ENCRYPTION_OAEP); + ->withMGFHash('sha1') // MGF1 with SHA1 is standard for banking + ->withPadding(RSA::ENCRYPTION_OAEP); return base64_encode($key->encrypt($data)); } diff --git a/src/Traits/HasAlfaErrorHandling.php b/src/Traits/HasAlfaErrorHandling.php index 8394a0a..12f8157 100644 --- a/src/Traits/HasAlfaErrorHandling.php +++ b/src/Traits/HasAlfaErrorHandling.php @@ -22,7 +22,7 @@ trait HasAlfaErrorHandling $contentType = $response->header('Content-Type') ?? ''; if (str_contains($contentType, 'application/json')) { $data = $response->json(); - if (isset($data['error']) || (isset($data['ErrorCode']) && (string)$data['ErrorCode'] !== '0')) { + if (isset($data['error']) || (isset($data['ErrorCode']) && (string) $data['ErrorCode'] !== '0')) { return true; } } @@ -50,8 +50,8 @@ trait HasAlfaErrorHandling } return new AlfaBankException( - $response, - (string)$errorCode, + $response, + (string) $errorCode, "({$requestId}) {$errorDescription}" ); } diff --git a/src/Traits/HasAlfaPagination.php b/src/Traits/HasAlfaPagination.php index dce8a72..db1f391 100644 --- a/src/Traits/HasAlfaPagination.php +++ b/src/Traits/HasAlfaPagination.php @@ -16,19 +16,20 @@ namespace Apoloz\AlfaBank\Traits; trait HasAlfaPagination { protected ?int $limit = 1000; + protected ?int $offset = 0; + public function getLimit(): ?int + { + return $this->limit; + } + protected function getPaginationQuery(): array { return array_filter([ 'limit' => $this->limit, 'offset' => $this->offset, - ], fn($v) => $v !== null); - } - - public function getLimit(): ?int - { - return $this->limit; + ], fn ($v) => $v !== null); } } //
diff --git a/src/Traits/SignableData.php b/src/Traits/SignableData.php index d22c663..5469193 100644 --- a/src/Traits/SignableData.php +++ b/src/Traits/SignableData.php @@ -14,7 +14,7 @@ trait SignableData { // 1. Create a clone to represent the data-to-be-signed (without existing signatures) $clone = clone $this; - + // We explicitly set digestSignatures to null or empty for the signature calculation // assuming the bank expects the "business payload" only. // If the bank expects the field "digestSignatures": [] to be present in signed string, @@ -40,7 +40,7 @@ trait SignableData // Safest way is to reconstruct it. $current = $this->digestSignatures->toCollection()->all(); $current[] = new DigestSignatureData($signature, 'cms'); - + $this->digestSignatures = new DataCollection(DigestSignatureData::class, $current); return $this; diff --git a/src/Utils/CardEncryptor.php b/src/Utils/CardEncryptor.php index 27d5558..0983ca5 100644 --- a/src/Utils/CardEncryptor.php +++ b/src/Utils/CardEncryptor.php @@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Utils; // use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\RSA; + //
//
@@ -24,7 +25,7 @@ class CardEncryptor /** * Encrypts a card PAN using RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING * as required by Alfa Bank for payouts to cards. - * + * * Requires phpseclib3/phpseclib. */ //
@@ -33,7 +34,7 @@ class CardEncryptor { /** @var RSA $publicKey */ $publicKey = PublicKeyLoader::load($publicKeyPem); - + $algo = $publicKey ->withPadding(RSA::ENCRYPTION_OAEP) ->withHash('sha256') diff --git a/src/Utils/CmsSigner.php b/src/Utils/CmsSigner.php index 8eb11f5..147940d 100644 --- a/src/Utils/CmsSigner.php +++ b/src/Utils/CmsSigner.php @@ -18,11 +18,13 @@ class CmsSigner /** * Signs data using PKCS#7 (CMS) as required by Alfa Bank. * - * @param string $data The JSON string to sign (should be canonicalized). - * @param string $certificatePem The content of the X.509 certificate. - * @param string $privateKeyPem The content of the private key. - * @param string|null $passphrase Private key passphrase. + * @param string $data The JSON string to sign (should be canonicalized). + * @param string $certificatePem The content of the X.509 certificate. + * @param string $privateKeyPem The content of the private key. + * @param string|null $passphrase Private key passphrase. + * * @return string Base64 encoded PKCS#7 signature. + * * @throws \Exception */ //
@@ -30,13 +32,13 @@ class CmsSigner public static function sign(string $data, string $certificatePem, string $privateKeyPem, ?string $passphrase = null): string { $privateKey = openssl_pkey_get_private($privateKeyPem, $passphrase ?? ''); - if (!$privateKey) { - throw new \Exception("Could not read private key for signing."); + if (! $privateKey) { + throw new \Exception('Could not read private key for signing.'); } $cert = openssl_x509_read($certificatePem); - if (!$cert) { - throw new \Exception("Could not read certificate for signing."); + if (! $cert) { + throw new \Exception('Could not read certificate for signing.'); } $inFile = tempnam(sys_get_temp_dir(), 'alfa_in'); @@ -55,10 +57,10 @@ class CmsSigner PKCS7_BINARY | PKCS7_DETACHED // Usually bank expects detached signature value in base64 ); - if (!$status) { + if (! $status) { unlink($inFile); unlink($outFile); - throw new \Exception("Encryption failed: " . openssl_error_string()); + throw new \Exception('Encryption failed: ' . openssl_error_string()); } $signedData = file_get_contents($outFile); @@ -68,7 +70,7 @@ class CmsSigner // Extract the base64 part from the PEM/SMIME block $parts = explode("\n\n", $signedData); $signature = end($parts); - + return str_replace(["\n", "\r"], '', $signature); } //
@@ -82,6 +84,7 @@ class CmsSigner public static function canonicalize(array $data): string { self::recursiveSort($data); + return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } //
@@ -105,7 +108,10 @@ class CmsSigner // private static function isAssoc(array $arr): bool { - if ([] === $arr) return false; + if ($arr === []) { + return false; + } + return array_keys($arr) !== range(0, count($arr) - 1); } //
diff --git a/src/Utils/JweEncryptor.php b/src/Utils/JweEncryptor.php index e50c0c4..1f341f3 100644 --- a/src/Utils/JweEncryptor.php +++ b/src/Utils/JweEncryptor.php @@ -13,9 +13,10 @@ namespace Apoloz\AlfaBank\Utils; //
// -use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\Random; +use phpseclib3\Crypt\RSA; + //
//
@@ -88,9 +89,11 @@ class JweEncryptor /** @var RSA $privateKey */ $privateKey = PublicKeyLoader::load($privateKeyPem, $passphrase ?? ''); $privateKey = $privateKey->withHash('sha256')->withMGFHash('sha256')->withPadding(RSA::ENCRYPTION_OAEP); - + $cek = $privateKey->decrypt(JwsSigner::base64UrlDecode($base64EncKey)); - if (!$cek) return null; + if (! $cek) { + return null; + } // 2. Decrypt Ciphertext $decrypted = openssl_decrypt( diff --git a/src/Utils/JwsSigner.php b/src/Utils/JwsSigner.php index cbcab5f..fd20b44 100644 --- a/src/Utils/JwsSigner.php +++ b/src/Utils/JwsSigner.php @@ -13,8 +13,9 @@ namespace Apoloz\AlfaBank\Utils; //
// -use phpseclib3\Crypt\RSA; use phpseclib3\Crypt\PublicKeyLoader; +use phpseclib3\Crypt\RSA; + //
//
diff --git a/src/Utils/Uuid.php b/src/Utils/Uuid.php index 134ab2f..762c383 100644 --- a/src/Utils/Uuid.php +++ b/src/Utils/Uuid.php @@ -10,8 +10,8 @@ class Uuid { $data = random_bytes(16); - $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 - $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 + $data[6] = chr(ord($data[6]) & 0x0F | 0x40); // set version to 0100 + $data[8] = chr(ord($data[8]) & 0x3F | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } diff --git a/src/Webhooks/WebhookFactory.php b/src/Webhooks/WebhookFactory.php index 0a1cba5..61b0124 100644 --- a/src/Webhooks/WebhookFactory.php +++ b/src/Webhooks/WebhookFactory.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Apoloz\AlfaBank\Webhooks; -use Apoloz\AlfaBank\Data\Webhooks\Payloads\BaseWebhookData; use Apoloz\AlfaBank\Data\Webhooks\Payloads\BaasWebhookData; +use Apoloz\AlfaBank\Data\Webhooks\Payloads\BaseWebhookData; use Apoloz\AlfaBank\Data\Webhooks\Payloads\SbpWebhookData; class WebhookFactory @@ -35,12 +35,14 @@ class WebhookFactory public static function isSbp(array $payload): bool { $target = array_is_list($payload) ? ($payload[0] ?? []) : $payload; + return ($target['object'] ?? '') === 'jp_sbp_incoming_payments'; } public static function isBaas(array $payload): bool { $target = array_is_list($payload) ? ($payload[0] ?? []) : $payload; + return ($target['object'] ?? '') === 'ul_transaction_default'; } } diff --git a/tests/Feature/Accounts/AccountTest.php b/tests/Feature/Accounts/AccountTest.php index 1054dfe..d5a911b 100644 --- a/tests/Feature/Accounts/AccountTest.php +++ b/tests/Feature/Accounts/AccountTest.php @@ -1,11 +1,10 @@ MockResponse::make([ 'accounts' => [ @@ -13,9 +12,9 @@ test('can get accounts list', function () { 'number' => '40702810...', 'openDate' => '2023-01-01', 'type' => 'Checking', - 'balance' => ['amount' => 1000] - ] - ] + 'balance' => ['amount' => 1000], + ], + ], ], 200, ['Content-Type' => 'application/json']), ]); @@ -23,7 +22,7 @@ test('can get accounts list', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetAccountsRequest()); + $response = $connector->send(new GetAccountsRequest); expect($response->status())->toBe(200) ->and($response->dto()->count())->toBe(1) diff --git a/tests/Feature/AdvancedModulesTest.php b/tests/Feature/AdvancedModulesTest.php index 3a1c9d6..eae3ece 100644 --- a/tests/Feature/AdvancedModulesTest.php +++ b/tests/Feature/AdvancedModulesTest.php @@ -6,7 +6,7 @@ use Apoloz\AlfaBank\Requests\Claims\ResolveClaimRequest; use Apoloz\AlfaBank\Requests\Logistics\ExecuteOrderActionRequest; use Saloon\Http\Faking\MockResponse; -test('can check 1c merchant', function () { +test('can check 1c merchant', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CheckMerchantRequest::class => MockResponse::make([], 200), ]); @@ -20,7 +20,7 @@ test('can check 1c merchant', function () { expect($response->status())->toBe(200); }); -test('can resolve claim', function () { +test('can resolve claim', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ ResolveClaimRequest::class => MockResponse::make([], 200), ]); @@ -34,7 +34,7 @@ test('can resolve claim', function () { expect($response->status())->toBe(200); }); -test('can execute logistics action', function () { +test('can execute logistics action', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ ExecuteOrderActionRequest::class => MockResponse::make([], 200), ]); @@ -43,7 +43,7 @@ test('can execute logistics action', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new ExecuteOrderActionRequest(1, 2, 'ORDER-1', 'deliver', new \Apoloz\AlfaBank\Data\Logistics\LogisticsActionData())); + $response = $connector->send(new ExecuteOrderActionRequest(1, 2, 'ORDER-1', 'deliver', new \Apoloz\AlfaBank\Data\Logistics\LogisticsActionData)); expect($response->status())->toBe(200); }); diff --git a/tests/Feature/AffIntegrationTest.php b/tests/Feature/AffIntegrationTest.php index 36ed3d0..7064c8c 100644 --- a/tests/Feature/AffIntegrationTest.php +++ b/tests/Feature/AffIntegrationTest.php @@ -5,7 +5,7 @@ use Apoloz\AlfaBank\Requests\Aff\CheckComplianceRequest; use Apoloz\AlfaBank\Requests\Aff\CreateRegisterRequest; use Saloon\Http\Faking\MockResponse; -test('can check aff compliance', function () { +test('can check aff compliance', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CheckComplianceRequest::class => MockResponse::make(['status' => 'APPROVED'], 200), ]); @@ -19,7 +19,7 @@ test('can check aff compliance', function () { expect($response->status())->toBe(200); }); -test('can create aff register', function () { +test('can create aff register', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateRegisterRequest::class => MockResponse::make(['id' => 'AFF-123'], 200), ]); diff --git a/tests/Feature/Auth/AuthenticationTest.php b/tests/Feature/Auth/AuthenticationTest.php index 475ae83..6e9caf8 100644 --- a/tests/Feature/Auth/AuthenticationTest.php +++ b/tests/Feature/Auth/AuthenticationTest.php @@ -6,7 +6,7 @@ use Saloon\Http\Faking\MockResponse; use Saloon\Http\OAuth2\GetAccessTokenRequest; use Saloon\Http\OAuth2\GetRefreshTokenRequest; -test('can generate authorization url', function () { +test('can generate authorization url', function (): void { $config = new AlfaConfig( baseUrl: 'https://sandbox.alfabank.ru', certificatePath: __DIR__ . '/../../test_key.pem', @@ -25,7 +25,7 @@ test('can generate authorization url', function () { ->toContain('scope=beneficiaries'); }); -test('can exchange code for token', function () { +test('can exchange code for token', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetAccessTokenRequest::class => MockResponse::make([ 'access_token' => 'new-access-token', @@ -52,7 +52,7 @@ test('can exchange code for token', function () { ->and($authenticator->getRefreshToken())->toBe('new-refresh-token'); }); -test('can refresh token', function () { +test('can refresh token', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetRefreshTokenRequest::class => MockResponse::make([ 'access_token' => 'refreshed-access-token', @@ -78,7 +78,7 @@ test('can refresh token', function () { ->and($authenticator->getRefreshToken())->toBe('refreshed-refresh-token'); }); -test('can login with client credentials', function () { +test('can login with client credentials', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ \Saloon\Http\OAuth2\GetClientCredentialsTokenRequest::class => MockResponse::make([ 'access_token' => 'cc-access-token', @@ -102,4 +102,3 @@ test('can login with client credentials', function () { expect($connector->getAuthenticator())->not->toBeNull() ->and($connector->getAuthenticator()->getAccessToken())->toBe('cc-access-token'); }); - diff --git a/tests/Feature/Auth/UserInfoTest.php b/tests/Feature/Auth/UserInfoTest.php index 102da0c..821d805 100644 --- a/tests/Feature/Auth/UserInfoTest.php +++ b/tests/Feature/Auth/UserInfoTest.php @@ -1,11 +1,10 @@ 'none'])); $payload = base64_encode(json_encode(['sub' => 'user-123', 'name' => 'John Doe'])); @@ -20,7 +19,7 @@ test('can get user info from JWT', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetUserInfoRequest()); + $response = $connector->send(new GetUserInfoRequest); expect($response->status())->toBe(200) ->and($response->dto()->sub)->toBe('user-123') diff --git a/tests/Feature/B2C/B2CPaymentTest.php b/tests/Feature/B2C/B2CPaymentTest.php index ae986e4..90afb4c 100644 --- a/tests/Feature/B2C/B2CPaymentTest.php +++ b/tests/Feature/B2C/B2CPaymentTest.php @@ -9,10 +9,10 @@ use Apoloz\AlfaBank\Requests\B2C\GetB2CPaymentReportRequest; use Saloon\Http\Faking\MockResponse; use Spatie\LaravelData\DataCollection; -test('can create b2c sbp payout', function () { +test('can create b2c sbp payout', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateB2CPaymentRequest::class => MockResponse::make([ - 'status' => 'SUCCESS' + 'status' => 'SUCCESS', ], 200, ['Content-Type' => 'application/json']), ]); @@ -32,8 +32,8 @@ test('can create b2c sbp payout', function () { 'amount' => 100.53, 'nspkBankId' => '100000000001', 'sequence' => 'seq-1', - 'name' => ['first' => 'Ivan', 'last' => 'Ivanov'] - ] + 'name' => ['first' => 'Ivan', 'last' => 'Ivanov'], + ], ], DataCollection::class) ); @@ -42,10 +42,10 @@ test('can create b2c sbp payout', function () { expect($response->status())->toBe(200); }); -test('can get b2c payment report', function () { +test('can get b2c payment report', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetB2CPaymentReportRequest::class => MockResponse::make([ - 'payments' => [] + 'payments' => [], ], 200, ['Content-Type' => 'application/json']), ]); @@ -58,11 +58,11 @@ test('can get b2c payment report', function () { expect($response->status())->toBe(200); }); -test('can get b2c package status', function () { +test('can get b2c package status', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ \Apoloz\AlfaBank\Requests\B2C\GetB2CPackageStatusRequest::class => \Saloon\Http\Faking\MockResponse::make([ 'packageId' => 'pkg-123', - 'status' => 'COMPLETED' + 'status' => 'COMPLETED', ], 200), ]); @@ -76,4 +76,3 @@ test('can get b2c package status', function () { expect($response->status())->toBe(200) ->and($response->json('status'))->toBe('COMPLETED'); }); - diff --git a/tests/Feature/Cards/CardTest.php b/tests/Feature/Cards/CardTest.php index 0a0b6da..1bb7fb0 100644 --- a/tests/Feature/Cards/CardTest.php +++ b/tests/Feature/Cards/CardTest.php @@ -1,11 +1,10 @@ MockResponse::make([ 'cards' => [ @@ -14,9 +13,9 @@ test('can get cards list', function () { 'maskedNumber' => '5555****4444', 'status' => 'ACTIVE', 'expirationDate' => '12/25', - 'paymentSystem' => 'MasterCard' - ] - ] + 'paymentSystem' => 'MasterCard', + ], + ], ], 200, ['Content-Type' => 'application/json']), ]); @@ -24,7 +23,7 @@ test('can get cards list', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetCardsRequest()); + $response = $connector->send(new GetCardsRequest); expect($response->status())->toBe(200) ->and($response->dto()->count())->toBe(1) diff --git a/tests/Feature/CloudSignature/CloudSignatureTest.php b/tests/Feature/CloudSignature/CloudSignatureTest.php index a0557e9..a1044f2 100644 --- a/tests/Feature/CloudSignature/CloudSignatureTest.php +++ b/tests/Feature/CloudSignature/CloudSignatureTest.php @@ -1,13 +1,13 @@ MockResponse::make(['dn' => 'CN=Test'], 200), ]); @@ -16,12 +16,12 @@ test('can get user dn', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetDnRequest()); + $response = $connector->send(new GetDnRequest); expect($response->status())->toBe(200); }); -test('can request rsa certificate issue', function () { +test('can request rsa certificate issue', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ IssueRsaCertificateRequest::class => MockResponse::make(['id' => 'ISSUE-1'], 200), ]); @@ -35,7 +35,7 @@ test('can request rsa certificate issue', function () { expect($response->status())->toBe(200); }); -test('can submit signing request', function () { +test('can submit signing request', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ SubmitSigningRequest::class => MockResponse::make(['operationId' => 'OP-1'], 200), ]); @@ -49,7 +49,7 @@ test('can submit signing request', function () { expect($response->status())->toBe(200); }); -test('can confirm signing with sms', function () { +test('can confirm signing with sms', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ ConfirmSigningWithSmsRequest::class => MockResponse::make([], 200), ]); diff --git a/tests/Feature/CustomerInfo/CustomerInfoTest.php b/tests/Feature/CustomerInfo/CustomerInfoTest.php index 3157896..d97e9d3 100644 --- a/tests/Feature/CustomerInfo/CustomerInfoTest.php +++ b/tests/Feature/CustomerInfo/CustomerInfoTest.php @@ -4,7 +4,7 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Requests\CustomerInfo\GetCustomerInfoRequest; use Saloon\Http\Faking\MockResponse; -test('can get customer info', function () { +test('can get customer info', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetCustomerInfoRequest::class => MockResponse::make([ 'organizationId' => 'org-123', @@ -12,7 +12,7 @@ test('can get customer info', function () { 'shortName' => 'Romashka', 'inn' => '1234567890', 'kpps' => ['123456789'], - 'ogrn' => '1234567890123' + 'ogrn' => '1234567890123', ], 200), ]); @@ -20,7 +20,7 @@ test('can get customer info', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetCustomerInfoRequest()); + $response = $connector->send(new GetCustomerInfoRequest); expect($response->status())->toBe(200) ->and($response->dto()->organizationId)->toBe('org-123') diff --git a/tests/Feature/ErrorHandlingTest.php b/tests/Feature/ErrorHandlingTest.php index 763eac8..8a6cc9c 100644 --- a/tests/Feature/ErrorHandlingTest.php +++ b/tests/Feature/ErrorHandlingTest.php @@ -1,16 +1,15 @@ MockResponse::make([ 'error' => 'invalid_client', - 'error_description' => 'Bad client secret' + 'error_description' => 'Bad client secret', ], 401, ['Content-Type' => 'application/json']), ]); @@ -21,11 +20,11 @@ test('it throws AlfaBankException on BaaS error', function () { $connector->login('id', 'secret'); })->throws(AlfaBankException::class, 'Alfa Bank API Error: [invalid_client] (Unknown) Bad client secret'); -test('it throws AlfaBankException on SBP error', function () { +test('it throws AlfaBankException on SBP error', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ '*' => MockResponse::make([ 'ErrorCode' => 'RQ05014', - 'message' => 'Invalid amount' + 'message' => 'Invalid amount', ], 200, ['Content-Type' => 'application/json']), // SBP often returns 200 even on errors ]); @@ -33,8 +32,13 @@ test('it throws AlfaBankException on SBP error', function () { $connector = new \Apoloz\AlfaBank\Sbp\SbpConnector($config, 'alias'); $connector->withMockClient($mockClient); - $connector->send(new class extends \Saloon\Http\Request { + $connector->send(new class extends \Saloon\Http\Request + { protected \Saloon\Enums\Method $method = \Saloon\Enums\Method::GET; - public function resolveEndpoint(): string { return '/'; } + + public function resolveEndpoint(): string + { + return '/'; + } }); })->throws(AlfaBankException::class, 'Alfa Bank API Error: [RQ05014] (Unknown) Invalid amount'); diff --git a/tests/Feature/Escrow/EscrowTest.php b/tests/Feature/Escrow/EscrowTest.php index 7d46b21..8367214 100644 --- a/tests/Feature/Escrow/EscrowTest.php +++ b/tests/Feature/Escrow/EscrowTest.php @@ -5,10 +5,10 @@ use Apoloz\AlfaBank\Requests\Escrow\GetBuildProjectsRequest; use Apoloz\AlfaBank\Requests\Escrow\GetEscrowOrdersRequest; use Saloon\Http\Faking\MockResponse; -test('can get build projects', function () { +test('can get build projects', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetBuildProjectsRequest::class => MockResponse::make([ - ['projectNumber' => '123', 'commercialName' => 'ЖК Тест'] + ['projectNumber' => '123', 'commercialName' => 'ЖК Тест'], ], 200), ]); @@ -16,17 +16,17 @@ test('can get build projects', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetBuildProjectsRequest()); + $response = $connector->send(new GetBuildProjectsRequest); expect($response->status())->toBe(200) ->and($response->json())->toBeArray() ->and($response->json('0.projectNumber'))->toBe('123'); }); -test('can get escrow orders', function () { +test('can get escrow orders', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetEscrowOrdersRequest::class => MockResponse::make([ - 'orders' => [] + 'orders' => [], ], 200), ]); diff --git a/tests/Feature/FileExchangeTest.php b/tests/Feature/FileExchangeTest.php index fe6500c..c303980 100644 --- a/tests/Feature/FileExchangeTest.php +++ b/tests/Feature/FileExchangeTest.php @@ -2,11 +2,11 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; -use Apoloz\AlfaBank\Requests\FileExchange\UploadFileRequest; use Apoloz\AlfaBank\Requests\FileExchange\DownloadFileRequest; +use Apoloz\AlfaBank\Requests\FileExchange\UploadFileRequest; use Saloon\Http\Faking\MockResponse; -test('can upload a file', function () { +test('can upload a file', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ '*' => MockResponse::make([], 200), ]); @@ -30,7 +30,7 @@ test('can upload a file', function () { fclose($stream); }); -test('can download a file', function () { +test('can download a file', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ '*' => MockResponse::make('file content', 200), ]); diff --git a/tests/Feature/LogisticsTest.php b/tests/Feature/LogisticsTest.php index e03a0d5..f25dd10 100644 --- a/tests/Feature/LogisticsTest.php +++ b/tests/Feature/LogisticsTest.php @@ -4,7 +4,7 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Requests\Logistics\GetDeliveriesRequest; use Saloon\Http\Faking\MockResponse; -test('can get deliveries', function () { +test('can get deliveries', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetDeliveriesRequest::class => MockResponse::make(['deliveries' => []], 200), ]); diff --git a/tests/Feature/Loyalty/LoyaltyTest.php b/tests/Feature/Loyalty/LoyaltyTest.php index 8ac9177..0055d05 100644 --- a/tests/Feature/Loyalty/LoyaltyTest.php +++ b/tests/Feature/Loyalty/LoyaltyTest.php @@ -5,7 +5,7 @@ use Apoloz\AlfaBank\Requests\Loyalty\GetLoyaltyAccountsRequest; use Apoloz\AlfaBank\Requests\Loyalty\GetLoyaltyTransactionsRequest; use Saloon\Http\Faking\MockResponse; -test('can get loyalty accounts', function () { +test('can get loyalty accounts', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetLoyaltyAccountsRequest::class => MockResponse::make(['accounts' => []], 200), ]); @@ -14,12 +14,12 @@ test('can get loyalty accounts', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetLoyaltyAccountsRequest()); + $response = $connector->send(new GetLoyaltyAccountsRequest); expect($response->status())->toBe(200); }); -test('can get loyalty transactions', function () { +test('can get loyalty transactions', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetLoyaltyTransactionsRequest::class => MockResponse::make(['transactions' => []], 200), ]); diff --git a/tests/Feature/MiscellaneousTest.php b/tests/Feature/MiscellaneousTest.php index a6e990b..d2d0ae8 100644 --- a/tests/Feature/MiscellaneousTest.php +++ b/tests/Feature/MiscellaneousTest.php @@ -6,7 +6,7 @@ use Apoloz\AlfaBank\Requests\Loans\GetCreditOffersRequest; use Apoloz\AlfaBank\Requests\Registries\CreateSelfEncashmentRegistryRequest; use Saloon\Http\Faking\MockResponse; -test('can get bonus numbers', function () { +test('can get bonus numbers', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetBonusNumbersRequest::class => MockResponse::make(['bonusNumbers' => []], 200), ]); @@ -15,12 +15,12 @@ test('can get bonus numbers', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetBonusNumbersRequest()); + $response = $connector->send(new GetBonusNumbersRequest); expect($response->status())->toBe(200); }); -test('can get credit offers', function () { +test('can get credit offers', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetCreditOffersRequest::class => MockResponse::make(['offers' => []], 200), ]); @@ -29,12 +29,12 @@ test('can get credit offers', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetCreditOffersRequest()); + $response = $connector->send(new GetCreditOffersRequest); expect($response->status())->toBe(200); }); -test('can create self-encashment registry', function () { +test('can create self-encashment registry', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateSelfEncashmentRegistryRequest::class => MockResponse::make([], 201), ]); diff --git a/tests/Feature/NominalAccounts/BeneficiariesTest.php b/tests/Feature/NominalAccounts/BeneficiariesTest.php index 6f38903..722aed8 100644 --- a/tests/Feature/NominalAccounts/BeneficiariesTest.php +++ b/tests/Feature/NominalAccounts/BeneficiariesTest.php @@ -2,20 +2,18 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; -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 Spatie\LaravelData\DataCollection; -use Saloon\Http\Faking\MockResponse; - +use Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries\CreateBeneficiaryRequestData; +use Apoloz\AlfaBank\Requests\NominalAccounts\Beneficiaries\CreateBeneficiaryRequest; use Apoloz\AlfaBank\Services\OpenSslCmsSigner; +use Saloon\Http\Faking\MockResponse; +use Spatie\LaravelData\DataCollection; -test('can create a beneficiary with automatic signing', function () { +test('can create a beneficiary with automatic signing', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateBeneficiaryRequest::class => MockResponse::make([ 'requestId' => 'req-123', - 'status' => 'PENDING' + 'status' => 'PENDING', ], 202), ]); @@ -26,7 +24,7 @@ test('can create a beneficiary with automatic signing', function () { ); // Mock signer to avoid real openssl calls if needed, or use real one with test keys $signer = new OpenSslCmsSigner($config->certificatePath, $config->privateKeyPath); - + $connector = new AlfaBankConnector($config, $signer); $connector->withMockClient($mockClient); @@ -34,25 +32,25 @@ test('can create a beneficiary with automatic signing', function () { type: 'FL_RESIDENT', countryOfTaxResidence: 'RU', addresses: new DataCollection(AddressData::class, [ - new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU') + new AddressData('REGISTRATION_ADDRESS', 'Moscow', 'RU'), ]) // digestSignatures is omitted! ); - + // Sign the payload using the connector's signer (or manual signer) // Since we are mocking the client, we might want to verify the request body has signatures. // But here we just test the method call. try { $payload->sign($signer); } catch (\Exception $e) { - // Ignore signing errors in test env if keys are invalid/missing, + // Ignore signing errors in test env if keys are invalid/missing, // but typically test keys should work. } // Ensure signature collection is initialized if ($payload->digestSignatures === null) { - // If signing failed or was skipped, manually add dummy for test assertion - $payload->digestSignatures = new DataCollection(Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData::class, []); + // If signing failed or was skipped, manually add dummy for test assertion + $payload->digestSignatures = new DataCollection(Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData::class, []); } $response = $connector->send(new CreateBeneficiaryRequest($payload)); diff --git a/tests/Feature/NominalAccounts/DealsTest.php b/tests/Feature/NominalAccounts/DealsTest.php index bfdadc8..32e1625 100644 --- a/tests/Feature/NominalAccounts/DealsTest.php +++ b/tests/Feature/NominalAccounts/DealsTest.php @@ -2,18 +2,18 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; -use Apoloz\AlfaBank\Requests\NominalAccounts\Deals\Steps\ManageStepRequest; use Apoloz\AlfaBank\Data\NominalAccounts\Deals\Steps\StepActionRequestData; use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData; -use Spatie\LaravelData\DataCollection; +use Apoloz\AlfaBank\Requests\NominalAccounts\Deals\Steps\ManageStepRequest; use Saloon\Http\Faking\MockResponse; +use Spatie\LaravelData\DataCollection; -test('can manage deal step', function () { +test('can manage deal step', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ ManageStepRequest::class => MockResponse::make([ 'dealId' => 'deal-123', 'stepId' => 'step-456', - 'stepNumber' => 1 + 'stepNumber' => 1, ], 200), ]); @@ -29,7 +29,7 @@ test('can manage deal step', function () { dealId: 'deal-123', action: 'CREATE', digestSignatures: new DataCollection(DigestSignatureData::class, [ - new DigestSignatureData('sig', 'rsa') + new DigestSignatureData('sig', 'rsa'), ]) ); diff --git a/tests/Feature/NominalAccounts/NominalAccountsTest.php b/tests/Feature/NominalAccounts/NominalAccountsTest.php index 730d3fb..26fac1c 100644 --- a/tests/Feature/NominalAccounts/NominalAccountsTest.php +++ b/tests/Feature/NominalAccounts/NominalAccountsTest.php @@ -5,13 +5,13 @@ use Apoloz\AlfaBank\Core\AlfaConfig; use Apoloz\AlfaBank\Requests\NominalAccounts\GetNominalAccountsRequest; use Saloon\Http\Faking\MockResponse; -test('can list nominal accounts', function () { +test('can list nominal accounts', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetNominalAccountsRequest::class => MockResponse::make([ [ 'accountNumber' => '40817810306050000000', 'isActive' => true, - ] + ], ], 200), ]); @@ -23,7 +23,7 @@ test('can list nominal accounts', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetNominalAccountsRequest()); + $response = $connector->send(new GetNominalAccountsRequest); expect($response->status())->toBe(200) ->and($response->dto()->first()->accountNumber)->toBe('40817810306050000000'); diff --git a/tests/Feature/Partner/PartnerTest.php b/tests/Feature/Partner/PartnerTest.php index 3e13835..015b557 100644 --- a/tests/Feature/Partner/PartnerTest.php +++ b/tests/Feature/Partner/PartnerTest.php @@ -5,7 +5,7 @@ use Apoloz\AlfaBank\Requests\Crypto\GetCertificatesRequest; use Apoloz\AlfaBank\Requests\Partner\GetPartnerApplicationsRequest; use Saloon\Http\Faking\MockResponse; -test('can get crypto certificates', function () { +test('can get crypto certificates', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetCertificatesRequest::class => MockResponse::make(['certificates' => []], 200), ]); @@ -14,12 +14,12 @@ test('can get crypto certificates', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetCertificatesRequest()); + $response = $connector->send(new GetCertificatesRequest); expect($response->status())->toBe(200); }); -test('can get partner applications', function () { +test('can get partner applications', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetPartnerApplicationsRequest::class => MockResponse::make(['items' => []], 200), ]); @@ -28,7 +28,7 @@ test('can get partner applications', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetPartnerApplicationsRequest()); + $response = $connector->send(new GetPartnerApplicationsRequest); expect($response->status())->toBe(200); }); diff --git a/tests/Feature/Payments/PaymentTest.php b/tests/Feature/Payments/PaymentTest.php index 42e7d95..11a6972 100644 --- a/tests/Feature/Payments/PaymentTest.php +++ b/tests/Feature/Payments/PaymentTest.php @@ -1,13 +1,12 @@ MockResponse::make('', 201), ]); @@ -38,11 +37,11 @@ test('can create payment order', function () { expect($response->status())->toBe(201); }); -test('can get payment state', function () { +test('can get payment state', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetPaymentStateRequest::class => MockResponse::make([ 'bankStatus' => 'ACCEPTED', - 'bankComment' => 'Processing' + 'bankComment' => 'Processing', ], 200, ['Content-Type' => 'application/json']), ]); diff --git a/tests/Feature/Poa/PoaTest.php b/tests/Feature/Poa/PoaTest.php index 565e39f..aac2f6a 100644 --- a/tests/Feature/Poa/PoaTest.php +++ b/tests/Feature/Poa/PoaTest.php @@ -5,7 +5,7 @@ use Apoloz\AlfaBank\Requests\Poa\CreatePoaRequest; use Apoloz\AlfaBank\Requests\Poa\GetPoaRequestStatusRequest; use Saloon\Http\Faking\MockResponse; -test('can create poa request', function () { +test('can create poa request', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreatePoaRequest::class => MockResponse::make(['requestUuid' => 'uuid-123'], 200), ]); @@ -20,7 +20,7 @@ test('can create poa request', function () { ->and($response->json('requestUuid'))->toBe('uuid-123'); }); -test('can get poa request status', function () { +test('can get poa request status', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetPoaRequestStatusRequest::class => MockResponse::make(['status' => 'COMPLETED'], 200), ]); diff --git a/tests/Feature/Registries/RegistryTest.php b/tests/Feature/Registries/RegistryTest.php index 7089e87..56c0dfd 100644 --- a/tests/Feature/Registries/RegistryTest.php +++ b/tests/Feature/Registries/RegistryTest.php @@ -9,11 +9,11 @@ use Apoloz\AlfaBank\Requests\Registries\SignRegistryRequest; use Saloon\Http\Faking\MockResponse; use Spatie\LaravelData\DataCollection; -test('can create payment registry', function () { +test('can create payment registry', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateRegistryRequest::class => MockResponse::make([ 'id' => 'REG-123', - 'status' => 'CREATED' + 'status' => 'CREATED', ], 201), ]); @@ -31,8 +31,8 @@ test('can create payment registry', function () { 'payeeInn' => '770...', 'payeeName' => 'Recipient LLC', 'payerAccount' => '40702...', - 'purpose' => 'Payment' - ] + 'purpose' => 'Payment', + ], ], DataCollection::class) ); @@ -42,7 +42,7 @@ test('can create payment registry', function () { ->and($response->json('id'))->toBe('REG-123'); }); -test('can sign payment registry', function () { +test('can sign payment registry', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ SignRegistryRequest::class => MockResponse::make([], 200), ]); @@ -55,8 +55,8 @@ test('can sign payment registry', function () { [ 'base64Encoded' => 'SIG...', 'signatureType' => 'RSA', - 'certificateUuid' => 'CERT-123' - ] + 'certificateUuid' => 'CERT-123', + ], ], DataCollection::class); $response = $connector->send(new \Apoloz\AlfaBank\Requests\Registries\SignRegistryRequest('reg-1', \Apoloz\AlfaBank\Data\Registries\RegistrySignatureData::collect([], \Spatie\LaravelData\DataCollection::class))); @@ -64,7 +64,7 @@ test('can sign payment registry', function () { expect($response->status())->toBe(200); }); -test('can get registry details', function () { +test('can get registry details', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ \Apoloz\AlfaBank\Requests\Registries\GetRegistryRequest::class => \Saloon\Http\Faking\MockResponse::make(['id' => 'reg-1'], 200), \Apoloz\AlfaBank\Requests\Registries\GetRegistryPaymentsRequest::class => \Saloon\Http\Faking\MockResponse::make(['payments' => []], 200), @@ -81,4 +81,3 @@ test('can get registry details', function () { $response = $connector->send(new \Apoloz\AlfaBank\Requests\Registries\GetRegistryPaymentsRequest('reg-1')); expect($response->status())->toBe(200); }); - diff --git a/tests/Feature/Reports/ReportTest.php b/tests/Feature/Reports/ReportTest.php index 60ce358..1dafc95 100644 --- a/tests/Feature/Reports/ReportTest.php +++ b/tests/Feature/Reports/ReportTest.php @@ -4,11 +4,11 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Requests\Reports\CreateAccountBalanceReportRequest; use Saloon\Http\Faking\MockResponse; -test('can create account balance report', function () { +test('can create account balance report', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateAccountBalanceReportRequest::class => MockResponse::make([ 'id' => 'report-123', - 'status' => 'PENDING' + 'status' => 'PENDING', ], 201), ]); diff --git a/tests/Feature/Salary/SalaryTest.php b/tests/Feature/Salary/SalaryTest.php index ab3e3b4..3cc4cce 100644 --- a/tests/Feature/Salary/SalaryTest.php +++ b/tests/Feature/Salary/SalaryTest.php @@ -11,7 +11,7 @@ use Apoloz\AlfaBank\Requests\Salary\GetAccountApplicationStatusRequest; use Saloon\Http\Faking\MockResponse; use Spatie\LaravelData\DataCollection; -test('can create salary account application', function () { +test('can create salary account application', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateAccountApplicationRequest::class => MockResponse::make(['id' => 'ACC-123'], 201), ]); @@ -30,7 +30,7 @@ test('can create salary account application', function () { organization: new SalaryOrganizationData('Org LLC', '407...', '770...'), rowsCount: 1, employees: SalaryEmployeeData::collect([ - ['firstName' => 'Ivan', 'lastName' => 'Ivanov'] + ['firstName' => 'Ivan', 'lastName' => 'Ivanov'], ], DataCollection::class) ); @@ -39,7 +39,7 @@ test('can create salary account application', function () { expect($response->status())->toBe(201); }); -test('can create salary payroll application', function () { +test('can create salary payroll application', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreatePayrollApplicationRequest::class => MockResponse::make(['id' => 'PAY-123'], 201), ]); @@ -61,7 +61,7 @@ test('can create salary payroll application', function () { organization: new SalaryOrganizationData('Org LLC', '407...', '770...'), rowsCount: 1, employees: SalaryEmployeeData::collect([ - ['firstName' => 'Ivan', 'lastName' => 'Ivanov', 'amount' => 1000.0] + ['firstName' => 'Ivan', 'lastName' => 'Ivanov', 'amount' => 1000.0], ], DataCollection::class) ); @@ -70,7 +70,7 @@ test('can create salary payroll application', function () { expect($response->status())->toBe(201); }); -test('can get salary application status', function () { +test('can get salary application status', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetAccountApplicationStatusRequest::class => MockResponse::make(['status' => 'PROCESSED'], 200), ]); diff --git a/tests/Feature/Sbp/ConfigTest.php b/tests/Feature/Sbp/ConfigTest.php index 0363530..226a2dc 100644 --- a/tests/Feature/Sbp/ConfigTest.php +++ b/tests/Feature/Sbp/ConfigTest.php @@ -1,12 +1,12 @@ MockResponse::make(['payload' => 'https://test.qr'], 200), ]); diff --git a/tests/Feature/Sbp/QrCodeTest.php b/tests/Feature/Sbp/QrCodeTest.php index 920f8b3..369e991 100644 --- a/tests/Feature/Sbp/QrCodeTest.php +++ b/tests/Feature/Sbp/QrCodeTest.php @@ -1,18 +1,18 @@ MockResponse::make([ 'ErrorCode' => 0, 'message' => 'OK', 'payload' => 'https://qr.nspk.ru/test', - 'image' => 'base64image' + 'image' => 'base64image', ], 200), ]); diff --git a/tests/Feature/Sbp/ReversalTest.php b/tests/Feature/Sbp/ReversalTest.php index 449161f..7754388 100644 --- a/tests/Feature/Sbp/ReversalTest.php +++ b/tests/Feature/Sbp/ReversalTest.php @@ -1,19 +1,19 @@ MockResponse::make([ 'ErrorCode' => 0, 'message' => 'OK', 'qrcId' => 'test-id', 'messageID' => 'guid-123', - 'payerBnkName' => 'Alfa' + 'payerBnkName' => 'Alfa', ], 200), ]); @@ -36,7 +36,7 @@ test('can check reversal data', function () { ->and($response->dto()->messageID)->toBe('guid-123'); }); -test('can get reversal history', function () { +test('can get reversal history', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ \Apoloz\AlfaBank\Sbp\Requests\Reversal\GetQrcReversalHistoryRequest::class => \Saloon\Http\Faking\MockResponse::make([ 'ErrorCode' => 0, @@ -48,9 +48,9 @@ test('can get reversal history', function () { 'originalQrcId' => 'QR-123', 'originalTrxId' => 'TRX-123', 'payerId' => '7900', - 'status' => 'ACWP' - ] - ] + 'status' => 'ACWP', + ], + ], ], 200), ]); diff --git a/tests/Feature/Sbp/WebhookTest.php b/tests/Feature/Sbp/WebhookTest.php index 9aa5a25..62ed9ee 100644 --- a/tests/Feature/Sbp/WebhookTest.php +++ b/tests/Feature/Sbp/WebhookTest.php @@ -1,16 +1,16 @@ 'qrc/notification', 'qrcId' => 'QR123', @@ -20,7 +20,7 @@ test('can parse payment notification webhook', function () { 'timestamp' => '2025-01-01T10:00:00Z', 'payerId' => '7900', 'payrrn' => 'RR123', - 'TermNo' => 'T123' + 'TermNo' => 'T123', ]; $dto = $connector->parsePaymentNotification($payload); diff --git a/tests/Feature/ScoringAndSecurityTest.php b/tests/Feature/ScoringAndSecurityTest.php index a3cf5fe..effae06 100644 --- a/tests/Feature/ScoringAndSecurityTest.php +++ b/tests/Feature/ScoringAndSecurityTest.php @@ -5,7 +5,7 @@ use Apoloz\AlfaBank\Requests\Scoring\GetComplianceScoreRequest; use Apoloz\AlfaBank\Requests\Security\GetSubscriptionsRequest; use Saloon\Http\Faking\MockResponse; -test('can get compliance score', function () { +test('can get compliance score', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetComplianceScoreRequest::class => MockResponse::make(['score' => 'LOW_RISK'], 200), ]); @@ -20,7 +20,7 @@ test('can get compliance score', function () { ->and($response->json('score'))->toBe('LOW_RISK'); }); -test('can get security subscriptions', function () { +test('can get security subscriptions', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ GetSubscriptionsRequest::class => MockResponse::make(['subscriptions' => []], 200), ]); @@ -29,7 +29,7 @@ test('can get security subscriptions', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetSubscriptionsRequest()); + $response = $connector->send(new GetSubscriptionsRequest); expect($response->status())->toBe(200); }); diff --git a/tests/Feature/SelfEmployed/AgreementTest.php b/tests/Feature/SelfEmployed/AgreementTest.php index ab982c0..8493069 100644 --- a/tests/Feature/SelfEmployed/AgreementTest.php +++ b/tests/Feature/SelfEmployed/AgreementTest.php @@ -1,16 +1,15 @@ MockResponse::make([ 'agreementPageId' => 'uuid-page-123', - 'agreementPageLink' => 'https://link.alfa/...' + 'agreementPageLink' => 'https://link.alfa/...', ], 200, ['Content-Type' => 'application/json']), ]); diff --git a/tests/Feature/SelfEmployed/DictionaryTest.php b/tests/Feature/SelfEmployed/DictionaryTest.php index 83cc51d..0820c9d 100644 --- a/tests/Feature/SelfEmployed/DictionaryTest.php +++ b/tests/Feature/SelfEmployed/DictionaryTest.php @@ -1,11 +1,10 @@ MockResponse::make([ ['id' => '1', 'name' => 'IT Services'], @@ -17,17 +16,17 @@ test('can get activities dictionary', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetActivitiesRequest()); + $response = $connector->send(new GetActivitiesRequest); expect($response->status())->toBe(200) ->and($response->dto()->count())->toBe(2) ->and($response->dto()->first()->name)->toBe('IT Services'); }); -test('can get regions dictionary', function () { +test('can get regions dictionary', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ \Apoloz\AlfaBank\Requests\SelfEmployed\GetRegionsRequest::class => \Saloon\Http\Faking\MockResponse::make([ - 'regions' => [['code' => '77', 'name' => 'Москва']] + 'regions' => [['code' => '77', 'name' => 'Москва']], ], 200), ]); @@ -36,9 +35,8 @@ test('can get regions dictionary', function () { $connector = new \Apoloz\AlfaBank\Core\AlfaBankConnector($config, $signer); $connector->withMockClient($mockClient); - $response = $connector->send(new \Apoloz\AlfaBank\Requests\SelfEmployed\GetRegionsRequest()); + $response = $connector->send(new \Apoloz\AlfaBank\Requests\SelfEmployed\GetRegionsRequest); expect($response->status())->toBe(200) ->and($response->json('regions.0.name'))->toBe('Москва'); }); - diff --git a/tests/Feature/SelfEmployed/IncomeTest.php b/tests/Feature/SelfEmployed/IncomeTest.php index 0108dd3..c581df5 100644 --- a/tests/Feature/SelfEmployed/IncomeTest.php +++ b/tests/Feature/SelfEmployed/IncomeTest.php @@ -2,17 +2,17 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; -use Apoloz\AlfaBank\Services\OpenSslCmsSigner; -use Apoloz\AlfaBank\Requests\SelfEmployed\RegisterIncomeRequest; use Apoloz\AlfaBank\Data\SelfEmployed\CreateIncomeRequestData; -use Saloon\Http\Faking\MockResponse; +use Apoloz\AlfaBank\Requests\SelfEmployed\RegisterIncomeRequest; +use Apoloz\AlfaBank\Services\OpenSslCmsSigner; use Saloon\Http\Faking\MockClient; +use Saloon\Http\Faking\MockResponse; -test('can register income', function () { +test('can register income', function (): void { $mockClient = new MockClient([ RegisterIncomeRequest::class => MockResponse::make([ 'requestId' => 'req-1', - 'status' => 'CREATED' + 'status' => 'CREATED', ], 200), ]); diff --git a/tests/Feature/SelfEmployed/PayoutTest.php b/tests/Feature/SelfEmployed/PayoutTest.php index e6545fb..ecb8547 100644 --- a/tests/Feature/SelfEmployed/PayoutTest.php +++ b/tests/Feature/SelfEmployed/PayoutTest.php @@ -1,16 +1,15 @@ MockResponse::make([ 'requestId' => 'payout-req-123', - 'state' => 'PROCESSED' + 'state' => 'PROCESSED', ], 200, ['Content-Type' => 'application/json']), ]); @@ -22,7 +21,7 @@ test('can create a payout for self-employed', function () { externalId: 'ext-id-456', company: ['vatin' => '7700000000'], requisite: [ - ['amount' => 1000, 'vatin' => '112233445566'] + ['amount' => 1000, 'vatin' => '112233445566'], ] ); diff --git a/tests/Feature/SelfEmployed/TaxpayerStatusTest.php b/tests/Feature/SelfEmployed/TaxpayerStatusTest.php index 46c7e00..089c888 100644 --- a/tests/Feature/SelfEmployed/TaxpayerStatusTest.php +++ b/tests/Feature/SelfEmployed/TaxpayerStatusTest.php @@ -1,12 +1,11 @@ MockResponse::make([ 'requestId' => '00000000-0000-0000-0000-000000000001', @@ -15,9 +14,9 @@ test('can get self-employed status from FTS', function () { [ 'vatin' => '112233445566', 'status' => 'ACTIVE', - 'message' => 'Is self-employed' - ] - ] + 'message' => 'Is self-employed', + ], + ], ], 200, ['Content-Type' => 'application/json']), ]); diff --git a/tests/Feature/Signature/SignatureTest.php b/tests/Feature/Signature/SignatureTest.php index a321927..d29ebca 100644 --- a/tests/Feature/Signature/SignatureTest.php +++ b/tests/Feature/Signature/SignatureTest.php @@ -2,12 +2,12 @@ use Apoloz\AlfaBank\Core\AlfaBankConnector; use Apoloz\AlfaBank\Core\AlfaConfig; -use Apoloz\AlfaBank\Services\OpenSslCmsSigner; use Apoloz\AlfaBank\Requests\Signature\GetDistinguishedNameRequest; -use Saloon\Http\Faking\MockResponse; +use Apoloz\AlfaBank\Services\OpenSslCmsSigner; use Saloon\Http\Faking\MockClient; +use Saloon\Http\Faking\MockResponse; -test('can get distinguished name', function () { +test('can get distinguished name', function (): void { $mockClient = new MockClient([ GetDistinguishedNameRequest::class => MockResponse::make(['dn' => 'CN=Test'], 200), ]); @@ -22,7 +22,7 @@ test('can get distinguished name', function () { $connector = new AlfaBankConnector($config, $signer); $connector->withMockClient($mockClient); - $response = $connector->send(new GetDistinguishedNameRequest()); + $response = $connector->send(new GetDistinguishedNameRequest); expect($response->json('dn'))->toBe('CN=Test'); }); diff --git a/tests/Feature/Statement/StatementTest.php b/tests/Feature/Statement/StatementTest.php index 35b2659..7e8e8f4 100644 --- a/tests/Feature/Statement/StatementTest.php +++ b/tests/Feature/Statement/StatementTest.php @@ -1,17 +1,16 @@ MockResponse::make([ 'pagination' => [ 'totalCount' => 1, 'limit' => 10, - 'offset' => 0 + 'offset' => 0, ], 'transactions' => [ [ @@ -23,9 +22,9 @@ test('can get transactions statement', function () { 'amount' => ['amount' => 100.00, 'currencyName' => 'RUB'], 'amountRub' => ['amount' => 100.00, 'currencyName' => 'RUB'], 'paymentPurpose' => 'Test', - 'correspondingAccount' => '408...' - ] - ] + 'correspondingAccount' => '408...', + ], + ], ], 200, ['Content-Type' => 'application/json']), ]); diff --git a/tests/Feature/Utils/CryptoTest.php b/tests/Feature/Utils/CryptoTest.php index 8514871..9940944 100644 --- a/tests/Feature/Utils/CryptoTest.php +++ b/tests/Feature/Utils/CryptoTest.php @@ -3,11 +3,11 @@ use Apoloz\AlfaBank\Utils\CardEncryptor; use Apoloz\AlfaBank\Utils\CmsSigner; -test('can encrypt card pan', function () { +test('can encrypt card pan', function (): void { // Generate a temporary RSA key for testing $res = openssl_pkey_new([ - "private_key_bits" => 2048, - "private_key_type" => OPENSSL_KEYTYPE_RSA, + 'private_key_bits' => 2048, + 'private_key_type' => OPENSSL_KEYTYPE_RSA, ]); openssl_pkey_export($res, $privateKey); $details = openssl_pkey_get_details($res); @@ -20,17 +20,17 @@ test('can encrypt card pan', function () { ->and(base64_decode($encrypted))->not->toBeFalse(); }); -test('can canonicalize json', function () { +test('can canonicalize json', function (): void { $data = [ 'z' => 1, 'a' => [ 'c' => 3, - 'b' => 2 - ] + 'b' => 2, + ], ]; $canonical = CmsSigner::canonicalize($data); - + // Keys should be sorted: a (then b, c), z expect($canonical)->toBe('{"a":{"b":2,"c":3},"z":1}'); }); diff --git a/tests/Feature/Utils/UuidTest.php b/tests/Feature/Utils/UuidTest.php index 0355970..265dafd 100644 --- a/tests/Feature/Utils/UuidTest.php +++ b/tests/Feature/Utils/UuidTest.php @@ -1,37 +1,46 @@ toBeString() ->and(strlen($uuid))->toBe(36) ->and(preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $uuid))->toBe(1); }); -test('middleware adds uuid to request', function () { - $middleware = new RequestIdMiddleware(); - - $request = new class extends Request { +test('middleware adds uuid to request', function (): void { + $middleware = new RequestIdMiddleware; + + $request = new class extends Request + { protected Method $method = Method::GET; - public function resolveEndpoint(): string { return '/'; } + + public function resolveEndpoint(): string + { + return '/'; + } }; - - $connector = new class extends \Saloon\Http\Connector { - public function resolveBaseUrl(): string { return 'https://test'; } + + $connector = new class extends \Saloon\Http\Connector + { + public function resolveBaseUrl(): string + { + return 'https://test'; + } }; - + $pendingRequest = new PendingRequest($connector, $request); - + $middleware($pendingRequest); - + $header = $pendingRequest->headers()->get('X-Request-ID'); - + expect($header)->toBeString() ->and(preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $header))->toBe(1); }); diff --git a/tests/Feature/Webhooks/WebhookManagementTest.php b/tests/Feature/Webhooks/WebhookManagementTest.php index 701e885..9dc9a98 100644 --- a/tests/Feature/Webhooks/WebhookManagementTest.php +++ b/tests/Feature/Webhooks/WebhookManagementTest.php @@ -1,13 +1,13 @@ MockResponse::make([['id' => 'WH-1']], 200), ]); @@ -16,13 +16,13 @@ test('can list webhooks', function () { $connector = new AlfaBankConnector($config); $connector->withMockClient($mockClient); - $response = $connector->send(new GetWebhooksRequest()); + $response = $connector->send(new GetWebhooksRequest); expect($response->status())->toBe(200) ->and($response->json('0.id'))->toBe('WH-1'); }); -test('can create webhook', function () { +test('can create webhook', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ CreateWebhookRequest::class => MockResponse::make(['id' => 'WH-2'], 201), ]); @@ -36,7 +36,7 @@ test('can create webhook', function () { expect($response->status())->toBe(201); }); -test('can delete webhook', function () { +test('can delete webhook', function (): void { $mockClient = new \Saloon\Http\Faking\MockClient([ DeleteWebhookRequest::class => MockResponse::make([], 204), ]); @@ -48,4 +48,4 @@ test('can delete webhook', function () { $response = $connector->send(new DeleteWebhookRequest('WH-1')); expect($response->status())->toBe(204); -}); \ No newline at end of file +}); diff --git a/tests/Feature/Webhooks/WebhookTest.php b/tests/Feature/Webhooks/WebhookTest.php index f1937ca..d12ea9b 100644 --- a/tests/Feature/Webhooks/WebhookTest.php +++ b/tests/Feature/Webhooks/WebhookTest.php @@ -2,11 +2,11 @@ declare(strict_types=1); -use Apoloz\AlfaBank\Webhooks\WebhookFactory; use Apoloz\AlfaBank\Data\Webhooks\Payloads\BaasWebhookData; use Apoloz\AlfaBank\Data\Webhooks\Payloads\SbpWebhookData; +use Apoloz\AlfaBank\Webhooks\WebhookFactory; -test('can detect baas webhook', function () { +test('can detect baas webhook', function (): void { $payload = [ [ 'object' => 'ul_transaction_default', @@ -19,20 +19,20 @@ test('can detect baas webhook', function () { 'documentDate' => '2022-01-12', 'operationCode' => '01', 'paymentPurpose' => 'Test', - 'uuid' => 'uuid-123' - ] - ] + 'uuid' => 'uuid-123', + ], + ], ]; expect(WebhookFactory::isBaas($payload))->toBeTrue(); - + $webhook = WebhookFactory::create($payload); expect($webhook)->toBeInstanceOf(BaasWebhookData::class) ->and($webhook->object)->toBe('ul_transaction_default') ->and($webhook->data->transactionId)->toBe('TX123'); }); -test('can detect sbp webhook', function () { +test('can detect sbp webhook', function (): void { $payload = [ [ 'object' => 'jp_sbp_incoming_payments', @@ -42,13 +42,13 @@ test('can detect sbp webhook', function () { 'nspkTransactionId' => 'NSPK123', 'amount' => 1000, 'currency' => 'RUR', - 'timestamp' => '2024-11-26T09:09:32Z' - ] - ] + 'timestamp' => '2024-11-26T09:09:32Z', + ], + ], ]; expect(WebhookFactory::isSbp($payload))->toBeTrue(); - + $webhook = WebhookFactory::create($payload); expect($webhook)->toBeInstanceOf(SbpWebhookData::class) ->and($webhook->object)->toBe('jp_sbp_incoming_payments') diff --git a/tests/Pest.php b/tests/Pest.php index bc08f25..722dc6f 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -5,13 +5,18 @@ use Apoloz\AlfaBank\Core\AlfaConfig; /** * Define a mock app() helper for tests running outside of Laravel. */ -if (!function_exists('app')) { - function app($abstract = null, array $parameters = []) { +if (! function_exists('app')) { + function app($abstract = null, array $parameters = []) + { static $container = []; - + if ($abstract === null) { - return new class { - public function make($abstract) { return app($abstract); } + return new class + { + public function make($abstract) + { + return app($abstract); + } }; } @@ -21,7 +26,10 @@ if (!function_exists('app')) { // Minimal implementations for laravel-data if ($abstract === \Spatie\LaravelData\Support\DataConfig::class) { - if (isset($container[$abstract])) return $container[$abstract]; + if (isset($container[$abstract])) { + return $container[$abstract]; + } + return $container[$abstract] = \Spatie\LaravelData\Support\DataConfig::createFromConfig(config('data')); } @@ -40,7 +48,7 @@ if (!function_exists('app')) { $constructor = $reflector->getConstructor(); if (is_null($constructor)) { - return $container[$abstract] = new $abstract(); + return $container[$abstract] = new $abstract; } $dependencies = []; @@ -67,8 +75,9 @@ if (!function_exists('app')) { /** * Define a mock config() helper for tests running outside of Laravel. */ -if (!function_exists('config')) { - function config($key = null, $default = null) { +if (! function_exists('config')) { + function config($key = null, $default = null) + { $dataConfig = [ 'validation_strategy' => 'disabled', 'transformers' => [], @@ -101,10 +110,11 @@ if (!function_exists('config')) { if (array_key_exists($subKey, $dataConfig)) { return $dataConfig[$subKey]; } - // Handle features.key + // Handle features.key if (str_starts_with($subKey, 'features.')) { - $featureKey = substr($subKey, 9); - return $dataConfig['features'][$featureKey] ?? $default; + $featureKey = substr($subKey, 9); + + return $dataConfig['features'][$featureKey] ?? $default; } } @@ -115,11 +125,12 @@ if (!function_exists('config')) { /** * Helper to create a test config. */ -function createTestConfig(): AlfaConfig { +function createTestConfig(): AlfaConfig +{ // Create temp files to satisfy file_exists checks $cert = tempnam(sys_get_temp_dir(), 'cert'); $key = tempnam(sys_get_temp_dir(), 'key'); - + return new AlfaConfig( baseUrl: 'https://test.alfabank.ru', certificatePath: $cert,