payUrl == null) { $this->payUrl = Yii::$app->params['qianwanbao.payUrl']; //支付地址 } if ($this->merNo == null) { $this->merNo = Yii::$app->params['qianwanbao.merNo']; //商户编码 } if ($this->platformNo == null) { $this->platformNo = Yii::$app->params['qianwanbao.platformNo']; //机构编码 } if ($this->secretKey == null) { $this->secretKey = Yii::$app->params['qianwanbao.secretKey']; //机构密钥 } } /** * @param array $deposit * @param array $params * @return string */ public function outPay($deposit, $params = []) { $data = []; //接口公告报文 $data['version'] = '1.0.0'; //SDK版本号 $data['tranType'] = '11000'; //网关支付类型 $data['platformNo'] = $this->platformNo; //机构平台编码 $data['merNo'] = $this->merNo; //商户编码 $data['signType'] = 'MD5'; //签名方式:MD5 // 请求应答参数 $data['service'] = 'pay'; //服务类型 $data['orderAmount'] = $deposit['rmb'] * 100; //订单总金额 $data['subject'] = $deposit['order_sn']; //订单标题(目前使用的是订单号) $data['merOrderNo'] = $deposit['order_sn']; //订单编码 $data['frontUrl'] = $this->returnUrl; //同步跳转地址(网管支付必填) $data['backUrl'] = $this->notifyUrl; //异步通知地址 $data['signature'] = PayUtils::makeSign($data, $this->secretKey); // 签名 return static::createHtml($data, $this->payUrl); } /** * @param array $data * @return bool */ public function handleNotify($data) { if (PayUtils::checkSign($data, $this->secretKey)) { if (isset($data['status']) && $data['status'] == 1) { $merOrderId = trim($data['merOrderNo']); /** @var Deposit $model */ $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; } } } return false; } public function outNotify($success) { if ($success == true) { return "SUCCESS"; } else { return "FAIL"; } } /** * @param array $data * @return bool */ public function handleReturn($data) { if (PayUtils::checkSign($data, $this->secretKey)) { if (isset($data['status']) && $data['status'] == 1) { $merOrderId = trim($data['merOrderNo']); /** @var Deposit $model */ $model = Deposit::find()->where(['id' => $merOrderId])->asArray()->limit(1)->one(); if ($model) { return true; } } } return false; } public function outReturn($success) { } }