Files
Moodle/classes/local/protocol/PayResponse.php
T

47 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace paygw_moneta\local\protocol;
use paygw_moneta\local\Money;
use paygw_moneta\local\receipt\Receipt;
/**
* @package paygw_moneta
* @copyright 2026 Moneta Labs {@link https://moneta.ru/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class PayResponse
{
public function __construct(
private readonly string $accountId,
private readonly string $transactionId,
private readonly Money $amount,
private readonly ResultCode $resultCode,
private readonly Signature $signature,
private readonly string $cms,
private readonly ?Receipt $receipt = null,
private readonly bool $fiscalization = false,
) {}
/**
* @throws \DOMException
* @throws \JsonException
*/
public function toXml(): CallbackResponse
{
return CallbackResponse::xml(
MntResponseXml::build(
accountId: $this->accountId,
transactionId: $this->transactionId,
resultCode: $this->resultCode,
amount: $this->amount,
signature: $this->signature->forResponse($this->resultCode, $this->accountId, $this->transactionId),
cms: $this->cms,
attributes: $this->receipt?->toResponseAttributes($this->fiscalization) ?? [],
),
);
}
}