fix(formating)

This commit is contained in:
Anatoliy Poloz
2026-01-28 03:36:26 +03:00
parent 1723177949
commit b15d29f8e9
313 changed files with 1863 additions and 1533 deletions

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for CashLink QR Code activation request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for CashLink QR Code registration request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP CashLink QR Code registration response.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for CashLink Universal QR Code account change request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP CashLink Uni QR Code account change response.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP Digital Ruble CashLink Universal QR Code creation request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP CashLink Universal QR Code creation response.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for CashLink Universal QR Code status request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP CashLink Universal QR Code status response.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP Digital Ruble Universal QR Code creation request.">

View File

@@ -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;
}

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\DigitalRuble\Notifications;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for Digital Ruble payment notification.">

View File

@@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Management;
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Attributes\MapName;
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code block/unblock request.">

View File

@@ -14,9 +14,10 @@ namespace Apoloz\AlfaBank\Sbp\Data;
// <SECTION name="module_imports" intent="Import necessary attributes and base class for defining the DTO.">
// <BELIEF_STATE "Spatie's Laravel Data package provides powerful features for DTOs, including automatic mapping, validation, and serialization. Using its attributes (`MapName`, `Data`) simplifies the DTO's definition and functionality.">
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
// </SECTION>
// <SECTION name="class_definition" intent="Define the DTO for an SBP QR Code generation request.">
@@ -29,53 +30,53 @@ class QrCodeRequestData extends Data
// <BELIEF_STATE "The `TermNo` is a mandatory identifier for the payment terminal. Using `#[MapName]` allows the internal property to be `termNo` (camelCase) while the API expects `TermNo` (PascalCase).">
#[MapName('TermNo')]
public string $termNo,
// <BELIEF_STATE "The `qrcType` specifies whether the QR code is static ('01') or dynamic ('02'). Providing a default value simplifies usage for the most common scenario.">
#[MapName('qrcType')] // Although same name, good to be explicit
public string $qrcType = '01',
public string $qrcType = '01',
// <BELIEF_STATE "The `amount` is optional for static QRs but mandatory for dynamic ones. It's stored as a string to avoid floating-point precision issues with currency.">
public ?string $amount = null,
// <BELIEF_STATE "The `currency` is typically 'RUB' for SBP, but it's explicitly defined for clarity and future extensibility.">
public string $currency = 'RUB',
// <BELIEF_STATE "The `paymentPurpose` provides a human-readable description for the payment, improving reconciliation.">
public ?string $paymentPurpose = null,
// <BELIEF_STATE "The `redirectUrl` is where the user is sent after completing the payment, essential for web-based flows.">
public ?string $redirectUrl = null,
// <BELIEF_STATE "The `messageID` provides an optional, unique identifier for the request, useful for idempotency or tracking.">
public ?string $messageID = null,
// <BELIEF_STATE "Width and height allow customization of the generated QR code image dimensions.">
public ?string $width = null,
public ?string $height = null,
// <BELIEF_STATE "The `notificationUrl` specifies where the bank should send webhook notifications about payment status changes.">
public ?string $notificationUrl = null,
// Dynamic QR specific fields
// <BELIEF_STATE "The `OrderNumber` is specific to dynamic QRs, providing a unique identifier for the order in the merchant's system.">
#[MapName('OrderNumber')]
public ?string $orderNumber = null,
// <BELIEF_STATE "The `qrTtl` defines how long a dynamic QR code remains valid, specified in minutes.">
public ?string $qrTtl = null,
public ?string $qrTtl = null,
// <BELIEF_STATE "Subscription service identifiers are used for recurring payment scenarios with SBP.">
public ?string $subscriptionServiceId = null,
public ?string $subscriptionServiceName = null,
// Optional user data for Dynamic QR (often part of sender identification)
// <BELIEF_STATE "Sender details are crucial for identifying the payer in certain SBP scenarios. `#[MapName]` ensures these follow API conventions.">
#[MapName('SenderFIO')]
public ?string $senderFio = null,
#[MapName('SenderID')]
public ?string $senderId = null,
#[MapName('SenderBankBIC')]
public ?string $senderBankBic = null,
) {}

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data;
// <SECTION name="module_imports" intent="Import the base Spatie\LaravelData class.">
// <BELIEF_STATE "This class extends `Spatie\LaravelData\Data` to leverage its robust data mapping and type safety, ensuring consistent and predictable handling of SBP QR Code response payloads.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define the QR Code response data structure.">
@@ -35,4 +36,4 @@ class QrCodeResponseData extends Data
) {}
// </SECTION>
}
// </SECTION>
// </SECTION>

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Registry;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP bank list response.">

View File

@@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Attributes\MapName;
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code reversal data request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for detailed SBP QR Code reversal data response.">

View File

@@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Attributes\MapName;
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code reversal status request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code reversal status response.">

View File

@@ -13,10 +13,10 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Attributes\MapInputName;
use Spatie\LaravelData\Attributes\MapName;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code reversal request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Reversal;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code reversal response.">

View File

@@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Status;
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from arrays and provides DTO benefits.">
use Spatie\LaravelData\Attributes\MapName;
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code status request.">

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Status;
// <SECTION name="module_imports" intent="Import the base Spatie Laravel Data class.">
// <BELIEF_STATE "Extending `Spatie\LaravelData\Data` enables automatic casting from JSON and provides DTO benefits.">
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code status response.">

View File

@@ -16,6 +16,7 @@ namespace Apoloz\AlfaBank\Sbp\Data\Subscription;
use Spatie\LaravelData\Attributes\MapName;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
// </SECTION>
// <SECTION name="class_definition" intent="Define a DTO for SBP QR Code subscription registration request.">

View File

@@ -18,6 +18,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to activate a CashLink QR Code.">
@@ -45,6 +46,14 @@ class ActivateCashQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(Response $response): array
{
return $response->json();
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Fields from the DTO are mapped, including conditional parameters for order number, payment purpose, QR TTL, and notification URLs.">
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;
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(Response $response): array
{
return $response->json();
}
// </SECTION>
}

View File

@@ -51,6 +51,14 @@ class ChangeAccountForCashQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Fields are conditionally added based on constructor parameters, ensuring the payload precisely matches the API specification.">
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;
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
}

View File

@@ -47,6 +47,14 @@ class ChangeTermNoForCashQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` and `qrcId` are included in the body to identify the target.">
protected function defaultBody(): array
@@ -58,12 +66,4 @@ class ChangeTermNoForCashQrRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
}

View File

@@ -47,6 +47,14 @@ class DeleteCashQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` and `qrcId` are included in the body to identify the target.">
protected function defaultBody(): array
@@ -58,12 +66,4 @@ class DeleteCashQrRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
}

View File

@@ -49,6 +49,14 @@ class GetCashQrHistoryRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. All constructor properties are directly mapped to the request body to identify the QR Code and the date range.">
protected function defaultBody(): array
@@ -62,12 +70,4 @@ class GetCashQrHistoryRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
}

View File

@@ -47,6 +47,14 @@ class GetCashQrStatusRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` and `qrcId` identify the target.">
protected function defaultBody(): array
@@ -58,12 +66,4 @@ class GetCashQrStatusRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Return the raw JSON response as an array.">
// <BELIEF_STATE "For this specific request, the response is currently returned as a raw array. A dedicated DTO could be created if a structured object is required.">
public function createDtoFromResponse(\Saloon\Http\Response $response): array
{
return $response->json();
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to register a CashLink QR Code.">
@@ -46,6 +47,14 @@ class RegCashQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `RegCashQrResponseData` DTO provides a type-safe and structured object for the result of the QR Code registration.">
public function createDtoFromResponse(Response $response): RegCashQrResponseData
{
return RegCashQrResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Fields from the DTO are mapped, including conditional parameters for media type, dimensions, redirect URL, and QR Code ID.">
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;
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `RegCashQrResponseData` DTO provides a type-safe and structured object for the result of the QR Code registration.">
public function createDtoFromResponse(Response $response): RegCashQrResponseData
{
return RegCashQrResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to change the account for a CashLink Uni QR Code.">
@@ -46,6 +47,14 @@ class ChangeAccForCashUniQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `ChangeAccForCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the account change operation.">
public function createDtoFromResponse(Response $response): ChangeAccForCashUniQrResponseData
{
return ChangeAccForCashUniQrResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Fields from the DTO are mapped, including conditional parameters for the new account, merchant, redirect URL, etc.">
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;
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `ChangeAccForCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the account change operation.">
public function createDtoFromResponse(Response $response): ChangeAccForCashUniQrResponseData
{
return ChangeAccForCashUniQrResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to create a CashLink Uni QR Code.">
@@ -46,6 +47,14 @@ class CreateCashUniQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `CreateCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the QR Code creation.">
public function createDtoFromResponse(Response $response): CreateCashUniQrResponseData
{
return CreateCashUniQrResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Fields from the DTO are mapped, including conditional and nested `queryData` for notification URLs.">
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;
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `CreateCashUniQrResponseData` DTO provides a type-safe and structured object for the result of the QR Code creation.">
public function createDtoFromResponse(Response $response): CreateCashUniQrResponseData
{
return CreateCashUniQrResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of a CashLink Uni QR Code.">
@@ -46,6 +47,14 @@ class GetCashUniQrStatusRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetCashUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of the CashLink Uni QR Code.">
public function createDtoFromResponse(Response $response): GetCashUniQrStatusResponseData
{
return GetCashUniQrStatusResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo`, `uniQrId`, and `paramsId` identify the target. Optional fields like `messageID` and `payrrn` provide additional context.">
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;
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetCashUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of the CashLink Uni QR Code.">
public function createDtoFromResponse(Response $response): GetCashUniQrStatusResponseData
{
return GetCashUniQrStatusResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -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());
}
}
}

View File

@@ -47,6 +47,14 @@ class GetUniQrStatusRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of Universal QR Codes.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` and `uniQrIds` are included in the body to identify the targets.">
protected function defaultBody(): array
@@ -58,12 +66,4 @@ class GetUniQrStatusRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetUniQrStatusResponseData` DTO provides a type-safe and structured object for the status of Universal QR Codes.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\DigitalRuble\GetUniQrStatusResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -15,6 +15,7 @@ namespace Apoloz\AlfaBank\Sbp\Requests\DigitalRuble\Notifications;
// <BELIEF_STATE "This utility uses the `PaymentDrNotificationData` DTO to structure the incoming data. The Laravel `Request` class is typically used for obtaining raw input in a web context.">
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.
// </SECTION>
// <SECTION name="class_definition" intent="Define a utility class for parsing Digital Ruble payment notifications.">

View File

@@ -21,6 +21,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasStringBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define a class that encapsulates all information for the 'Get QR Code' API call.">
@@ -49,6 +50,14 @@ class GetQrCodeRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_dto_caster" intent="Transform the raw API JSON response into a structured DTO.">
// <BELIEF_STATE "Automatically casting the JSON response to a `QrCodeResponseData` DTO provides a superior, type-safe developer experience. It abstracts away the raw response, allowing the user to interact with a clean, predictable object with autocompletion and static analysis benefits.">
public function createDtoFromResponse(Response $response): QrCodeResponseData
{
return QrCodeResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="request_body_builder" intent="Prepare the request payload for transmission.">
// <BELIEF_STATE "This method builds the request body by adding the required 'command' field and merging the DTO data. The SBP API requires the 'command' field to identify the operation type. The 'GetQRCd' command is used for both static and dynamic QR code generation.">
protected function defaultBody(): string
@@ -57,15 +66,8 @@ class GetQrCodeRequest extends Request implements HasBody
['command' => 'GetQRCd'],
$this->data->toArray()
);
return CmsSigner::canonicalize($bodyArray);
}
// </SECTION>
// <SECTION name="response_dto_caster" intent="Transform the raw API JSON response into a structured DTO.">
// <BELIEF_STATE "Automatically casting the JSON response to a `QrCodeResponseData` DTO provides a superior, type-safe developer experience. It abstracts away the raw response, allowing the user to interact with a clean, predictable object with autocompletion and static analysis benefits.">
public function createDtoFromResponse(Response $response): QrCodeResponseData
{
return QrCodeResponseData::from($response->json());
}
// </SECTION>
}
}

View File

@@ -47,6 +47,14 @@ class BlockQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `SbpManagementResponseData` DTO provides a structured object for the result of the block operation.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Using the DTO's `toArray` method ensures the payload is correctly structured.">
protected function defaultBody(): array
@@ -57,12 +65,4 @@ class BlockQrRequest extends Request implements HasBody
);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `SbpManagementResponseData` DTO provides a structured object for the result of the block operation.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -46,6 +46,14 @@ class GetBlockedQrListRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetBlockedQrListResponseData` DTO provides a type-safe object for the list of blocked QR Codes.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` is included in the body to identify the terminal.">
protected function defaultBody(): array
@@ -56,12 +64,4 @@ class GetBlockedQrListRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetBlockedQrListResponseData` DTO provides a type-safe object for the list of blocked QR Codes.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Management\GetBlockedQrListResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -47,6 +47,14 @@ class UnblockQrRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `SbpManagementResponseData` DTO provides a structured object for the result of the unblock operation.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Using the DTO's `toArray` method ensures the payload is correctly structured.">
protected function defaultBody(): array
@@ -57,12 +65,4 @@ class UnblockQrRequest extends Request implements HasBody
);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `SbpManagementResponseData` DTO provides a structured object for the result of the unblock operation.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Management\SbpManagementResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -18,6 +18,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the SBP bank list.">
@@ -46,6 +47,14 @@ class GetBankListRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetBankListResponseData` DTO provides a type-safe and structured object for the list of SBP banks.">
public function createDtoFromResponse(Response $response): GetBankListResponseData
{
return GetBankListResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Optional fields are conditionally added to the body.">
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;
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetBankListResponseData` DTO provides a type-safe and structured object for the list of SBP banks.">
public function createDtoFromResponse(Response $response): GetBankListResponseData
{
return GetBankListResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get detailed QR Code reversal data.">
@@ -46,6 +47,14 @@ class GetQrcReversalDataRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrcReversalDataResponseData` DTO provides a type-safe and structured object for the detailed reversal data.">
public function createDtoFromResponse(Response $response): GetQrcReversalDataResponseData
{
return GetQrcReversalDataResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Other fields from the DTO are conditionally added, ensuring the payload precisely matches the API specification.">
protected function defaultBody(): array
@@ -56,12 +65,4 @@ class GetQrcReversalDataRequest extends Request implements HasBody
);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrcReversalDataResponseData` DTO provides a type-safe and structured object for the detailed reversal data.">
public function createDtoFromResponse(Response $response): GetQrcReversalDataResponseData
{
return GetQrcReversalDataResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -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());
}
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of a QR Code reversal.">
@@ -46,6 +47,14 @@ class GetQrcReversalStatusRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrcReversalStatusResponseData` DTO provides a type-safe and structured object for the status of the reversal.">
public function createDtoFromResponse(Response $response): GetQrcReversalStatusResponseData
{
return GetQrcReversalStatusResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Other fields from the DTO are conditionally added, ensuring the payload precisely matches the API specification.">
protected function defaultBody(): array
@@ -56,12 +65,4 @@ class GetQrcReversalStatusRequest extends Request implements HasBody
);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrcReversalStatusResponseData` DTO provides a type-safe and structured object for the status of the reversal.">
public function createDtoFromResponse(Response $response): GetQrcReversalStatusResponseData
{
return GetQrcReversalStatusResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to initiate a QR Code reversal.">
@@ -46,6 +47,14 @@ class QrcReversalRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `QrcReversalResponseData` DTO provides a type-safe and structured object for the result of the reversal.">
public function createDtoFromResponse(Response $response): QrcReversalResponseData
{
return QrcReversalResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Other fields from the DTO are conditionally added, ensuring the payload precisely matches the API specification.">
protected function defaultBody(): array
@@ -56,12 +65,4 @@ class QrcReversalRequest extends Request implements HasBody
);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `QrcReversalResponseData` DTO provides a type-safe and structured object for the result of the reversal.">
public function createDtoFromResponse(Response $response): QrcReversalResponseData
{
return QrcReversalResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -19,6 +19,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to get the status of a QR Code.">
@@ -46,6 +47,14 @@ class GetQrcStatusRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrcStatusResponseData` DTO provides a type-safe and structured object for the status of the QR Code.">
public function createDtoFromResponse(Response $response): GetQrcStatusResponseData
{
return GetQrcStatusResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. The `TermNo` is mandatory, and `qrcId`, `payrrn`, and `messageID` are optional filters to pinpoint the transaction.">
protected function defaultBody(): array
@@ -56,12 +65,4 @@ class GetQrcStatusRequest extends Request implements HasBody
);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrcStatusResponseData` DTO provides a type-safe and structured object for the status of the QR Code.">
public function createDtoFromResponse(Response $response): GetQrcStatusResponseData
{
return GetQrcStatusResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -48,6 +48,14 @@ class GetQrSubStatusRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrSubStatusResponseData` DTO provides a structured object for the status of the subscription.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Other fields are conditionally added, ensuring the payload precisely matches the API specification.">
protected function defaultBody(): array
@@ -65,12 +73,4 @@ class GetQrSubStatusRequest extends Request implements HasBody
return $body;
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `GetQrSubStatusResponseData` DTO provides a structured object for the status of the subscription.">
public function createDtoFromResponse(\Saloon\Http\Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Subscription\GetQrSubStatusResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -17,6 +17,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to petition a QR Code subscription payment.">
@@ -47,6 +48,14 @@ class QrcSubPayPetitionRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `QrcSubPayPetitionResponseData` DTO provides a structured object for the result of the payment petition.">
public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. All constructor properties are directly mapped to the request body.">
protected function defaultBody(): array
@@ -60,12 +69,4 @@ class QrcSubPayPetitionRequest extends Request implements HasBody
];
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `QrcSubPayPetitionResponseData` DTO provides a structured object for the result of the payment petition.">
public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Subscription\QrcSubPayPetitionResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -18,6 +18,7 @@ use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
// </SECTION>
// <SECTION name="class_definition" intent="Define the request to register a QR Code subscription.">
@@ -45,6 +46,14 @@ class RegQrSubRequest extends Request implements HasBody
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `RegQrSubResponseData` DTO provides a structured object for the result of the subscription registration.">
public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData::from($response->json());
}
// </SECTION>
// <SECTION name="body_builder" intent="Construct the JSON body for the request.">
// <BELIEF_STATE "The `command` field specifies the operation to the SBP API. Using the DTO's `toArray` method ensures the payload is correctly structured.">
protected function defaultBody(): array
@@ -55,12 +64,4 @@ class RegQrSubRequest extends Request implements HasBody
);
}
// </SECTION>
// <SECTION name="response_caster" intent="Map the JSON response to a DTO.">
// <BELIEF_STATE "Casting the response to a `RegQrSubResponseData` DTO provides a structured object for the result of the subscription registration.">
public function createDtoFromResponse(Response $response): \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData
{
return \Apoloz\AlfaBank\Sbp\Data\Subscription\RegQrSubResponseData::from($response->json());
}
// </SECTION>
}

View File

@@ -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);
}
}
}