toArray(),$config); foreach ($base_config as $key => $val) { if (property_exists($this, $key)) { $this->{$key} = $val; } } $this->pay_sign = new PaySign(); empty($this->notify_url) && $this->setNotifyUrl(); empty($this->return_url) && $this->setReturnUrl(); empty($this->client_ip) && $this->setClientIp(); } public function setNotifyUrl(){ $this->notify_url = \Yii::$app->services->setting->platform->get('system.api_url').'/notify/sicpay?mall_id='.$this->mall_id; } public function setReturnUrl(){ // $this->return_url= \Yii::$app->services->setting->platform->get('system.api_url').'/notify/pay?mall_id='.$this->mall_id; $this->return_url= \Yii::$app->services->setting->platform->get('system.h5_url')."/#/plugins/pages/schemes/index"; } public function setClientIp(){ if (!empty($_SERVER['REMOTE_ADDR'])) { $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = defined('PHPUNIT_RUNNING') ? '127.0.0.1' : gethostbyname(gethostname()); } $this->client_ip = filter_var($ip, FILTER_VALIDATE_IP) ?: '127.0.0.1'; } public function getConfig(){ // TODO: Implement getConfig() method. $class = new \ReflectionClass($this); $pro = $class->getProperties(); $config = []; foreach ($pro as $item) { if($item->isPublic() ){ $config[$item->getName()] = $item->getValue($this); } } return array_filter($config); } public function pay () { // TODO: Implement pay() method. $param = $this->getConfig(); $res = $this->pay_sign->sendEncodeData($param,$param); // var_dump($res); if(!isset($res['resp_code']) || $res['resp_code'] != '0000'){ return $this->error($res['resp_desc']); } // 成功 return $this->response = $res; } public function query () { // TODO: Implement query() method. $param = $this->getConfig(); $res = $this->pay_sign->sendEncodeData($param,$param); if(isset($res['resp_code']) && $res['resp_code'] != '0000'){ return $this->error($res['resp_desc']); } // 成功 return $this->response = $res; } public function returnData(){ // TODO: Implement pay() method. return [ 'busi_code'=>"PRE_PAY", 'merchant_no'=>$this->agencyId, 'terminal_no'=>$this->terminal_no, 'order_no'=>$this->order_no, 'pay_no'=>$this->response['pay_no'] ?? '', ]; } }