/** * Ping AvaTax using configured live/production mode * * @param $scopeId * @param $scopeType * @return array */ protected function sendPing($scopeId, $scopeType) { $errors = []; if (!$this->config->isModuleEnabled($scopeId, $scopeType)) { return $errors; } $message = ''; $type = $this->config->getLiveMode() ? Config::API_PROFILE_NAME_PROD : Config::API_PROFILE_NAME_DEV; try { $result = $this->interactionTax->getTaxService($type, $scopeId, $scopeType)->ping(); if (is_object($result) && $result->getResultCode() != \AvaTax\SeverityLevel::$Success) { foreach ($result->getMessages() as $messages) { $message .= $messages->getName() . ': ' . $messages->getSummary() . "\n"; } } elseif (is_object($result) && $result->getResultCode() == \AvaTax\SeverityLevel::$Success) { $this->messageManager->addSuccess(__('Successfully connected to AvaTax using the ' . '<a href="#row_tax_avatax_connection_settings_header">%1 credentials</a>', $type)); } } catch (\Exception $exception) { $message = $exception->getMessage(); } if ($message) { $errors[] = __('Error connecting to AvaTax using the ' . '<a href="#row_tax_avatax_connection_settings_header">%1 credentials</a>: %2', $type, $message); } return $errors; }
/** * Pass all undefined method calls through to Tax Service * * @param $name * @param array $arguments * @return mixed */ public function __call($name, array $arguments) { return call_user_func_array([$this->taxInteraction->getTaxService($this->type), $name], $arguments); }