public function back() { $message = $_GET["message"]; $signature = $_GET["signature"]; vendor('jubaopay.jubaopay'); $jubaopay = new \jubaopay('jubaopay.ini'); $jubaopay->decrypt($message); // 校验签名,然后进行业务处理 $result = $jubaopay->verify($signature); if ($result == 1) { // 得到解密的结果后,进行业务处理 $payid = $jubaopay->getEncrypt("payid"); $state = $jubaopay->getEncrypt("state"); // $amount=$jubaopay->getEncrypt("amount"); // $orderNo=$jubaopay->getEncrypt("orderNo"); $db = M('account'); $data = $db->find($payid); if ($data) { $type = (int) $data["type"]; if ($type == 30 || $type == 1) { layout(false); if ($state == '2') { $this->display("success"); } else { $this->display("error"); } } else { if ($type == 31 || $type == 11) { if ($state == '2') { $this->redirect('Home/Pay/success'); } else { $this->redirect('Home/Pay/error'); } } } } } }
public function jubaopay() { $uid = session("_uid"); vendor('jubaopay.jubaopay'); // $payid=$this->genPayId(20); $partnerid = C("jubaopay.partnerid"); $amount = $_POST["amount"]; $accountmoney = $_POST["accountmoney"]; $accountscore = $_POST["accountscore"]; $accountbgid = $_POST["accountbgid"]; $payid = $_POST["payid"]; $goodsName = $_POST["goodsName"]; $remark = $_POST["remark"]; $paytype = $_POST["paytype"]; //rechargepc $accountpaytype = -1; //$orderNo = md5(time()); $orderNo = $payid; if ($paytype == 'pc' || $paytype == 'wap') { $type = 1; if ($paytype == 'wap') { $type = 11; } $result['status'] = $this->updatePrePay($payid, $uid, $accountmoney, $accountscore, $amount, $type); if ($status != 0) { // 计算余额失败 $this->ajaxReturn($result, 'JSON'); return; } } else { if ($paytype == 'rechargepc' || $paytype == 'rechargewap') { $adb = M('account'); $payid = $this->genPayId(20); $type = 30; if ($paytype == 'rechargewap') { $type = 31; } $accountData = array('payid' => $payid, 'uid' => $uid, 'type' => $type, 'third' => $amount, 'score' => 0, 'status' => 0); if ($adb->add($accountData) !== FALSE) { //echo $paytype.'成功'; } else { $this->display("error"); //echo $paytype.'失败'; return; } } } // //写入到 account 表。 // $adb = M('account'); // if($adb->add($data)) { $payerName = "zs001"; //$_POST["payerName"]; $returnURL = C("jubaopay.returnURL"); //"http://pay.xxx.com/result.php"; // 可在商户后台设置 $callBackURL = C("jubaopay.callBackURL"); //"http://pay.xxx.com/notify.php"; // 可在商户后台设置 $payMethod = "WANGYIN"; //$_POST["payMethod"]; //测试 //$amount=0.5; ////////////////////////////////////////////////////////////////////////////////////////////////// //商户利用支付订单(payid)和商户号(mobile)进行对账查询 $jubaopay = new \jubaopay('jubaopay.ini'); $jubaopay->setEncrypt("payid", $payid); $jubaopay->setEncrypt("partnerid", $partnerid); $jubaopay->setEncrypt("amount", $amount); $jubaopay->setEncrypt("payerName", $payerName); $jubaopay->setEncrypt("remark", $remark); $jubaopay->setEncrypt("returnURL", $returnURL); $jubaopay->setEncrypt("callBackURL", $callBackURL); $jubaopay->setEncrypt("goodsName", $goodsName); //对交易进行加密=$message并签名=$signature $jubaopay->interpret(); $message = $jubaopay->message; $signature = $jubaopay->signature; $this->assign("message", $message); $this->assign("signature", $signature); $this->assign("payMethod", $payMethod); layout(false); // // if ($paytype == "rechargepc" || $paytype == "pc") { $this->display("jubaopaypc"); } else { if ($paytype == "wap" || $paytype == "rechargewap") { $this->display("jubaopaywap"); } } // } }