Files
PHPShop/moneta/class/protocol/PaymentServer.php
T

49 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace MonetaPhpShop\protocol;
/**
* Ñåðâåð ïëàò¸æíîé ôîðìû MONETA.Assistant. Ó äåìî-ïëîùàäêè ñâîé íîìåð ñ÷¸òà.
* Çíà÷åíèÿ `PROD`/`DEMO` õðàíÿòñÿ â íàñòðîéêàõ ìîäóëÿ — íå ïåðåèìåíîâûâàòü.
*/
final class PaymentServer
{
public const PROD = 'PROD';
public const DEMO = 'DEMO';
private const URLS = [
self::PROD => 'https://www.payanyway.ru/assistant.htm',
self::DEMO => 'https://demo.moneta.ru/assistant.htm',
];
/** @var string */
private $value;
private function __construct(string $value)
{
$this->value = $value;
}
public static function fromSetting(?string $value): self
{
return new self(isset(self::URLS[(string) $value]) ? (string) $value : self::PROD);
}
public function getValue(): string
{
return $this->value;
}
public function isDemo(): bool
{
return ($this->value === self::DEMO);
}
public function url(): string
{
return self::URLS[$this->value];
}
}