상점정보 > 계약정보 > 부가정보 > INIAPI key 생성조회 $key = isset($args['key']) ? $args['key'] : get_inicis_iniapi_key(); $type = "Refund"; // 고정 $paymethod = isset($args['paymethod']) ? $args['paymethod'] : "Card"; $timestamp = isset($args['timestamp']) ? $args['timestamp'] : date("YmdHis"); $clientIp = isset($args['clientIp']) ? $args['clientIp'] : $_SERVER['SERVER_ADDR']; $mid = isset($args['mid']) ? $args['mid'] : $default['de_inicis_mid']; $tid = $args['tid']; $msg = $args['msg']; // 부분취소인 경우 if ($is_part){ $type = 'PartialRefund'; $price = $args['price']; $confirmPrice = $args['confirmPrice']; // INIAPIKey + type + paymethod + timestamp + clientIp + mid + tid + price + confirmPrice $hashData = hash("sha512",(string)$key.(string)$type.(string)$paymethod.(string)$timestamp.(string)$clientIp.(string)$mid.(string)$tid.(string)$price.(string)$confirmPrice); // hash 암호화 //step2. key=value 로 post 요청 $data = array( 'type' => $type, 'paymethod' => $paymethod, 'timestamp' => $timestamp, 'clientIp' => $clientIp, 'mid' => $mid, 'tid' => $tid, 'price' => $price, 'confirmPrice' => $confirmPrice, 'msg' => $msg, 'hashData'=> $hashData ); } else { // 전체취소인 경우 // INIAPIKey + type + paymethod + timestamp + clientIp + mid + tid $hashData = hash("sha512", (string)$key.(string)$type.(string)$paymethod.(string)$timestamp.(string)$clientIp.(string)$mid.(string)$tid); // hash 암호화 //step2. key=value 로 post 요청 $data = array( 'type' => $type, 'paymethod' => $paymethod, 'timestamp' => $timestamp, 'clientIp' => $clientIp, 'mid' => $mid, 'tid' => $tid, 'msg' => $msg, 'hashData'=> $hashData ); } $url = "https://iniapi.inicis.com/api/v1/refund"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded; charset=utf-8')); curl_setopt($ch, CURLOPT_POST, 1); $response = curl_exec($ch); curl_close($ch); //step3. 요청 결과 return $response; } function get_type_inicis_paymethod($od_settle_case){ $ini_paymethod = ''; switch ($od_settle_case) { case '신용카드': case '간편결제': $ini_paymethod = 'Card'; break; case '가상계좌': $ini_paymethod = 'GVacct'; // 가상계좌 (입금전, 채번취소 시 사용) break; case '계좌이체': $ini_paymethod = 'Acct'; break; case '휴대폰': $ini_paymethod = 'HPP'; break; } if (! $ini_paymethod) { if (is_inicis_order_pay($od_settle_case)) { $ini_paymethod = 'Card'; } } return $ini_paymethod; }