payUrl == null) { $this->payUrl = Yii::$app->params['chuanghui.payUrl']; } if ($this->merId == null) { $this->merId = Yii::$app->params['chuanghui.merId']; } if ($this->privateKey == null) { $this->privateKey = __DIR__ . '/prem/chuanghui_private.pem'; } if ($this->publicKey == null) { $this->publicKey = __DIR__ . '/prem/chuanghui_public.pem'; } } /** * @param array $deposit * @param array $params * @return string */ public function outPay($deposit, $params = []) { $data = []; $data['merId'] = $this->merId; //商户号 $data['orderNo'] = $deposit['order_sn']; //订单号 $data['amount'] = $deposit['rmb']; //金额 $data['payType'] = $params['bankCode']; //支付类型 $data['goodsName'] = $deposit['order_sn']; //商品名称 $data['returnUrl'] = $this->returnUrl; //支付完成返回地址 $data['notifyUrl'] = $this->notifyUrl; //回调地址 $data['sign'] = PayUtils::makeSign($data, $this->privateKey); $result = static::createHtml($data, $this->payUrl); return $result; } /** * @param array $data * @return bool */ public function handleNotify($data) { // Yii::warning('支付异步通知参数,' . VarDumper::dumpAsString($data), __METHOD__); if (isset($data['sign']) && trim($data['sign']) !== '') { if (PayUtils::verify($data, $this->publicKey)) { if ($data['status'] == '1') { $merOrderId = trim($data['orderNo']); $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 success; } } } } return false; } public function outNotify($success) { if ($success == true) { return "success"; } else { // 返回的数据格式 return "FAIL"; } } /** * @param array $data * @return bool */ public function handleReturn($data) { //Yii::warning('支付同步通知参数,' . VarDumper::dumpAsString($data), __METHOD__); if (isset($data['sign']) && trim($data['sign']) !== '') { if (PayUtils::verify($data, $this->publicKey)) { if ($data['status'] == '1') { $merOrderId = trim($data['orderNo']); $reuslt = Deposit::find()->where(['order_sn' => $merOrderId])->asArray()->limit(1)->one(); if ($reuslt) { return success; } } } } return false; } public function outReturn($success) { } }