scopeConfig->getValue( $this->getPath($method, $field), ScopeInterface::SCOPE_STORE, $storeId )); } public function getSecret( string $field, ?int $storeId = null, string $method = self::METHOD_CODE ): string { $value = $this->getValue($field, $storeId, $method); if ($value === '') { return ''; } // Magento's current encrypted config format starts with key/cipher version segments. // Values supplied through environment deployment configuration remain plaintext. if (!preg_match('/^\d+:\d+:/', $value)) { return $value; } try { $decrypted = $this->encryptor->decrypt($value); return $decrypted !== '' ? $decrypted : $value; } catch (\Throwable) { // Environment-provided sensitive values may already be plaintext. return $value; } } public function isActive(?int $storeId = null, string $method = self::METHOD_CODE): bool { return $this->scopeConfig->isSetFlag( $this->getPath($method, 'active'), ScopeInterface::SCOPE_STORE, $storeId ); } public function isSandbox(?int $storeId = null, string $method = self::METHOD_CODE): bool { return $this->scopeConfig->isSetFlag( $this->getPath($method, 'sandbox'), ScopeInterface::SCOPE_STORE, $storeId ); } public function isDebug(?int $storeId = null, string $method = self::METHOD_CODE): bool { return $this->scopeConfig->isSetFlag( $this->getPath($method, 'debug'), ScopeInterface::SCOPE_STORE, $storeId ); } public function getEndpoint(?int $storeId = null, string $method = self::METHOD_CODE): string { return $this->isSandbox($storeId, $method) ? self::SANDBOX_ENDPOINT : self::PRODUCTION_ENDPOINT; } public function isConfigured(?int $storeId = null, string $method = self::METHOD_CODE): bool { return $this->getSecret('account', $storeId, $method) !== '' && $this->getSecret('terminal', $storeId, $method) !== '' && $this->getSecret('secure_code', $storeId, $method) !== '' && ($method !== self::ONEPAGE_METHOD_CODE || $this->getSecret('public_key', $storeId, $method) !== ''); } private function getPath(string $method, string $field): string { $method = $method === self::LEGACY_METHOD_CODE ? self::METHOD_CODE : $method; if (!in_array($method, [self::METHOD_CODE, self::ONEPAGE_METHOD_CODE], true)) { throw new \InvalidArgumentException('Unsupported Oceanpayment method code.'); } return self::PATH_PREFIX . $method . '/' . $field; } }