first commit

This commit is contained in:
2026-01-14 16:40:33 +03:00
commit f803480f7b
184 changed files with 5573 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace Gemini\AlfaBank\Sbp\Requests;
use Gemini\AlfaBank\Sbp\Data\QrCodeRequestData;
use Gemini\AlfaBank\Sbp\Data\QrCodeResponseData;
use Saloon\Contracts\Body\HasBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Http\Response;
use Saloon\Traits\Body\HasJsonBody;
class GetQrCodeRequest extends Request implements HasBody
{
use HasJsonBody;
protected Method $method = Method::POST;
public function __construct(
protected QrCodeRequestData $data
) {}
public function resolveEndpoint(): string
{
return '';
}
protected function defaultBody(): array
{
$body = [
'command' => 'GetQRCd',
'TermNo' => $this->data->TermNo,
'qrcType' => $this->data->qrcType,
'currency' => $this->data->currency,
];
// Common Fields
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->messageID !== null) $body['messageID'] = $this->data->messageID;
if ($this->data->width !== null) $body['width'] = $this->data->width;
if ($this->data->height !== null) $body['height'] = $this->data->height;
// Dynamic QR Fields
if ($this->data->OrderNumber !== null) $body['OrderNumber'] = $this->data->OrderNumber;
if ($this->data->qrTtl !== null) $body['qrTtl'] = $this->data->qrTtl;
if ($this->data->subscriptionServiceId !== null) $body['subscriptionServiceId'] = $this->data->subscriptionServiceId;
if ($this->data->subscriptionServiceName !== null) $body['subscriptionServiceName'] = $this->data->subscriptionServiceName;
// Query Data nesting
$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 (!empty($queryData)) {
$body['queryData'] = $queryData;
}
return $body;
}
public function createDtoFromResponse(Response $response): QrCodeResponseData
{
return QrCodeResponseData::from($response->json());
}
}