Skip to content

Commit

Permalink
增加在企业付款到零钱包时自定义客户端或服务器端IP功能。
Browse files Browse the repository at this point in the history
  • Loading branch information
abei2017 committed Mar 21, 2020
1 parent bbcf47b commit 5aa23ae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/mp/payment/Mch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,17 @@ class Mch extends Driver {
* @return array
*/
public function send($params = []){
// 主要解决在console模式下无法通过Yii的request组件获取IP问题。
$ip = isset($params['ip']) ? $params['ip'] : Yii::$app->request->userIP;
$conf = [
'mch_appid'=>$this->conf['app_id'],
'mchid'=>$this->conf['payment']['mch_id'],
'spbill_create_ip'=>Yii::$app->request->userIP,
'spbill_create_ip'=>$ip,
'nonce_str'=>Yii::$app->security->generateRandomString(32)
];

if (isset($params['ip'])) unset($params['ip']);

$params = array_merge($params,$conf);
$params['sign'] = Util::makeSign($params,$this->conf['payment']['key']);

Expand Down

0 comments on commit 5aa23ae

Please sign in to comment.