payUrl == null) { $this->payUrl = Yii::$app->params['kexing.payUrl']; } if ($this->merId == null) { $this->merId = Yii::$app->params['kexing.merId']; } if ($this->pubCert == null) { $this->pubCert = __DIR__ . '/cert/1005314_pub.pem'; } if ($this->priCert == null) { $this->priCert = __DIR__ . '/cert/1005314_prv.pem'; } } /** * @param array $deposit * @param array $params * @return string */ public function outPay($deposit, $params = []) { $data = [ 'version' => '1.0.0', 'productId' => '0001', 'transType' => 'SALES', 'merNo' => $this->merId, 'orderDate' => date("Ymd"), //交易日期 'orderNo' => $deposit['order_sn'], //订单号 'returnUrl' => $this->returnUrl, 'notifyUrl' => $this->notifyUrl, 'transAmt' => $deposit['rmb'] * 100, //分为 'commodityName' => $deposit['order_sn'], //产品名称 'commodityDetail' => $deposit['order_sn'], //产品描述 'bankCode' => $params['bankCode'] ]; $data['signature'] = PayUtils::makeSign($data, $this->priCert); Yii::warning('支付请求参数,' . VarDumper::dumpAsString($data), __METHOD__); $result = PayUtils::sendPost($this->payUrl, $data); Yii::warning('支付请求结果,' . VarDumper::dumpAsString($result), __METHOD__); return $result; } /** * @param array $data * @return bool */ public function handleNotify($data) { Yii::warning('支付异步通知参数,' . VarDumper::dumpAsString($data), __METHOD__); if (isset($data['signature']) && trim($data['signature']) !== '') { if(PayUtils::verify($data, $this->pubCert)) { if ($data['respCode'] == '0000') { $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 true; } } } } return false; } public function outNotify($success) { if ($success == true) { return "success"; } else { return "fail"; } } /** * @param array $data * @return bool */ public function handleReturn($data) { return true; } public function outReturn($success) { } }