function refundTest() { $merNo = '20081'; $gatewayNo = '20081001'; $signkey = '46rrj486'; $tradeNo = 1; $refundType = 1; $tradeAmount = '10.00'; $refundAmount = '10.00'; $currency = 'GBP'; $refundReason = 'refund'; $remark = ''; $signsrc = htmlspecialchars($merNo . $gatewayNo . $tradeNo . $refundType . $signkey); $signInfo = hash('sha256', $signsrc); $correct_url = 'https://check.onlinesslconnect.com:8081/servlet/ApplyRefund'; $params = array('merNo' => $merNo, 'gatewayNo' => $gatewayNo, 'tradeNo' => $tradeNo, 'signInfo' => $signInfo, 'refundType' => $refundType, 'tradeAmount' => $tradeAmount, 'refundAmount' => $refundAmount, 'currency' => $currency, 'refundReason' => $refundReason, 'remark' => $remark = ''); $result_data = socketPost($correct_url, $params); echo '<pre>'; print_r($params); echo '</pre>'; $xml = new DOMDocument(); $xml->loadXML($result_data); $orderNo = $xml->getElementsByTagName("orderNo")->item(0)->nodeValue; $orderInfo = $xml->getElementsByTagName("orderInfo")->item(0)->nodeValue; // echo $orderInfo; echo $result_data; }
/** * http post */ function httpRequest($url, $post_string, $connectTimeout = CONNECT_TIMEOUT, $readTimeout = READ_TIMEOUT) { $result = ""; if (function_exists('curl_init')) { $timeout = $connectTimeout + $readTimeout; // Use CURL if installed... $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connectTimeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, '139.com API PHP5 Client 1.1 (curl) ' . phpversion()); $result = curl_exec($ch); curl_close($ch); } else { // Non-CURL based version... $result = socketPost($url, $post_string, $connectTimeout = CONNECT_TIMEOUT, $readTimeout = READ_TIMEOUT); } return $result; }