public static function MobileRecharge($data) { $logger = Logger::getLogger("ofpay"); $logger->info("开始手机充值 : " . print_r($data, true)); $now = date("YmdHis"); $data['money'] = $data['money'] + 0; $hmac = strtoupper(md5(OfpayV3::$merchantId . OfpayV3::$merchantPassword . "140101" . $data['money'] . $data['orderId'] . $now . $data['phone'] . "OFCARD")); $url = "http://api2.ofpay.com/onlineorder.do?userid=" . OfpayV3::$merchantId . "&userpws=" . OfpayV3::$merchantPassword . "&cardid=140101&cardnum=" . $data['money'] . "&sporder_id=" . $data['orderId'] . "&sporder_time={$now}&game_userid=" . $data['phone'] . "&md5_str={$hmac}&ret_url=&version=6.0"; $xml = OfpayV3::Request($url); if ($xml) { $logger->info("完成手机充值,从({$url})返回的结果" . print_r($xml, true)); OfpayV3::Feedback($xml, $data['orderId']); } else { $logger->error("手机充值不成功"); } }
public function CanRecharge() { $logger = Logger::getLogger('mobilerecharge'); $logger->debug("开始判断是否可以充值"); $phone = trim($this->arr_body["phone"]); $money = trim($this->arr_body["money"]); if ($phone == "" || $money == "") { ErrorReponse::reponError(array('retcode' => '200', 'retmsg' => '用户输入信息不完整')); } $canRecharge = OfpayV3::CanMobileRecharge($phone, $money); $retcode = "0"; if ($canRecharge) { $arr_message = array("result" => "success", "message" => "可以充值"); } else { $arr_message = array("result" => "fail", "message" => "该面值暂不可以充值"); } $arr_msg['msgbody']['result'] = $arr_message['result']; $arr_msg['msgbody']['message'] = $arr_message['message']; $returnvalue = array("msgbody" => $arr_msg['msgbody']); $logger->debug("判断是否可以充值的结果" . print_r($returnvalue, true)); $returnval = TfbxmlResponse::ResponsetoApp($retcode, $returnvalue); return $returnval; }
<?php require_once "../class/Logger.php"; Logger::configure("../class/Logger.ini"); require_once "../include/config.inc.php"; __BeginRecivePostData(); __EndRecivePostData(); switch ($_POST['FUNC']) { case 'MOBILE_RECHARGE': require_once "../third_api/ofpay/ofpayV3.class.php"; OfpayV3::MobileRecharge($_POST); break; case 'GAME_RECHARGE': require_once "../third_api/ofpay/ofpayV2.class.php"; OfpayV2::GameRecharge($_POST); break; case 'SEND_SMS': require_once "../third_api/sendsms.php"; SendMessage($_POST); break; } /* * 接口开始接收POST数据 */ function __BeginRecivePostData() { ob_end_clean(); header("Connection: close\r\n"); // 这里的冒号前面不能有空格 header("Content-Encoding: none\r\n"); ignore_user_abort();