feat: moneta 2.0, MONETA.Assistant payment module for PHPShop 6.7+
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?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];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user