第一步:相关基本配置:
.env文件里:
[pay] #product = true #mchntcd = '0003320F2144842' #secret = 'zxppac23oeolb9gweugjxt1d8ntxpgkh' version = '1.0'
application目录下config.php文件里:
'pay' => [ 'product' => Env::get('pay.product',false), 'mchntcd' => Env::get('pay.product',false) ? Env::get('pay.mchntcd'):'0002900F0096235', 'secret' => Env::get('pay.product',false) ? Env::get('pay.secret'):'5old71wihg2tqjug9kkpxnhx9hiujoqj', 'version' => Env::get('pay.version'), ],
第二步:控制器里:
private $config = []; private $client = null; public function __construct() { $this->config = config('pay'); $this->config['domain'] = $this->config['product'] ? 'https://mpay.fuioupay.com/newpropay/':'http://www-1.fuioupay.com:18670/mobile_pay/newpropay/'; $this->client = new \GuzzleHttp\Client(); parent::__construct(); }
/** * 发送绑卡短信 */ public function bindMsg() { $postUrl = $this->config['domain'].'bindMsg.pay'; $postFm = $this->config['product'] ? 'https://mpay.fuioupay.com/findPay/cardBinQuery.pay':'http://www-1.fuioupay.com:18670/mobile_pay/findPay/cardBinQuery.pay'; $mchntcd = $this->config['mchntcd']; $secret = $this->config['secret']; $version = $this->config['version']; $uid = input('uid'); $date = date('Ymd',time()); $oid = $date.date('His').mt_rand(1000,9999); $account = input('account'); $cardno = input('cardno'); $idtype = 0; $idcard = input('idcard'); $phone = input('mobile'); if(!$uid || !$account || !$cardno|| !$idcard|| !$phone){ $this->error('参数缺失',null,201); } $binSign = md5($mchntcd.'|'.$cardno.'|'.$secret); $fm = '<FM><MchntCd>'. $mchntcd .'</MchntCd> <Ono>'. $cardno .'</Ono> <Sign>'. $binSign .'</Sign></FM>'; $resFm = $this->getResult($postFm,$fm,true); if($resFm['Rcd'] != '0000'){ $this->error($resFm['RDesc'],null,201); } $sign = md5($version.