forked from apoloz/alfa-bank-sdk
first commit
This commit is contained in:
20
src/Sbp/Data/CashLink/ActivateCashQrRequestData.php
Normal file
20
src/Sbp/Data/CashLink/ActivateCashQrRequestData.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class ActivateCashQrRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public string $qrcId,
|
||||
public int $amount,
|
||||
public ?string $currency = 'RUB',
|
||||
public ?string $OrderNumber = null,
|
||||
public ?string $paymentPurpose = null,
|
||||
public ?string $notificationUrl = null,
|
||||
public ?string $qrTtl = null,
|
||||
public ?string $redirectUrl = null,
|
||||
) {}
|
||||
}
|
||||
17
src/Sbp/Data/CashLink/RegCashQrRequestData.php
Normal file
17
src/Sbp/Data/CashLink/RegCashQrRequestData.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class RegCashQrRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public ?string $mediaType = null,
|
||||
public ?string $width = null,
|
||||
public ?string $height = null,
|
||||
public ?string $redirectUrl = null,
|
||||
public ?string $qrcId = null,
|
||||
) {}
|
||||
}
|
||||
19
src/Sbp/Data/CashLink/RegCashQrResponseData.php
Normal file
19
src/Sbp/Data/CashLink/RegCashQrResponseData.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class RegCashQrResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public string $message,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $content = null,
|
||||
public ?string $mediaType = null,
|
||||
public ?string $payload = null,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $status = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class ChangeAccForCashUniQrRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public ?string $messageID = null,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $account = null,
|
||||
public ?string $accountDR = null,
|
||||
public ?string $NewTermNo = null,
|
||||
public ?string $NewMerchantId = null,
|
||||
public ?string $redirectUrl = null,
|
||||
public ?string $paymentPageUrl = null,
|
||||
public ?string $fraudScore = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class ChangeAccForCashUniQrResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public string $message,
|
||||
public ?string $messageID = null,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $account = null,
|
||||
public ?string $accountDR = null,
|
||||
public ?string $redirectUrl = null,
|
||||
public ?string $paymentPageUrl = null,
|
||||
public ?string $fraudScore = null,
|
||||
public ?string $NewTermNo = null,
|
||||
public ?string $NewMerchantId = null,
|
||||
public ?string $status = null,
|
||||
public ?string $merchantId = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class CreateCashUniQrRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public ?string $messageID = null,
|
||||
public ?string $redirectUrl = null,
|
||||
public ?string $paymentPageUrl = null,
|
||||
public ?string $mediaType = 'image/png',
|
||||
public ?string $width = '600',
|
||||
public ?string $height = '600',
|
||||
public ?string $qrcId = null,
|
||||
public ?string $notificationUrl = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class CreateCashUniQrResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public string $message,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $payload = null,
|
||||
public ?string $image = null,
|
||||
public ?string $mediaType = null,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $status = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetCashUniQrStatusRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public string $uniQrId,
|
||||
public string $paramsId,
|
||||
public ?string $messageID = null,
|
||||
public ?string $payrrn = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetCashUniQrStatusResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public string $message,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $uniQrId = null,
|
||||
public ?string $paramsId = null,
|
||||
public ?string $trxStatus = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $timestamp = null,
|
||||
public ?string $cashRegisterQrcStatus = null,
|
||||
public ?string $trxId = null,
|
||||
public ?string $trxDT = null,
|
||||
public ?string $amount = null,
|
||||
public ?string $currency = null,
|
||||
public ?string $Url = null,
|
||||
public ?string $CreditDatePos = null,
|
||||
public ?string $payerId = null,
|
||||
public ?string $kzo = null,
|
||||
public ?string $merchantId = null,
|
||||
public ?string $paymentServiceId = null,
|
||||
) {}
|
||||
}
|
||||
26
src/Sbp/Data/DigitalRuble/CreateUniQrRequestData.php
Normal file
26
src/Sbp/Data/DigitalRuble/CreateUniQrRequestData.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class CreateUniQrRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public string $uniQrType = '02', // 01=Multi, 02=Single
|
||||
public ?string $amount = null,
|
||||
public ?string $paymentPurpose = null,
|
||||
public ?string $mediaType = 'image/png',
|
||||
public ?string $width = '600',
|
||||
public ?string $height = '600',
|
||||
public ?string $redirectUrl = null,
|
||||
public ?string $paymentPageUrl = null,
|
||||
public ?string $qrTtl = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $notificationUrl = null,
|
||||
public ?string $SenderFIO = null,
|
||||
public ?string $SenderID = null,
|
||||
public ?string $SenderBankBIC = null,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\DigitalRuble\Notifications;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class PaymentDrNotificationData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $command,
|
||||
public string $payrrn,
|
||||
public string $BatchId,
|
||||
public string $TermNo,
|
||||
public string $CreditDatePos,
|
||||
public string $merchantName,
|
||||
public ?string $uniQrId = null,
|
||||
public ?string $operationId = null,
|
||||
public ?string $status = null,
|
||||
public ?string $amount = null,
|
||||
public ?string $timestamp = null,
|
||||
public ?string $purpose = null,
|
||||
) {}
|
||||
}
|
||||
14
src/Sbp/Data/Management/BlockQrRequestData.php
Normal file
14
src/Sbp/Data/Management/BlockQrRequestData.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Management;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class BlockQrRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public string $qrcId,
|
||||
public ?string $reason = null,
|
||||
) {}
|
||||
}
|
||||
32
src/Sbp/Data/QrCodeRequestData.php
Normal file
32
src/Sbp/Data/QrCodeRequestData.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class QrCodeRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public string $qrcType = '01', // '01' = Static, '02' = Dynamic
|
||||
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
|
||||
public ?string $OrderNumber = null,
|
||||
public ?string $qrTtl = null, // Minutes, 1-6
|
||||
public ?string $subscriptionServiceId = null,
|
||||
public ?string $subscriptionServiceName = null,
|
||||
|
||||
// Optional user data for Dynamic QR
|
||||
public ?string $SenderFIO = null,
|
||||
public ?string $SenderID = null,
|
||||
public ?string $SenderBankBIC = null,
|
||||
) {}
|
||||
}
|
||||
20
src/Sbp/Data/QrCodeResponseData.php
Normal file
20
src/Sbp/Data/QrCodeResponseData.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class QrCodeResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public ?string $message = null,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $image = null,
|
||||
public ?string $payload = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $status = null,
|
||||
) {}
|
||||
}
|
||||
14
src/Sbp/Data/Registry/GetBankListResponseData.php
Normal file
14
src/Sbp/Data/Registry/GetBankListResponseData.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Registry;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetBankListResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public string $message,
|
||||
public ?array $BankList = null,
|
||||
) {}
|
||||
}
|
||||
20
src/Sbp/Data/Reversal/GetQrcReversalDataRequestData.php
Normal file
20
src/Sbp/Data/Reversal/GetQrcReversalDataRequestData.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Reversal;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetQrcReversalDataRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $trxId = null,
|
||||
public ?string $trxDT = null,
|
||||
public ?string $amount = null,
|
||||
public string $currency = 'RUB',
|
||||
public ?string $messageID = null,
|
||||
public ?bool $ReturnRestAmount = null,
|
||||
) {}
|
||||
}
|
||||
24
src/Sbp/Data/Reversal/GetQrcReversalDataResponseData.php
Normal file
24
src/Sbp/Data/Reversal/GetQrcReversalDataResponseData.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Reversal;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetQrcReversalDataResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public string $message,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $payerBnkBIC = null,
|
||||
public ?string $payerBnkName = null,
|
||||
public ?string $payerId = null,
|
||||
public ?string $payerPam = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $trxDT = null,
|
||||
public ?string $trxId = null,
|
||||
public ?string $restAmount = null,
|
||||
) {}
|
||||
}
|
||||
16
src/Sbp/Data/Reversal/GetQrcReversalStatusRequestData.php
Normal file
16
src/Sbp/Data/Reversal/GetQrcReversalStatusRequestData.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Reversal;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetQrcReversalStatusRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $originalTrxId = null,
|
||||
public ?string $trxId = null,
|
||||
public ?string $messageID = null,
|
||||
) {}
|
||||
}
|
||||
23
src/Sbp/Data/Reversal/GetQrcReversalStatusResponseData.php
Normal file
23
src/Sbp/Data/Reversal/GetQrcReversalStatusResponseData.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Reversal;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetQrcReversalStatusResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public ?string $message = null,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $amount = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $originalQrcId = null,
|
||||
public ?string $originalTrxId = null,
|
||||
public ?string $payerId = null,
|
||||
public ?string $Url = null,
|
||||
public ?string $status = null,
|
||||
public ?string $trxDT = null,
|
||||
public ?string $trxId = null,
|
||||
) {}
|
||||
}
|
||||
22
src/Sbp/Data/Reversal/QrcReversalRequestData.php
Normal file
22
src/Sbp/Data/Reversal/QrcReversalRequestData.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Reversal;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class QrcReversalRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $trxId = null,
|
||||
public ?string $trxDT = null,
|
||||
public ?string $amount = null,
|
||||
public string $currency = 'RUB',
|
||||
public ?string $messageID = null,
|
||||
public ?string $notificationUrl = null,
|
||||
public ?bool $ReturnRestAmount = null,
|
||||
// extJsonParams not fully implemented as it's optional and dynamic
|
||||
) {}
|
||||
}
|
||||
21
src/Sbp/Data/Reversal/QrcReversalResponseData.php
Normal file
21
src/Sbp/Data/Reversal/QrcReversalResponseData.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Reversal;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class QrcReversalResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public ?string $message = null,
|
||||
public ?string $TermNo = null,
|
||||
public ?string $amount = null,
|
||||
public ?string $currency = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $trxDT = null,
|
||||
public ?string $trxId = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $restAmount = null,
|
||||
) {}
|
||||
}
|
||||
15
src/Sbp/Data/Status/GetQrcStatusRequestData.php
Normal file
15
src/Sbp/Data/Status/GetQrcStatusRequestData.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Status;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetQrcStatusRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $messageID = null,
|
||||
) {}
|
||||
}
|
||||
27
src/Sbp/Data/Status/GetQrcStatusResponseData.php
Normal file
27
src/Sbp/Data/Status/GetQrcStatusResponseData.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Status;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class GetQrcStatusResponseData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public int $ErrorCode,
|
||||
public string $message,
|
||||
public ?string $qrcId = null,
|
||||
public ?string $status = null,
|
||||
public ?string $trxId = null,
|
||||
public ?string $trxDT = null,
|
||||
public ?string $payrrn = null,
|
||||
public ?string $CreditDatePos = null,
|
||||
public ?string $TermNo = null,
|
||||
public ?int $amount = null,
|
||||
public ?string $currency = null,
|
||||
public ?string $Url = null,
|
||||
public ?string $payerId = null,
|
||||
public ?string $kzo = null,
|
||||
public ?string $messageID = null,
|
||||
public ?string $merchantId = null,
|
||||
) {}
|
||||
}
|
||||
19
src/Sbp/Data/Subscription/RegQrSubRequestData.php
Normal file
19
src/Sbp/Data/Subscription/RegQrSubRequestData.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Data\Subscription;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class RegQrSubRequestData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $TermNo,
|
||||
public string $subscriptionPurpose,
|
||||
public string $notificationUrl,
|
||||
public string $qrcType = '03',
|
||||
public ?string $qrTtl = null,
|
||||
public ?string $redirectUrl = null,
|
||||
public ?string $subscriptionServiceId = null,
|
||||
public ?string $subscriptionServiceName = null,
|
||||
) {}
|
||||
}
|
||||
52
src/Sbp/Requests/CashLink/ActivateCashQrRequest.php
Normal file
52
src/Sbp/Requests/CashLink/ActivateCashQrRequest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\CashLink;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\CashLink\ActivateCashQrRequestData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class ActivateCashQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected ActivateCashQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'ActivateCashQRc',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'qrcId' => $this->data->qrcId,
|
||||
'amount' => $this->data->amount,
|
||||
'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->notificationUrl !== null) {
|
||||
$body['queryData'] = ['notificationUrl' => $this->data->notificationUrl];
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
50
src/Sbp/Requests/CashLink/ChangeAccountForCashQrRequest.php
Normal file
50
src/Sbp/Requests/CashLink/ChangeAccountForCashQrRequest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\CashLink;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class ChangeAccountForCashQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected string $qrcId,
|
||||
protected string $account,
|
||||
protected ?string $NewTermNo = null,
|
||||
protected ?string $NewMerchantId = null,
|
||||
protected ?string $redirectUrl = null,
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'ChangeAccForCashQRc',
|
||||
'TermNo' => $this->TermNo,
|
||||
'qrcId' => $this->qrcId,
|
||||
'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;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
39
src/Sbp/Requests/CashLink/ChangeTermNoForCashQrRequest.php
Normal file
39
src/Sbp/Requests/CashLink/ChangeTermNoForCashQrRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\CashLink;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class ChangeTermNoForCashQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected string $qrcId
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'ChangeTermNoForCashQRc',
|
||||
'TermNo' => $this->TermNo,
|
||||
'qrcId' => $this->qrcId,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
39
src/Sbp/Requests/CashLink/DeleteCashQrRequest.php
Normal file
39
src/Sbp/Requests/CashLink/DeleteCashQrRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\CashLink;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class DeleteCashQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected string $qrcId
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'DelCashQRc',
|
||||
'TermNo' => $this->TermNo,
|
||||
'qrcId' => $this->qrcId,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
43
src/Sbp/Requests/CashLink/GetCashQrHistoryRequest.php
Normal file
43
src/Sbp/Requests/CashLink/GetCashQrHistoryRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\CashLink;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetCashQrHistoryRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected string $qrcId,
|
||||
protected string $dateFrom,
|
||||
protected string $dateTo
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'GetCashQrcId',
|
||||
'TermNo' => $this->TermNo,
|
||||
'qrcId' => $this->qrcId,
|
||||
'dateFrom' => $this->dateFrom,
|
||||
'dateTo' => $this->dateTo,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
39
src/Sbp/Requests/CashLink/GetCashQrStatusRequest.php
Normal file
39
src/Sbp/Requests/CashLink/GetCashQrStatusRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\CashLink;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetCashQrStatusRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected string $qrcId
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'GetCashQRCstatus',
|
||||
'TermNo' => $this->TermNo,
|
||||
'qrcId' => $this->qrcId,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
48
src/Sbp/Requests/CashLink/RegCashQrRequest.php
Normal file
48
src/Sbp/Requests/CashLink/RegCashQrRequest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\CashLink;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\CashLink\RegCashQrRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\CashLink\RegCashQrResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class RegCashQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected RegCashQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'RegCashQRc',
|
||||
'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;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): RegCashQrResponseData
|
||||
{
|
||||
return RegCashQrResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\DigitalRuble\CashLink;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink\ChangeAccForCashUniQrRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink\ChangeAccForCashUniQrResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class ChangeAccForCashUniQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected ChangeAccForCashUniQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'ChangeAccForCashUniQr',
|
||||
'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;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): ChangeAccForCashUniQrResponseData
|
||||
{
|
||||
return ChangeAccForCashUniQrResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\DigitalRuble\CashLink;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink\CreateCashUniQrRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink\CreateCashUniQrResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class CreateCashUniQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected CreateCashUniQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'ReqCashUniQr',
|
||||
'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->notificationUrl !== null) {
|
||||
$body['queryData'] = ['notificationUrl' => $this->data->notificationUrl];
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): CreateCashUniQrResponseData
|
||||
{
|
||||
return CreateCashUniQrResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\DigitalRuble\CashLink;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink\GetCashUniQrStatusRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CashLink\GetCashUniQrStatusResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetCashUniQrStatusRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected GetCashUniQrStatusRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'GetCashUniQrStatus',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'uniQrId' => $this->data->uniQrId,
|
||||
'paramsId' => $this->data->paramsId,
|
||||
];
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
62
src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php
Normal file
62
src/Sbp/Requests/DigitalRuble/CreateUniQrRequest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\DigitalRuble;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\CreateUniQrRequestData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class CreateUniQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected CreateUniQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'ReqUniQr',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'uniQrType' => $this->data->uniQrType,
|
||||
];
|
||||
|
||||
// Conditional mappings
|
||||
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 (!empty($queryData)) {
|
||||
$body['queryData'] = $queryData;
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
39
src/Sbp/Requests/DigitalRuble/GetUniQrStatusRequest.php
Normal file
39
src/Sbp/Requests/DigitalRuble/GetUniQrStatusRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\DigitalRuble;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetUniQrStatusRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected array $uniQrIds, // Array of strings
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'GetUniQrStatus',
|
||||
'TermNo' => $this->TermNo,
|
||||
'uniQrIds' => $this->uniQrIds,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\DigitalRuble\Notifications;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\DigitalRuble\Notifications\PaymentDrNotificationData;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ParsePaymentDrNotification
|
||||
{
|
||||
public function execute(array $data): PaymentDrNotificationData
|
||||
{
|
||||
return PaymentDrNotificationData::from($data);
|
||||
}
|
||||
}
|
||||
69
src/Sbp/Requests/GetQrCodeRequest.php
Normal file
69
src/Sbp/Requests/GetQrCodeRequest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
45
src/Sbp/Requests/Management/BlockQrRequest.php
Normal file
45
src/Sbp/Requests/Management/BlockQrRequest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Management;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Management\BlockQrRequestData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class BlockQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected BlockQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'BlockQRcId',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'qrcId' => $this->data->qrcId,
|
||||
];
|
||||
|
||||
if ($this->data->reason !== null) {
|
||||
$body['reason'] = $this->data->reason;
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
37
src/Sbp/Requests/Management/GetBlockedQrListRequest.php
Normal file
37
src/Sbp/Requests/Management/GetBlockedQrListRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Management;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetBlockedQrListRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'GetBlockedQRcIdList',
|
||||
'TermNo' => $this->TermNo,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
39
src/Sbp/Requests/Management/UnblockQrRequest.php
Normal file
39
src/Sbp/Requests/Management/UnblockQrRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Management;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Management\BlockQrRequestData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class UnblockQrRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected BlockQrRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'UnblockQRcId',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'qrcId' => $this->data->qrcId,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
44
src/Sbp/Requests/Registry/GetBankListRequest.php
Normal file
44
src/Sbp/Requests/Registry/GetBankListRequest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Registry;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Registry\GetBankListResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetBankListRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected ?string $messageID = null,
|
||||
protected ?string $BankMemberIdFilter = null
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'GetBankList',
|
||||
];
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
51
src/Sbp/Requests/Reversal/GetQrcReversalDataRequest.php
Normal file
51
src/Sbp/Requests/Reversal/GetQrcReversalDataRequest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Reversal;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Reversal\GetQrcReversalDataRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\Reversal\GetQrcReversalDataResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetQrcReversalDataRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected GetQrcReversalDataRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'GetQRCreversalData',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'currency' => $this->data->currency,
|
||||
];
|
||||
|
||||
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
|
||||
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
|
||||
if ($this->data->trxId !== null) $body['trxId'] = $this->data->trxId;
|
||||
if ($this->data->trxDT !== null) $body['trxDT'] = $this->data->trxDT;
|
||||
if ($this->data->amount !== null) $body['amount'] = $this->data->amount;
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
if ($this->data->ReturnRestAmount !== null) $body['ReturnRestAmount'] = $this->data->ReturnRestAmount;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GetQrcReversalDataResponseData
|
||||
{
|
||||
return GetQrcReversalDataResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
47
src/Sbp/Requests/Reversal/GetQrcReversalStatusRequest.php
Normal file
47
src/Sbp/Requests/Reversal/GetQrcReversalStatusRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Reversal;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Reversal\GetQrcReversalStatusRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\Reversal\GetQrcReversalStatusResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetQrcReversalStatusRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected GetQrcReversalStatusRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'GetQRCreversalStatus',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
];
|
||||
|
||||
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
|
||||
if ($this->data->originalTrxId !== null) $body['originalTrxId'] = $this->data->originalTrxId;
|
||||
if ($this->data->trxId !== null) $body['trxId'] = $this->data->trxId;
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GetQrcReversalStatusResponseData
|
||||
{
|
||||
return GetQrcReversalStatusResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
52
src/Sbp/Requests/Reversal/QrcReversalRequest.php
Normal file
52
src/Sbp/Requests/Reversal/QrcReversalRequest.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Reversal;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Reversal\QrcReversalRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\Reversal\QrcReversalResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class QrcReversalRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected QrcReversalRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'QRCreversal',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'currency' => $this->data->currency,
|
||||
];
|
||||
|
||||
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
|
||||
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
|
||||
if ($this->data->trxId !== null) $body['trxId'] = $this->data->trxId;
|
||||
if ($this->data->trxDT !== null) $body['trxDT'] = $this->data->trxDT;
|
||||
if ($this->data->amount !== null) $body['amount'] = $this->data->amount;
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
if ($this->data->notificationUrl !== null) $body['queryData'] = ['notificationUrl' => $this->data->notificationUrl];
|
||||
if ($this->data->ReturnRestAmount !== null) $body['ReturnRestAmount'] = $this->data->ReturnRestAmount;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): QrcReversalResponseData
|
||||
{
|
||||
return QrcReversalResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
46
src/Sbp/Requests/Status/GetQrcStatusRequest.php
Normal file
46
src/Sbp/Requests/Status/GetQrcStatusRequest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Status;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Status\GetQrcStatusRequestData;
|
||||
use Gemini\AlfaBank\Sbp\Data\Status\GetQrcStatusResponseData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetQrcStatusRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected GetQrcStatusRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'GetQRCstatus',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
];
|
||||
|
||||
if ($this->data->qrcId !== null) $body['qrcId'] = $this->data->qrcId;
|
||||
if ($this->data->payrrn !== null) $body['payrrn'] = $this->data->payrrn;
|
||||
if ($this->data->messageID !== null) $body['messageID'] = $this->data->messageID;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): GetQrcStatusResponseData
|
||||
{
|
||||
return GetQrcStatusResponseData::from($response->json());
|
||||
}
|
||||
}
|
||||
46
src/Sbp/Requests/Subscription/GetQrSubStatusRequest.php
Normal file
46
src/Sbp/Requests/Subscription/GetQrSubStatusRequest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Subscription;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class GetQrSubStatusRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected string $qrcId,
|
||||
protected ?string $RQperiod = null
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'GetQRCSubStatus',
|
||||
'TermNo' => $this->TermNo,
|
||||
'qrcId' => $this->qrcId,
|
||||
];
|
||||
|
||||
if ($this->RQperiod !== null) {
|
||||
$body['RQperiod'] = $this->RQperiod;
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(\Saloon\Http\Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
44
src/Sbp/Requests/Subscription/QrcSubPayPetitionRequest.php
Normal file
44
src/Sbp/Requests/Subscription/QrcSubPayPetitionRequest.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Subscription;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class QrcSubPayPetitionRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected string $TermNo,
|
||||
protected string $subscriptionToken,
|
||||
protected string $SenderMemberId,
|
||||
protected string $qrcId,
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'command' => 'QRCSubPayPetition',
|
||||
'TermNo' => $this->TermNo,
|
||||
'subscriptionToken' => $this->subscriptionToken,
|
||||
'SenderMemberId' => $this->SenderMemberId,
|
||||
'qrcId' => $this->qrcId,
|
||||
];
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
51
src/Sbp/Requests/Subscription/RegQrSubRequest.php
Normal file
51
src/Sbp/Requests/Subscription/RegQrSubRequest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp\Requests\Subscription;
|
||||
|
||||
use Gemini\AlfaBank\Sbp\Data\Subscription\RegQrSubRequestData;
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Http\Response;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class RegQrSubRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected RegQrSubRequestData $data
|
||||
) {}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
$body = [
|
||||
'command' => 'RegQRcSub',
|
||||
'TermNo' => $this->data->TermNo,
|
||||
'qrcType' => $this->data->qrcType,
|
||||
'subscriptionPurpose' => $this->data->subscriptionPurpose,
|
||||
'queryData' => [
|
||||
'notificationUrl' => $this->data->notificationUrl,
|
||||
],
|
||||
];
|
||||
|
||||
if ($this->data->qrTtl !== null) $body['qrTtl'] = $this->data->qrTtl;
|
||||
if ($this->data->redirectUrl !== null) $body['redirectUrl'] = $this->data->redirectUrl;
|
||||
if ($this->data->subscriptionServiceId !== null) $body['subscriptionServiceId'] = $this->data->subscriptionServiceId;
|
||||
if ($this->data->subscriptionServiceName !== null) $body['subscriptionServiceName'] = $this->data->subscriptionServiceName;
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function createDtoFromResponse(Response $response): array
|
||||
{
|
||||
return $response->json();
|
||||
}
|
||||
}
|
||||
75
src/Sbp/SbpConnector.php
Normal file
75
src/Sbp/SbpConnector.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Gemini\AlfaBank\Sbp;
|
||||
|
||||
use Gemini\AlfaBank\Enums\Environment;
|
||||
use Saloon\Http\Connector;
|
||||
use Saloon\Http\PendingRequest;
|
||||
use Saloon\Traits\Plugins\HasTimeout;
|
||||
|
||||
class SbpConnector extends Connector
|
||||
{
|
||||
use HasTimeout;
|
||||
|
||||
public function __construct(
|
||||
protected string $certificatePath,
|
||||
protected string $privateKeyPath,
|
||||
protected string $keyNameAlias, // 'key-name' header
|
||||
protected Environment $environment = Environment::SANDBOX
|
||||
) {}
|
||||
|
||||
public function resolveBaseUrl(): string
|
||||
{
|
||||
return match ($this->environment) {
|
||||
Environment::SANDBOX => 'https://217.12.103.132:2443/fsCryptoProxy',
|
||||
Environment::PRODUCTION => 'https://pay.alfabank.ru/fsCryptoProxy', // Placeholder, user needs to confirm
|
||||
};
|
||||
}
|
||||
|
||||
protected function defaultConfig(): array
|
||||
{
|
||||
return [
|
||||
'cert' => $this->certificatePath,
|
||||
'ssl_key' => $this->privateKeyPath,
|
||||
'verify' => true,
|
||||
];
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return [
|
||||
'Content-Type' => 'application/x-www-form-urlencoded', // As per doc, despite body being JSON
|
||||
'key-name' => $this->keyNameAlias,
|
||||
];
|
||||
}
|
||||
|
||||
public function boot(PendingRequest $pendingRequest): void
|
||||
{
|
||||
// Calculate Signature
|
||||
$body = $pendingRequest->body()?->all();
|
||||
|
||||
if (empty($body)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Minify JSON for signature
|
||||
$jsonBody = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
// Remove spaces/newlines as per doc requirement "exclude all spaces, tabs, newlines"
|
||||
// Standard json_encode without pretty print usually does this, but let's be sure.
|
||||
// The doc example: `{"command":"GetQRCd",...}` implies no spaces after colons/commas.
|
||||
|
||||
$privateKey = file_get_contents($this->privateKeyPath);
|
||||
$pkeyId = openssl_get_privatekey($privateKey);
|
||||
|
||||
openssl_sign($jsonBody, $signature, $pkeyId, OPENSSL_ALGO_SHA256);
|
||||
$signatureBase64 = base64_encode($signature);
|
||||
|
||||
$pendingRequest->headers()->add('Authorization', $signatureBase64);
|
||||
|
||||
// Ensure the body sent is the exact string we signed?
|
||||
// Saloon will encode the array to JSON again.
|
||||
// We should enforce the body to be the string we just signed to ensure consistency.
|
||||
$pendingRequest->body()->set($jsonBody);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user