Example #1
0
$message = decodeUtf8($message);
$sigTyp = $_REQUEST["signType"];
$type = $_REQUEST["type"];
$version = $_REQUEST["version"];
//报文体
$amount = $_REQUEST["amount"];
$banks = $_REQUEST["banks"];
$contractName = $_REQUEST["contractName"];
$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", "###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') {
Example #2
0
 public function completePurchase(array $params = array())
 {
     try {
         $merchantId = $params["merchantId"];
         $payNo = $params["payNo"];
         $returnCode = $params["returnCode"];
         $message = $params["message"];
         $signType = $params["signType"];
         $type = $params["type"];
         $version = $params["version"];
         $amount = $params["amount"];
         $amtItem = $params["amtItem"];
         $bankAbbr = $params["bankAbbr"];
         $mobile = $params["mobile"];
         $orderId = $params["orderId"];
         $payDate = $params["payDate"];
         $accountDate = $params["accountDate"];
         $reserved1 = $params["reserved1"];
         $reserved2 = $params["reserved2"];
         $status = $params["status"];
         //            $payType = $params["payType"];
         $orderDate = $params["orderDate"];
         $fee = $params["fee"];
         $vhmac = $params["hmac"];
         if ($returnCode != 00) {
             //此处表示后台通知产生错误
             // echo $returnCode . decodeUtf8($message);
             return ['status' => false, 'message' => $returnCode . decodeUtf8($message)];
         }
         $signData = $merchantId . $payNo . $returnCode . $message . $signType . $type . $version . $amount . $amtItem . $bankAbbr . $mobile . $orderId . $payDate . $accountDate . $reserved1 . $reserved2 . $status . $orderDate . $fee;
         $hmac = Utils::MD5sign($this->getParameter('app_key'), $signData);
         if ($hmac != $vhmac) {
             //此处无法信息数据来自手机支付平台
             return ['status' => false, 'message' => '验签失败'];
         } else {
             return ['status' => true, 'message' => 'SUCCESS'];
         }
     } catch (\Exception $e) {
         return ['status' => false, 'message' => $e->getLine() . ':' . $e->getMessage()];
     }
 }