X2000051789 <�秘钥> ef03cc337b3f4d47bb245f51bff9adfe <�商户简称> VIP-阿伟 供应商-4 <�登录账号> eugene57@126.com <�登录密码> MZKECL <�手机号码> 13811398308 谢谢! */ # 电话充值 public function dhcz($param) { $check = array ( # key值是传入的数据,value是传出的数据 'mobile' => 'phoneNo', 'cash' => 'txnAmt', 'gateway' => 'gateway', ); $param['gateway'] = $this->mobile($param['mobile']); if (!$param['gateway']) { return '不支持的手机号码'; } return $this->submit($param, $check); } # 通知处理 主要返回状态 2是成功 3是失败 public function notify($data) { $request = $data; unset($request['signMethod']); unset($request['signature']); unset($request['s_order']); $sign = base64_encode(strtolower($this->sign($request, 'md5', $this->token, '', false))); if ($sign != $data['signature']) { return false; } $result = array(); $result['data'] = $data; $result['cash'] = floatval($data['txnAmt']/100); if ($data['respCode'] == '1001') { $result['status'] = 2; } else { $result['status'] = 3; } return $result; } # 数据响应格式处理 public function response($data) { $log['type'] = 'response'; $log['data'] = $data; $log['config'] = $this->data; $this->log($log); $array = $this->json_decode($data); if (!$array) { $msg = 'error'; } elseif (isset($array['success']) && $array['success'] == 1) { $msg = 'ok'; } else { $msg = $array['msg']; } return array ( 'msg' => $msg, 'data' => $data, 'array' => $array, ); } # 查询接口 public function query($param) { } # 提交数据 private function submit($param, $check) { $param = $this->param($param, $check); if (is_string($param) || (is_array($param) && $param['status'] == 1)) { return $param; } $request = $param['detail']; $request['txnAmt'] = $request['txnAmt'] * 100; $request['merchantId'] = $this->mid; $request['merOrderId'] = $param['order']; $request['backUrl'] = $this->getNotify($param['order'], 1); $request['sendTime'] = date('YmdHis'); $request['signature'] = base64_encode(strtolower($this->sign($request, 'md5', $this->token))); $request['signMethod'] = 'MD5'; $url = $this->host . 'mobile/pay'; $data = $this->curl('post', $url, $request); $response = $this->response($data); $channel_order_id = ''; $this->create($param['order'], $channel_order_id, $param['merchant_order'], $param['cash'], $url, $request, $response, 1, $param['account']); return $response['msg']; } private function mobile($mobile) { $url = 'http://cx.shouji.360.cn/phonearea.php?number=' . $mobile; $data = $this->curl('get', $url); if ($data) { $data = json_decode($data, true); if ($data && isset($data['data']['sp'])) { $sp = $data['data']['sp']; if ($sp == '移动') { return false; return 'YDQ'; } elseif ($sp == '联通') { return 'LTQ'; } elseif ($sp == '电信') { return 'DXQ'; } } } return false; } }