payUrl); $timeout = 6000; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER,0 ); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 $payAmount = intval($pay_amount * 100); $data = array( 'merAccount' => $this->merAccount, //商户标识 'merNo' => $this->merNo, //商户编号 'time' => time(),//时间戳 'orderId' => $order_no,//订单号 'amount' => $payAmount,//交易金额(分) 'product' => $title,//商品 'productDesc' => $title,//商品描述 'payWay' => 'WEIXIN', 'payType' => 'H5_WEIXIN', // 'openId' => 'ojmRm1jJzNSBK-6RxFFdNE30E4_4', 'userIp' => Request::instance()->ip(), 'returnUrl' => $return_url, //前端页面回调地址 'notifyUrl' => $notify_url//后台回调地址 ); $data['sign'] = getSign($data,$this->privateKey); $encode_data = encryptData($data,$this->privateKey); $post_data = array( 'merAccount' => $this->merAccount,//商户标识 'data' => $encode_data ); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); $ret = curl_exec($ch); curl_close($ch); // echo ' return:'.$ret; $retjson = json_decode($ret,true); if(checkSign($retjson["data"],$this->publicKey)){ // echo '验签成功'; return $ret; } else { // echo '验签失败'; return false; } } public function alipay($title, $order_no, $pay_amount,$return_url='',$notify_url=''){ $ch = curl_init($this->payUrl); $timeout = 6000; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER,0 ); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 $payAmount = intval($pay_amount * 100); $data = array( 'merAccount' => $this->merAccount, //商户标识 'merNo' => $this->merNo, //商户编号 'time' => time(),//时间戳 'orderId' => $order_no,//订单号 'amount' => $payAmount,//交易金额(分) 'product' => $title,//商品 'productDesc' => $title,//商品描述 'payWay' => 'ALIPAY', 'payType' => 'ALIPAY_H5', // 'openId' => 'ojmRm1jJzNSBK-6RxFFdNE30E4_4', 'userIp' => Request::instance()->ip(), 'returnUrl' => $return_url, //前端页面回调地址 'notifyUrl' => $notify_url//后台回调地址 ); $data['sign'] = getSign($data,$this->privateKey); $encode_data = encryptData($data,$this->privateKey); $post_data = array( 'merAccount' => $this->merAccount,//商户标识 'data' => $encode_data ); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); $ret = curl_exec($ch); curl_close($ch); // echo ' return:'.$ret; $retjson = json_decode($ret,true); if(checkSign($retjson["data"],$this->publicKey)){ // echo '验签成功'; return $ret; } else { // echo '验签失败'; return false; } } public function notifyVerify($data){ //公钥 $data = decryptData($data,$this->publicKey); // echo "解密data:".$data; $retjson = json_decode($data,true); if(checkSign($retjson,$this->publicKey)){ return $retjson; } else { return false; } } public function queryOrder($order_no) { $ch = curl_init($this->queryUrl); $timeout = 6000; curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER,0 ); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查 $data = array( 'merAccount' => $this->merAccount, //商户标识 'orderId' => $order_no,//订单号 'time' => time(),//时间戳 ); $data['sign'] = getSign($data,$this->privateKey); $encode_data = encryptData($data,$this->privateKey); $post_data = array( 'merAccount' => $this->merAccount,//商户标识 'data' => $encode_data ); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); $ret = curl_exec($ch); curl_close($ch); // echo ' return:'.$ret; $retjson = json_decode($ret,true); if(checkSign($retjson["data"],$this->publicKey)){ return $ret; echo '验签成功'; } else { echo '验签失败'; } } }