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

40 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace paygw_moneta\local\protocol;
/**
* Тело и тип ответа модуля на Check URL / Pay URL.
*
* @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 CallbackResponse
{
public const CONTENT_TYPE_XML = 'application/xml; charset=UTF-8';
public const CONTENT_TYPE_JSON = 'application/json; charset=UTF-8';
public const CONTENT_TYPE_TEXT = 'text/plain; charset=UTF-8';
public function __construct(
public readonly string $contentType,
public readonly string $body,
) {}
public static function fail(): self
{
return new self(self::CONTENT_TYPE_TEXT, AssistantProtocol::TEXT_FAIL);
}
public static function xml(string $body): self
{
return new self(self::CONTENT_TYPE_XML, $body);
}
public static function json(string $body): self
{
return new self(self::CONTENT_TYPE_JSON, $body);
}
}