第一步:相关基本配置:

.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.'|'.$oid.'|'.$mchntcd.'|'.$uid.'|'.$account.'|'.$cardno.'|'.$idtype.'|'.$idcard.'|'.$phone.'|'.$secret);$apifms = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><REQUEST><VERSION>'. $version .'</VERSION><MCHNTCD>'. $mchntcd .'</MCHNTCD><USERID>'. $uid .'</USERID> <TRADEDATE>'. $date .'</TRADEDATE><MCHNTSSN>'. $oid .'</MCHNTSSN><ACCOUNT>'. $account .'</ACCOUNT><CARDNO>'. $cardno .'</CARDNO><IDTYPE>'. $idtype .'</IDTYPE><IDCARD>'. $idcard .'</IDCARD><MOBILENO>' .$phone. '</MOBILENO><SIGN>'. $sign .'</SIGN></REQUEST>';$res = $this->getResult($postUrl,$apifms);if($res['RESPONSECODE'] == '0000'){$this->success('成功',['date' => $date,'oid' => $oid,'uid' => $uid,'bank' => $resFm['Cnm']],200);}else{$this->error($res['RESPONSEMSG'],null,201);}
}
/*** 协议卡绑定*/
public function bindCommit()
{$postUrl = $this->config['domain'].'bindCommit.pay';$mchntcd = $this->config['mchntcd'];$secret  = $this->config['secret'];$version = $this->config['version'];$uid     = $data['userid']   = input('uid');$date    = input('date');$oid     = input('mcntssn');$account = $data['account'] = input('account');$cardno  = $data['cardno']  = input('cardno');$idtype  = 0;$idcard  = $data['idcard']  = input('idcard');$phone   = $data['mobile']  = input('mobile');$code    = input('code');if(!$uid || !$account || !$cardno || !$idcard || !$phone || !$code){$this->error('参数缺失',null,201);}$sign    = md5($version.'|'.$oid.'|'.$mchntcd.'|'.$uid.'|'.$account.'|'.$cardno.'|'.$idtype.'|'.$idcard.'|'.$phone.'|'.$code.'|'.$secret);//签名$apifms  = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><REQUEST><VERSION>'. $version .'</VERSION><MCHNTCD>'. $mchntcd .'</MCHNTCD><USERID>'. $uid .'</USERID> <TRADEDATE>'. $date .'</TRADEDATE><MCHNTSSN>'. $oid .'</MCHNTSSN><ACCOUNT>'. $account .'</ACCOUNT><CARDNO>'. $cardno .'</CARDNO><IDCARD>'.$idcard.'</IDCARD><IDTYPE>'.$idtype.'</IDTYPE><MOBILENO>'.$phone.'</MOBILENO><MSGCODE>'.$code.'</MSGCODE><SIGN>'. $sign .'</SIGN></REQUEST>';$res = $this->getResult($postUrl,$apifms);if($res['RESPONSECODE'] == '0000'){$data['is_bind']    = 1;$data['mchntssn']   = $res['MCHNTSSN'];$data['protocolno'] = $res['PROTOCOLNO'];$data['backname']   = input('bank');if($bindcard = BindCard::create($data)){$this->success('绑卡成功',$bindcard->id,200);}else{$this->error('入库失败',null,201);}}else{$this->error($res['RESPONSEMSG'],null,201);}
}
/*** 协议卡解绑*/
public function unbind()
{$postUrl  = $this->config['domain'].'unbind.pay';$mchntcd  = $this->config['mchntcd'];$secret   = $this->config['secret'];$version  = $this->config['version'];$uid      = input('uid');$bindcard = BindCard::get(input('bcid'));if($bindcard->userid != $uid){$this->error('无权限',null,201);}$protocol = $bindcard->protocolno;$sign     = md5($version.'|'.$mchntcd.'|'.$uid.'|'.$protocol.'|'.$secret);$apifms   = '<?xml version="1.0" encoding="UTF-8" standalone="no"?><REQUEST><VERSION>'. $version .'</VERSION><MCHNTCD>'. $mchntcd .'</MCHNTCD><USERID>'. $uid .'</USERID><PROTOCOLNO>'. $protocol .'</PROTOCOLNO>><SIGN>'. $sign .'</SIGN></REQUEST>';$res = $this->getResult($postUrl,$apifms);if($res['RESPONSECODE'] == '0000'){$bindcard->is_bind = 2;if($bindcard -> save()){$this->success('解绑成功',null,200);}else{$this->error('更新数据失败',null,201);}}else{$this->error('解绑失败',null,201);}
}/*** 协议支付*/
public function order()
{$postUrl  = $this->config['domain'].'order.pay';$version  = $this->config['version'];$ip       = $this->request->ip();$mchntcd  = $this->config['mchntcd'];$secret   = $this->config['secret'];$type     = '03';$oid      = date('YmdHis').mt_rand(1000,9999);    //商户订单号$uid      = input('uid');                            //用户id$price    = input('price');                          //支付金额$bcid     = input('bcid');                              //协议卡idif(!$uid || !$price || !$bcid){$this->error('参数缺失',null,201);}$needMsg  = 0;                                            //是否需要发短信$notice   = 'http://im.ttyoumi.cn/api/pay/notice';        //回调url$protocol = BindCard::where('id',$bcid)->value('protocolno');$sign     = md5($type.'|'.$version.'|'.$mchntcd.'|'.$oid.'|'.$uid.'|'.$protocol.'|'.$price.'|'.$notice.'|'.$ip.'|'.$secret);//签名$apifms = '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <REQUEST><VERSION>'. $version .'</VERSION><USERIP>'. $ip .'</USERIP> <MCHNTCD>'. $mchntcd .'</MCHNTCD><TYPE>'. $type .'</TYPE> <MCHNTORDERID>'. $oid .'</MCHNTORDERID> <USERID>'. $uid .'</USERID><AMT>'. $price .'</AMT><PROTOCOLNO>'. $protocol .'</PROTOCOLNO> <NEEDSENDMSG>'. $needMsg .'</NEEDSENDMSG> <BACKURL>'. $notice .'</BACKURL><SIGNTP>MD5</SIGNTP> <SIGN>'. $sign .'</SIGN></REQUEST>';$res = $this->getResult($postUrl,$apifms);if($res['RESPONSECODE'] == '0000'){$data = ['userid'        => $uid,'version'       => $res['VERSION'],'type'          => $res['TYPE'],'mchntorderid'  => $res['MCHNTORDERID'],'orderid'       => $res['ORDERID'],'protocolno'    => $res['PROTOCOLNO'],'bankcard'      => $res['BANKCARD'],'amt'           => $res['AMT'],'signtp'        => $res['SIGNTP'],'responsemsg'   => $res['RESPONSEMSG']];if($result = Repayment::create($data)){$this->success($res['RESPONSEMSG'],null,200);}else{$this->error('插入数据失败',null,202);}}else{$this->error($res['RESPONSEMSG'],null,201);}
}/*** 支付回调*/
public function notice()
{\think\Log::write(input(),'debug');$this->success();
}
/*** des加密,ecb* @param $str* @param $key* @return string*/
public static function encrypt_base64($str,$key){$str = self::pkcs5_pad($str, 8);if (strlen($str) % 8) {$str = str_pad($str,strlen($str) + 8 - strlen($str) % 8, "\0");}$sign = openssl_encrypt($str,'DES-ECB' ,$key,OPENSSL_RAW_DATA);return base64_encode($sign);
}/*** des解密* @param $str* @param $key* @return string*/
public static function decrypt_base64($str,$key){$sign = openssl_decrypt(base64_decode($str),'DES-ECB' ,$key,OPENSSL_RAW_DATA);return $sign;
}
/*** 数据填充* @param $text* @param $blocksize* @return string*/
private static function pkcs5_pad($text, $blocksize) {$pad = $blocksize - (strlen($text) % $blocksize);return $text . str_repeat(chr($pad), $pad);
}private function getResult($postUrl,$apifms,$fm = false)
{$secret = $this->config['secret'];if($fm){$response = $this->client->request('POST',$postUrl,['form_params' => ['FM'  => $apifms]]);$response = $response->getBody();}else{$apifms = self::encrypt_base64($apifms,$secret);$data = ['MCHNTCD' => $this->config['mchntcd'],'APIFMS' => $apifms];$response = $this->client->request('POST',$postUrl,['form_params' => $data]);$response = self::decrypt_base64($response->getBody(),$secret);}return $this->xmlToArray($response);
}private function xmlToArray($xml)
{return json_decode(json_encode(simplexml_load_string($xml), true),true);
}

tp接入富友协议支付相关推荐

  1. tp接入富友H5支付

    控制器里方法: public function __construct() {$this->config = config('pay');$this->client = new \Guzz ...

  2. 富友支付AS微信支付

    刚好公司有个需求,需要把公众号的微信支付,改成富友AS微信支付(我自己起的名字),而且是要用C#去写.对于只用过PHP和Python的我来说,那是一脸懵逼.最后研究了一下富友开放平台的文档,折腾了一天 ...

  3. 富友集团由盈转亏:收购事项完成后未变更,旗下富友支付多次被罚

    近日,精达股份(SH:600577)发布的2020年年报显示,该公司2020年度实现营业收入124.47亿元,同比增长3.75%:归属于上市公司股东的净利润为4.19亿元,同比下降4.29%. 同时, ...

  4. 富友支付 统一下单接口 自创php版本demo

    看了文档才发现demo只有java版本的 那可不妙啊 还好在我的坚持与努力下 终于参透了这文档. 就这个文档 富友开放接口文档  有一说一这个验签的方式还是很简介的直接md5验签 害我找了半天的DES ...

  5. 富友支付接口对接不是必填的值如何处理

    1.拿注册接口举例子 正常需要的签名明文: back_notify_url+"|"+bank_nm+"|"+capAcntNo+"|"+ce ...

  6. Golang 对接宝付、通联、富友金账户...填坑记

    一.宝付私钥加密,公钥解密 由于对RSA加密解密原理不是很熟悉,宝付也没有Golang的Demo提供.Go语言库里一般都是私钥解密.公钥加密,或者私钥签名.公钥验签.宝付需要反过来,这里也到好找到了h ...

  7. 富友eERP打造服装企业电子商务快鱼时代

    每年,"中国企业信息化500强"总会吸引我们的目光. 在数千家企业中,我们也能欣喜地看到中国服装企业的身影:雅戈尔.美特斯邦威.波司登.杉杉等众多知名服装企业,都曾经进入过&quo ...

  8. 强监管下 协议支付会是互金平台救命稻草?(协议支付是代扣协议的升级版)

    近期,第三方支付的快捷支付.代扣代付渠道骤然收紧,导致多个行业不同程度受到影响,互金受到的冲击最为直接明显. 尤其是消费金融和P2P网贷行业,因为对监管尺度的负面预期,情绪上的恐慌大于对业务的实际影响 ...

  9. 富友电子商务系统的四大优势助网商轻松赚钱

    首先解决了大量订单处理的效率问题.富友电子商务系统通过淘宝接口,直接把商城订单导入系统,并对订单进行分类处理(确认.审核.合并.拆分.挂起异常订单),把订单处理流程化,自动化,提高订单的处理效率. 第 ...

最新文章

  1. 猫猫学iOS 之第一次打开Xcode_git配置,git简单学习
  2. linux杀死tomcat进程6,Linux下启动停止查看杀死Tomcat进程(示例代码)
  3. JSP在动态网页上输出 三角形和菱形
  4. ROC与AUC的定义与使用详解
  5. 软件工程第一次作业补充
  6. 线性回归 —— python
  7. [Android]Handler的消息机制
  8. python asyncio_Python中asyncio神器的入门
  9. Mybatis编写初始化Dao代码
  10. 软件工程中的十三种文档
  11. 无效的列类型 || Mbatis-Plus链接oracle
  12. 管道单线图CAD工具
  13. anbmcmdn 上下文无关文法_词法分析 | 上下文无关文法和推导
  14. 用html制作ps,ps制作图片的步骤
  15. PPT过大怎么压缩?这种方法务必收藏
  16. React之Hook(四)——使用 Effect Hook
  17. android动态mac地址,android 设备唯一码的获取,Cpu号,Mac地址
  18. wxpython的简单使用【代码实现】
  19. 《设计模式之禅(第三版)》 摘录篇-------依赖倒置原则
  20. AS3使用,播放声音和加载外部声音文件

热门文章

  1. java中写定时任务
  2. 青岛科技大学计算机田玉平,控制理论与控制工程;就业怎么样/?博士.
  3. C语言输出100-1000之内所有的水仙花数字
  4. 一款使用MarkDown描述的自动化神器Gauge
  5. 联想计算机如何修改启动顺序,联想电脑怎么在BOSS里设置启动次序
  6. 《搜索引擎原理、技术与系统》读书笔记(2)——分词算法
  7. 2019阿里P7社招面试题泄露;《警察抓小偷》,几人能答出来?
  8. 解决AndroidStudio编译时报错:org.gradle.api.ProjectConfigurationException;编译报错Read Time out
  9. 使用Chef部署OpenStack (by quqi99)
  10. CTF--信息技术对抗赛ISCC之安卓逆向分析