71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MonetaPhpShop\protocol;
|
|
|
|
use MonetaPhpShop\Money;
|
|
|
|
/**
|
|
* Îòâåò íà óâåäîìëåíèå îá îïëàòå (Pay URL): âñåãäà XML `MNT_RESPONSE`, íåçàâèñèìî îò íàñòðîéêè
|
|
* ôèñêàëèçàöèè. `MNT_ATTRIBUTES` — òîëüêî â óñïåøíîì îòâåòå, ñîñòàâ çàâèñèò îò ôèñêàëèçàöèè.
|
|
*/
|
|
final class PayResponse
|
|
{
|
|
/** @var string */
|
|
private $accountId;
|
|
|
|
/** @var string */
|
|
private $transactionId;
|
|
|
|
/** @var Money */
|
|
private $amount;
|
|
|
|
/** @var ResultCode */
|
|
private $resultCode;
|
|
|
|
/** @var Signature */
|
|
private $signature;
|
|
|
|
/** @var string */
|
|
private $cms;
|
|
|
|
/**
|
|
* @param string $transactionId ðîâíî òî, ÷òî ïðèñëàë ñåðâèñ
|
|
*/
|
|
public function __construct(
|
|
string $accountId,
|
|
string $transactionId,
|
|
Money $amount,
|
|
ResultCode $resultCode,
|
|
Signature $signature,
|
|
string $cms
|
|
) {
|
|
$this->accountId = $accountId;
|
|
$this->transactionId = $transactionId;
|
|
$this->amount = $amount;
|
|
$this->resultCode = $resultCode;
|
|
$this->signature = $signature;
|
|
$this->cms = $cms;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, string> $attributes `INVENTORY`, `CLIENT`, `CUSTOMER`, `PHONE`
|
|
* @throws \DOMException
|
|
*/
|
|
public function toXml(array $attributes = []): CallbackResponse
|
|
{
|
|
return CallbackResponse::xml(
|
|
MntResponseXml::build(
|
|
$this->accountId,
|
|
$this->transactionId,
|
|
$this->resultCode,
|
|
$this->amount,
|
|
$this->signature->forResponse($this->resultCode, $this->accountId, $this->transactionId),
|
|
$this->cms,
|
|
$attributes,
|
|
),
|
|
);
|
|
}
|
|
}
|