feat: paygw_moneta 1.0.2, receipt attributes by fiscalization, pm/po settings

This commit is contained in:
2026-10-12 13:24:13 +03:00
parent 2be833119b
commit e4e04236cc
17 changed files with 234 additions and 75 deletions
+6 -2
View File
@@ -31,9 +31,12 @@ final class CheckResponse
}
/**
* XML без атрибутов — для мерчанта без кассового сервиса.
* XML — для мерчанта без кассового сервиса
*
* @throws \DOMException
* @throws \JsonException
*/
public function toXml(): CallbackResponse
public function toXml(?Receipt $receipt = null): CallbackResponse
{
return CallbackResponse::xml(
MntResponseXml::build(
@@ -43,6 +46,7 @@ final class CheckResponse
amount: $this->amount,
signature: $this->sign(),
cms: $this->cms,
attributes: $receipt?->toResponseAttributes(fiscalization: false) ?? [],
),
);
}
+2 -12
View File
@@ -22,6 +22,7 @@ final class PayResponse
private readonly Signature $signature,
private readonly string $cms,
private readonly ?Receipt $receipt = null,
private readonly bool $fiscalization = false,
) {}
/**
@@ -30,17 +31,6 @@ final class PayResponse
*/
public function toXml(): CallbackResponse
{
$attributes = [];
if ($this->receipt !== null) {
$attributes['INVENTORY'] = $this->receipt->toInventoryAttribute();
$attributes['CLIENT'] = $this->receipt->toClientAttribute();
$duplicates = [
'CUSTOMER' => $this->receipt->toCustomerAttribute(),
'PHONE' => $this->receipt->toPhoneAttribute(),
];
$attributes += array_filter($duplicates, static fn(?string $value): bool => $value !== null);
}
return CallbackResponse::xml(
MntResponseXml::build(
accountId: $this->accountId,
@@ -49,7 +39,7 @@ final class PayResponse
amount: $this->amount,
signature: $this->signature->forResponse($this->resultCode, $this->accountId, $this->transactionId),
cms: $this->cms,
attributes: $attributes,
attributes: $this->receipt?->toResponseAttributes($this->fiscalization) ?? [],
),
);
}
+2 -2
View File
@@ -26,9 +26,9 @@ enum PaymentServer: string
}
/**
* Ключ строки интерфейса (`server_prod`, `server_demo`).
* Ключ строки в `lang/{ru,en}/paygw_moneta.php` (`server_prod`, `server_demo`).
*/
public function label(): string
public function langKey(): string
{
return 'server_' . strtolower($this->value);
}