Example #1
0
$invoiceTitle = $_REQUEST["invoiceTitle"];
$invoiceTitle = decodeUtf8($invoiceTitle);
$mobile = $_REQUEST["mobile"];
$orderId = $_REQUEST["orderId"];
$payDate = $_REQUEST["payDate"];
$reserved = $_REQUEST["reserved"];
$reserved = decodeUtf8($reserved);
$status = $_REQUEST["status"];
$amtItem = $_REQUEST["amtItem"];
$signData = $merchantId . $payNo . $requestId . $returnCode . $message . $sigTyp . $type . $version . $amount . $banks . $contractName . $invoiceTitle . $mobile . $orderId . $payDate . $reserved . $status;
// if($version == "1.0.1")
$signData = $merchantId . $payNo . $requestId . $returnCode . $message . $sigTyp . $type . $version . $amount . $banks . $contractName . $invoiceTitle . $mobile . $orderId . $payDate . $reserved . $status . $amtItem;
$hash = hmac("", $signData);
$newhmac = hmac($signKey, $hash);
RecordLog("YGM", "###hmac" . $hmac . "###");
RecordLog("YGM", "###newhmac" . $newhmac . "###");
@(list($_, $order_id, $city_id, $_) = explode('-', $orderId, 4));
if (Table::Fetch('pay', $orderId)) {
    die('SUCCESS');
}
$v_amount = $amount / 100;
if ($_ == 'charge') {
    if ($newhmac == $hmac) {
        @(list($_, $user_id, $create_time, $_) = explode('-', $orderId, 4));
        ZFlow::CreateFromCharge($v_amount, $user_id, $create_time, 'cmpay');
        // 记录日志
        RecordMyLog("流水号:" . $payNo);
        RecordMyLog("支付金额:" . $amount);
        RecordMyLog("金额明细:" . $amtItem);
        RecordMyLog("支付银行:" . $banks);
        RecordMyLog("送货信息:" . $contractName);
Example #2
0
 protected function _post($data)
 {
     $url = $this->_server;
     $url = parse_url($url);
     if (!$url) {
         RecordLog("couldn't parse url");
         return "couldn't parse url";
     }
     if (!isset($url['port'])) {
         $url['port'] = "";
     }
     if (!isset($url['query'])) {
         $url['query'] = "";
     }
     $encoded = "";
     foreach ($data as $k => $v) {
         $encoded .= $encoded ? "&" : "";
         $encoded .= rawurlencode($k) . "=" . rawurlencode($v);
     }
     $urlHead = null;
     $urlPort = $url['port'];
     if ($url['scheme'] == "https") {
         $urlHead = "ssl://" . $url['host'];
         if ($url['port'] == null || $url['port'] == 0) {
             $urlPort = 443;
         }
     } else {
         $urlHead = $url['host'];
         if ($url['port'] == null || $url['port'] == 0) {
             $urlPort = 80;
         }
     }
     $fp = fsockopen($urlHead, $urlPort);
     if (!$fp) {
         return "Failed to open socket to {$url['host']}";
     }
     $tmp = "";
     $tmp .= sprintf("POST %s%s%s HTTP/1.0\r\n", $url['path'], $url['query'] ? "?" : "", $url['query']);
     $tmp .= "Host: {$url['host']}\r\n";
     $tmp .= "Content-type: application/x-www-form-urlencoded\r\n";
     $tmp .= "Content-Length: " . strlen($encoded) . "\r\n";
     $tmp .= "Connection: close\r\n\r\n";
     $tmp .= "{$encoded}\r\n";
     fputs($fp, $tmp);
     $line = fgets($fp, 1024);
     if (!preg_match('#^HTTP/1\\.. 200#i', $line)) {
         $logstr = "MSG" . $line;
         return array("FLAG" => 0, "MSG" => $line);
     }
     $results = "";
     $inheader = 1;
     while (!feof($fp)) {
         $line = fgets($fp, 1024);
         if ($inheader && ($line == "\n" || $line == "\r\n")) {
             $inheader = 0;
         } elseif (!$inheader) {
             $results .= $line;
         }
     }
     fclose($fp);
     return array("FLAG" => 1, "MSG" => $results);
 }
Example #3
0
function RecordMyLog($text) {
	RecordLog("YGM",$text);
}
Example #4
0
function parseRecv($source)
{
    $ret = array();
    $temp = explode("&", $source);
    RecordLog("YGM", "**\$" . $source . "\$**");
    RecordLog("yu", "**%" . $source . "%**");
    foreach ($temp as $value) {
        $tempKey = explode("=", $value);
        $ret[$tempKey[0]] = $tempKey[1];
    }
    return $ret;
}
Example #5
0
$contractName = decodeUtf8($contractName);
$invoiceTitle = $_REQUEST["invoiceTitle"];
$invoiceTitle = decodeUtf8($invoiceTitle);
$mobile = $_REQUEST["mobile"];
$orderId = $_REQUEST["orderId"];
$payDate = $_REQUEST["payDate"];
$reserved = $_REQUEST["reserved"];
$reserved = decodeUtf8($reserved);
$status = $_REQUEST["status"];
$amtItem = $_REQUEST["amtItem"];
$signData = $merchantId . $payNo . $requestId . $returnCode . $message . $sigTyp . $type . $version . $amount . $banks . $contractName . $invoiceTitle . $mobile . $orderId . $payDate . $reserved . $status;
//if($version == "1.0.1")
$signData = $merchantId . $payNo . $requestId . $returnCode . $message . $sigTyp . $type . $version . $amount . $banks . $contractName . $invoiceTitle . $mobile . $orderId . $payDate . $reserved . $status . $amtItem;
$hash = hmac("", $signData);
$newhmac = hmac($signKey, $hash);
RecordLog("YGM", "###backurl" . $hmac . "backurl###");
RecordMyLog("*backurl*" . $hmac . "*backurl*");
@(list($_, $order_id, $city_id, $_) = explode('-', $orderId, 4));
$v_amount = $amount / 100;
//print_r($v_amount);
//exit;
if ($_ == 'charge') {
    if ($newhmac == $hmac) {
        $pay = Table::Fetch('pay', $orderId);
    }
    if ($pay) {
        Session::Set('notice', "手机支付充值{$v_amount}元成功!");
    }
    /* @list($_, $user_id, $create_time, $_) = explode('-', $orderId, 4);
    		if(ZFlow::CreateFromCharge($v_amount, $user_id, $create_time, 'cmpay')){
    			Session::Set('notice', "手机支付充值{$v_amount}元成功!");