13 'ROBOXCHANGE_SHOPLOGIN',
14 'ROBOXCHANGE_SHOPPASSWORD',
15 'ROBOXCHANGE_SHOPPASSWORD2',
29 $normalizedSettings = $this->normalizeSettings($settings);
31 foreach ($normalizedSettings as $settingCode => $settingValue)
33 $addResult = Sale\Internals\BusinessValueTable::add([
34 'CODE_KEY' => $settingCode,
35 'CONSUMER_KEY' =>
Sale\Internals\BusinessValueTable::COMMON_CONSUMER_KEY,
36 'PERSON_TYPE_ID' =>
Sale\Internals\BusinessValueTable::COMMON_PERSON_TYPE_ID,
37 'PROVIDER_KEY' =>
'VALUE',
38 'PROVIDER_VALUE' => $settingValue,
41 if (!$addResult->isSuccess())
43 $result->addErrors($addResult->getErrors());
48 if ($result->isSuccess())
50 $this->emitAddEvent();
66 $normalizedSettings = $this->normalizeSettings($settings);
68 foreach ($normalizedSettings as $settingCode => $settingValue)
71 'CODE_KEY' => $settingCode,
72 'CONSUMER_KEY' => Sale\Internals\BusinessValueTable::COMMON_CONSUMER_KEY,
73 'PERSON_TYPE_ID' => Sale\Internals\BusinessValueTable::COMMON_PERSON_TYPE_ID,
76 $updateResult = Sale\Internals\BusinessValueTable::update(
79 'PROVIDER_VALUE' => $settingValue,
83 if (!$updateResult->isSuccess())
85 $result->addErrors($updateResult->getErrors());
97 public function delete(): void
104 $this->deleteInternal();
107 private function deleteInternal(): void
109 foreach (self::getSettingsCoded() as $settingsCode)
111 Sale\Internals\BusinessValueTable::deleteByCodeKey($settingsCode);
120 public function get(): array
126 $businessValues = Sale\Internals\BusinessValueTable::getList([
127 'select' => [
'CODE_KEY',
'PROVIDER_VALUE'],
129 '@CODE_KEY' => self::getSettingsCoded(),
130 '=CONSUMER_KEY' =>
Sale\Internals\BusinessValueTable::COMMON_CONSUMER_KEY,
131 '=PERSON_TYPE_ID' =>
Sale\Internals\BusinessValueTable::COMMON_PERSON_TYPE_ID,
135 foreach ($businessValues as $businessValue)
137 $result[$businessValue[
'CODE_KEY']] = $businessValue[
'PROVIDER_VALUE'];
151 $businessValues = Sale\Internals\BusinessValueTable::getList([
152 'select' => [
'CONSUMER_KEY',
'PERSON_TYPE_ID'],
154 '@CODE_KEY' => self::getSettingsCoded(),
156 'group' => [
'CONSUMER_KEY',
'PERSON_TYPE_ID'],
159 if (!$businessValues)
164 $otherSettings = array_filter($businessValues,
static function ($businessValue) {
166 $businessValue[
'CONSUMER_KEY'] !==
null
167 || $businessValue[
'PERSON_TYPE_ID'] !== null
181 return (
bool)Sale\Internals\BusinessValueTable::getList([
182 'select' => [
'CODE_KEY'],
184 '@CODE_KEY' => self::getSettingsCoded(),
190 private function normalizeSettings(array $settings): array
196 static function ($code) use ($settingsCodeList) {
197 return in_array($code, $settingsCodeList,
true);
203 private function emitAddEvent(): void
205 if ($this->isPushAndPullAvailable())
207 $handlerClassName = \Sale\Handlers\PaySystem\RoboxchangeHandler::class;
209 'module_id' =>
'sale',
210 'command' =>
'on_add_paysystem_settings_robokassa',
212 'handlerClassName' => $handlerClassName,
213 'handler' => Sale\PaySystem\Manager::getFolderFromClassName($handlerClassName),
217 \CPullWatch::AddToStack(
'SALE_PAYSYSTEM_ROBOKASSA_REGISTRATION', $message);
221 private function isPushAndPullAvailable(): bool
223 return Main\Loader::includeModule(
'pull');