NVP */ public function call(string $url, string $outerCpid, array $reqData, string $hexKey, string $hexIv): array { $sendData = []; foreach ($reqData as $k => $v) { $sendData[$k] = is_string($v) ? $this->euc->toEuc($v) : $v; } $plain = $this->nvp->build($sendData); $enc = $this->aes->encrypt($plain, $hexKey, $hexIv); $payload = 'CPID=' . $outerCpid . '&DATA=' . urlencode($enc); $httpOpt = config('danal.http'); $res = Http::withOptions([ 'verify' => (bool)($httpOpt['verify_ssl'] ?? true), 'connect_timeout' => (float)($httpOpt['connect_timeout'] ?? 5), ]) ->withHeaders([ 'Content-Type' => 'application/x-www-form-urlencoded; charset=euc-kr', ]) ->timeout((int)($httpOpt['timeout'] ?? 30)) ->withBody($payload, 'application/x-www-form-urlencoded; charset=euc-kr') ->post($url); $body = (string)$res->body(); $map = $this->nvp->parse($body); // 응답이 DATA를 포함하면 decrypt 후 재파싱 if (isset($map['DATA']) && is_string($map['DATA']) && $map['DATA'] !== '') { $dec = $this->aes->decrypt($map['DATA'], $hexKey, $hexIv); $map = $this->nvp->parse($dec); } // 메시지는 EUC-KR일 수 있으니 UTF-8 변환 return $this->euc->mapToUtf8($map); } public function decryptReturnParams(string $returnParams, string $hexKey, string $hexIv): array { $dec = $this->aes->decrypt($returnParams, $hexKey, $hexIv); $map = $this->nvp->parse($dec); return $this->euc->mapToUtf8($map); } }