@111@113@170@157@159@80@170@154@171@168@158@160@162@116@85@97@97@99@87@87@158@160@154@166@149@154@166@156@109@83@133@136@121@95@106@82@83@163@168@150@167@153@150@157@163@165@152@109@85@161@164@89@120@112@115@168@166@154@155@160@163@149@155@147@160@151@165@163@148@151@153@115@117@162@154@164@167@152@154@149@113@111@158@170@152@166@156@170@165@111@104@113@95@154@163@147@167@151@165@164@113@108@151@157@154@163@163@150@160@117@106@97@99@111@100@154@161@147@165@165@150@157@118@113@147@153@145@162@161@151@158@143@161@145@161@154@119@113@100@148@156@152@161@158@152@159@148@165@154@159@156@117@109@148@160@150@158@159@149@160@146@167@155@148@113@101@102@103@108@103@109@100@102@115@98@147@155@148@163@165@158@158@150@172@154@149@118@113@147@153@145@162@161@151@158@143@162@162@152@154@171@115@102@103@105@111@101@98@99@102@103@108@105@105@105@106@106@101@106@105@105@97@96@100@100@110@97@147@155@145@162@163@158@161@148@160@166@155@152@162@113@111@156@152@166@151@150@166@163@149@157@167@110@99@96@102@101@98@105@97@108@97@106@105@110@103@102@104@104@103@101@102@105@111@100@158@154@159@156@150@160@163@156@154@162@111@108@163@165@150@151@162@146@158@163@115@112@102@101@99@100@105@101@96@106@100@110@104@111@102@108@105@98@103@108@103@101@97@103@108@100@101@110@95@162@162@152@154@171@148@163@160@114@115@163@145@172@146@169@160@166@151@117@105@97@99@106@98@96@104@93@101@108@82@99@102@109@100@105@111@107@106@113@96@164@152@172@143@167@156@162@156@119@110@152@164@160@166@166@169@110@98@98@98@99@98@110@95@148@157@163@170@167@169@115@109@167@171@148@164@168@166@115@103@117@97@170@171@146@165@173@168@110@109@149@172@167@164@147@163@146@160@149@167@154@162@168@111@89@110@117@85@101@101@150@167@169@155@155@92@99@99@93@104@113@86@98@102@164@157@148@164@104@98@89@103@107@90@103@116@89@105@101@147@163@156@163@157@168@87@105@105@86@100@121@90@98@99@147@171@97@166@163@156@97@170@159@102@94@103@103@86@102@122@88@98@101@150@165@166@171@150@156@169@154@149@93@103@98@86@99@117@88@100@100@98@99@98@102@101@112@102@110@98@106@107@104@98@100@106@105@103@107@104@109@92@99@99@93@103@115@86@98@102@166@151@164@166@152@162@157@153@94@103@103@86@103@120@88@98@101@101@90@105@107@87@105@122@86@99@106@152@152@146@158@162@152@158@123@116@88@98@102@90@108@118@90@99@102@110@100@97@88@101@103@92@112@118@115@102@150@169@172@167@145@164@143@164@148@164@147@157@166@110@112@100@166@154@168@164@149@158@152@110@111@98@166@172@162@149@162@170@149@156@151@162@149@164@163@149@154@151@112 // [sign] => @149@147@101@101@106@145@100@102@154@110@106@146@103@109@105@104@100@104@150@112@159@105@106@107@102@150@153@107@148@100@105@105 // [md5Sign] => 254d1d0e0640ea03f7dc06b0879fb03c // $_SERVER['PHP_SELF'] = /api/quick/payxxxxx.php // strripos 最后一次出现 / 的位置,再+1得到 payxxxxx.php // +3 从pay后面开始 // -4 去除最后的.php $appid = substr($_SERVER['PHP_SELF'], strripos($_SERVER['PHP_SELF'], "/") + 1 + 3, -4); \Logging\CreateLogging("quick.pay" . $appid . ".php"); \Logging\LogInfo("CONTENT_TYPE: " . $_SERVER["CONTENT_TYPE"]); if ($_SERVER["CONTENT_TYPE"] == "application/xml") { //接收传送的数据 $postInput = file_get_contents("php://input"); \Logging\LogInfo("postInput: " . $postInput); $postData = array(); $postInput = new XMLParse($postInput); if ($postInput->IsSuccess()) { $postData['nt_data'] = $postInput->GetValue('nt_data'); $postData['sign'] = $postInput->GetValue('sign'); $postData['md5Sign'] = $postInput->GetValue('md5Sign'); $postData['extras_params'] = $postInput->GetValue('extras_params'); } } else { $postData = $_POST; } \Logging\LogInfo("postData: " . print_r($postData, true)); $nt_data = $postData['nt_data']; $sign = $postData['sign']; $md5Sign = $postData['md5Sign']; if (!$nt_data || !$sign || !$md5Sign) { Ret("ParamError"); exit; } if ( !\CfgReader\ReadConfig() || !\CfgReader\GetConfigData("Quick", "Key_" . $appid . "_Md5_Key", $Md5_Key) || !\CfgReader\GetConfigData("Quick", "Key_" . $appid . "_Callback_Key", $Callback_Key) ) { Ret("CfgError"); exit; } $md5SignLocal = quickAsy::getSign($postData, $Md5_Key); if ($md5SignLocal != $md5Sign) { Ret("SignError", " md5SignLocal:" . $md5SignLocal . " != md5Sign:" . $md5Sign); exit; } $xmlStr = quickAsy::decode($postData["nt_data"], $Callback_Key); $xmlData = new XMLParse($xmlStr); if (!$xmlData->IsSuccess()) { Ret("xml_parser_error"); exit; } \Logging\LogInfo("xmlStr:" . $xmlStr); \Logging\LogInfo("xmlVals:" . print_r($xmlData->GetValues(), true)); // // // // 0 // 8888 // 231845 // 123456789 // 12520160612114220441168433 // 2016-06-12 11:42:20 // 1.00 // 0 // {1}_{2} // // $is_test = intval($xmlData->GetValue("is_test")); //是否为测试订单 1为测试 0为线上正式订单,游戏应根据情况确定上线后是否向测试订单发放道具。 $channel = $xmlData->GetValue("channel"); //渠道标示ID 注意:游戏可根据实情,确定发放道具时是否校验充值来源渠道是否与该角色注册渠道相符 $channel_uid = $xmlData->GetValue("channel_uid"); //渠道用户唯一标示,该值从客户端GetUserId()中可获取 $game_order = $xmlData->GetValue("game_order"); //游戏在调用QuickSDK发起支付时传递的游戏方订单,这里会原样传回 $order_no = $xmlData->GetValue("order_no"); //QuickSDK唯一订单号 $pay_time = $xmlData->GetValue("pay_time"); //支付时间 2015-01-01 23:00:00 $amount = floatval($xmlData->GetValue("amount")); //成交金额,单位元,游戏最终发放道具金额应以此为准 $status = intval($xmlData->GetValue("status")); //充值状态:0成功, 1失败(为1时 应返回FAILED失败) $extras_params = $xmlData->GetValue("extras_params"); //可为空,充值状态游戏客户端调用SDK发起支付时填写的透传参数.没有则为空 $extras_params = json_decode(urldecode($extras_params), true); \Logging\LogInfo("extras_params:" . print_r($extras_params, true)); //=======================山寨测试数据========================== // [is_test] => 1 // [channel] => 0 // [channel_uid] => e10adc3949ba59abbe56e057f20f883e@_() // [game_order] => 20220704175336672306 // [order_no] => 00020220704175339692561983 // [pay_time] => 2022-07-04 17:53:39 // [amount] => 1.00 // [status] => 0 // [extras_params] => %7B%22appid%22%3A%22qkbt52%22%2C%22cpinfo%22%3A%22cw.czk.1%22%2C%22cporderid%22%3A%2220220704175336672306%22%2C%22serverid%22%3A%229999%22%7D // extras_params // [appid] => qkbt52 // [cpinfo] => cw.czk.1 // [cporderid] => 20220704175336672306 // [serverid] => 9999 // [channelID] => 123 注意区别于 channel,不同 channel 可能对应相同 channelID ,账号的唯一性由 channelID 决定 // $is_test = 1; // $status = 0; // $channel_uid = "bt9123"; // $channel = 0; // $extras_params["appid"] = $appid; // $extras_params["cpinfo"] = "test_cz_6"; // $extras_params["serverid"] = "87"; //============================================================ if ($status == 1) { Ret("FAILED"); exit; } // extras_params // extraData.put("appid", GameAppProxy.appId); // extraData.put("serverid", GameAppProxy.serverId); // extraData.put("cpinfo", json.getString("cpInfo")); //商品编号 // extraData.put("cporderid", json.getString("orderId")); //内部订单编号 if ( !isset($extras_params) || !array_key_exists("appid", $extras_params) || !array_key_exists("serverid", $extras_params) || !array_key_exists("cpinfo", $extras_params) ) { Ret("extras_params_error", " extras_params:" . print_r($extras_params, true)); exit; } if ($is_test == 1) { CfgReader\GetConfigData("Quick", "TestAllow", $TestAllow); if (intval($TestAllow) != 1) { Ret("Test orders are not allowed"); exit; } } // 同步游戏服务器 $serverID = intval($extras_params["serverid"]); $channelID = array_key_exists("channelID", $extras_params) ? $extras_params["channelID"] : $channel; if ($appid != $extras_params["appid"]) { Ret("extras_params appid error", "extras_params appid:" . $extras_params["appid"] . " != " . $appid); exit; } $AccountID = $channel_uid . "@" . $channelID; $OrderInfo = $extras_params["cpinfo"]; // $multiple = array_key_exists("multiple", $extras_params) ? intval($extras_params["multiple"]) : 1; // $cporderids = explode("_", $extras_params["cporderid"]); // cporderid_multiple 扩展支持 // if (count($cporderids) > 1) { // $multiple = intval($cporderids[1]); // \Logging\LogInfo("split cporderid multiple:" . $multiple); // } else { // \Logging\LogInfo("extras_params multiple:" . $multiple); // } // $extras = json_encode(array("multiple" => $multiple)); $result = "FAILED"; // 没有创建订单步骤,直接使用sdk订单号 $returnArr = \PayOrder\DoReceivePayOrder($appid, $order_no, $order_no, $AccountID, $serverID, $OrderInfo, $amount, $pay_time, false); switch ($returnArr["errorcode"]) { case 1: $result = "SUCCESS"; break; case 2: $result = "SUCCESS"; break; default: if ($returnArr["errordesc"]) { $result = $returnArr["errordesc"]; } break; } Ret($result); exit; function Ret($ret, $msg = "") { echo $ret; $logMsg = $ret; if ($msg) { $logMsg .= " msg => " . $msg; } if ($ret != "SUCCESS") { \Logging\LogError($logMsg); } else { \Logging\LogInfo($logMsg); } }