payUrl == null) { $this->payUrl = Yii::$app->params['huanqiu.payUrl']; //网关地址 } if ($this->merId == null) { $this->merId = Yii::$app->params['huanqiu.merId']; //商户号 } if ($this->appId == null) { $this->appId = Yii::$app->params['huanqiu.appId']; //商户账号 } if ($this->privateKey == null) { $this->privateKey = Yii::$app->params['huanqiu.key']; //商户私钥 } } /** * @param array $deposit * @param array $params * @return string */ public function outPay($deposit, $params = []) { $data['p1'] = $deposit['amount']; //订单金额(美元) $data['p2'] = $this->merId; //商户号 $data['p3'] = $deposit['order_sn']; //订单号码 $data['timestamp'] = time(); //时间戳 $result = PayUtils::sendPost($this->payUrl, $data,$this->appId, $this->privateKey); //入金请求 // 对返回的数据进行转化 $result_array = json_decode($result,true); return $result_array; } /** * @param array $data * @return bool */ public function handleNotify($data) { $string = print_r($data,true); file_put_contents('postshuju.txt',$string); if (isset($data['sign']) && trim($data['sign']) !== '') { if (PayUtils::checkSign($data,$this->privateKey)) { file_put_contents('huidiao.txt','验签成功'); $merOrderId = trim($data['merchantOrderNo']); //商戶的订单号码 $reuslt = Deposit::find()->where(['order_sn' => $merOrderId])->asArray()->limit(1)->one(); if ($reuslt['type'] != 1) { $res = Deposit::updateAll(['type' => 1], "order_sn = $merOrderId"); $configData = Config::find()->asArray()->one(); if ($configData['auto_deposit'] == 1 && $res) { $syncDespositModel = new SyncDesposit(); $syncDespositModel->login = $reuslt['login']; $syncDespositModel->amount = $reuslt['amount']; $syncDespositModel->comment = 'Deposit'; $syncDespositModel->memo = $merOrderId; $syncDespositModel->type = 2; $syncDespositModel->in_time = time(); $syncDespositModel->save(); } } return true; }else{ return false; } } return false; } public function outNotify($success) { if ($success == true) { return json(['code'=>'200']); } else { return "fail"; } } /** * @param array $data * @return bool */ public function handleReturn($data) { if (isset($data['sign']) && trim($data['sign']) !== '') { if (PayUtils::checkSign($data,$this->privateKey)) { if ($data['respCode'] == '00') { $merOrderId = trim($data['orderId']); $reuslt = Deposit::find()->where(['order_sn' => $merOrderId])->asArray()->limit(1)->one(); if ($reuslt) { return true; } } } } return false; } public function outReturn($success){ } }