以下是自己写的调用支付和退款和查询订单

<?phpnamespace Org\IcbcPhp;use Exception;/*** Class ICBCPay* 工银支付*/
class ICBCPay
{private $client;private $payType;/*** ICBCPay constructor.* @param string $payType 9 微信 10 支付宝 11 e支付*/public function __construct($payType){$this->payType = $payType . "";if ($payType == "9" || $payType == "10" || !$payType) {$this->client = new DefaultIcbcClient(C("icbc_app_id"), C("icbc_private_key"), C("icbc_sign_type"), C("icbc_charset"), C("icbc_format"), C("icbc_gateway_public_key"), C("icbc_encryptKey"), C("icbc_encryptType"), "", "");} elseif ($payType == "11") {$this->client = new UiIcbcClient(C("icbc_app_id"), C("icbc_private_key"), C("icbc_sign_type"), C("icbc_charset"), C("icbc_format"), C("icbc_gateway_public_key"), C("icbc_encryptKey"), C("icbc_encryptType"), "", "");}}/*** app 支付宝和微信下单* 张志强* 2021-01-12* @param string $subMerchantId 商户号* @param string $mer_prtcl_no 协议编号* @param string $orderId 订单号* @param string $money 金额* @param string $decive 设备号* @param string $attach 附加字段* @param string $clientIp 设备ip* @param string $notifyUrl 回调地址* @return false|string* @throws Exception*/public function appPay($subMerchantId, $mer_prtcl_no, $orderId, $money, $decive, $attach, $clientIp, $notifyUrl){if ($this->payType == 11) {throw new Exception("请使用e支付的接口");}$data = ['serviceUrl' => 'https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/consumepurchase/V1','biz_content' => get_object_vars(new ICBCPayBizContentParameter($subMerchantId, $mer_prtcl_no, $orderId . "", $this->payType, $decive, $money . "", $attach, $clientIp, $notifyUrl)),'extraParams' => [],'method' => "POST",'isNeedEncrypt' => true];return $this->client->execute($data, $orderId, "");}/*** e支付 h5* 张志强* 2021-01-12* @param string $subMerchantId 商户号* @param string $mer_prtcl_no 协议编号* @param string $orderId string     订单号* @param string $money string      金额* @param string $attach string     附加字段* @param boolean $isInApp bool 是否嵌入app内* @param string $notifyUrl 回调地址* @param string $returnUrl 支付完跳转地址* @return string* @throws Exception*/public function ePay($subMerchantId, $mer_prtcl_no, $orderId, $money, $attach, $isInApp, $notifyUrl, $returnUrl){if ($this->payType != 11) {throw new Exception("请使用聚合支付的接口");}$data = ['serviceUrl' => 'https://gw.open.icbc.com.cn/ui/cardbusiness/epayh5/ui/consumption/V1','biz_content' => get_object_vars(new ICBCEPayBizContentParameter($subMerchantId, $mer_prtcl_no, $orderId . "", $money . "", $attach, $isInApp, $notifyUrl, $returnUrl)),'extraParams' => [],'method' => "POST",'isNeedEncrypt' => true];return $this->client->buildPostForm($data, $orderId, "");}/*** 退款* 张志强* 2021-01-12* @param string $subMerchantId 商户编号* @param string $refundId 自己生成的唯一退款id* @param string $orderId 订单号* @param string $money 金额* @return false|string* @throws Exception*/public function refund($subMerchantId, $refundId, $orderId, $money){// 退款$data = ['serviceUrl' => 'https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/merrefund/V1','biz_content' => get_object_vars(new ICBCRefundBizContentParameter($subMerchantId, $refundId . "", $orderId . "", $money . "")),'extraParams' => [],'method' => "POST",'isNeedEncrypt' => true];return $this->client->execute($data, $orderId, "");}// 查询订单/*** @param $subMerchantId* @param $serial_number* @return false|string* @throws Exception*/public function selectIcbcOrder($subMerchantId, $serial_number){$data = ['serviceUrl' => 'https://gw.open.icbc.com.cn/api/cardbusiness/aggregatepay/b2c/online/orderqry/V1','biz_content' => ['mer_id' => $subMerchantId,'out_trade_no' => $serial_number,'deal_flag' => "0",'icbc_appid' => C('icbc_app_id')],'extraParams' => [],'method' => "POST",'isNeedEncrypt' => true];return $this->client->execute($data, microtime(), "");}
}

支付回调

/*** 工银支付回调* @throws Exception*/public function icbcNotify() {$file_pointer = fopen(APP_PATH."/Lib/Action".__GROUP__."/aa.txt","a+");fwrite($file_pointer,"回调开始");try {// 获取参数$responseStr = urldecode(file_get_contents("php://input"));if (!$responseStr) {throw new Exception("【".date("Y-m-d H:i:s")."】  参数不能为空\r\n");}$response = explode("&",$responseStr);$responseArr = [];$sign = "";foreach ($response as $k => $v) {if (strstr($v,"=",true) == 'sign') {$sign = substr(strstr($v,"=",false),1);} else {$responseArr[strstr($v,"=",true)] = substr(strstr($v,"=",false),1);}}// 生成待签名字符串$path = parse_url('域名' +'接口名', PHP_URL_PATH);$respBizContentStr = WebUtils::buildOrderedSignStr($path,$responseArr);// 验证签名1$passed = IcbcSignature::verify($respBizContentStr, $responseArr['sign_type'], C("icbc_gateway_public_key"), $responseArr['charset'], $sign,'');if (!$passed) {$responseArr = json_encode($responseArr);throw new Exception("【".date("Y-m-d H:i:s")."】  icbc sign verify not passed!\r\n订单信息为【{$responseArr}】签名为【{$sign}】\r\n");}// 返回业务参数$bizContent = json_decode($responseArr['biz_content'],true);$merOrderId = $bizContent['out_trade_no'];$notify_return_code = $bizContent['return_code'];// 验证返回消息码是否正确if ($notify_return_code !== "0") {return $this->response("-1","error");}// 修改unipay_log$result = M('unionpay_log')->data(['is_valid' => 2])->where(['serial_number'=>$merOrderId])->save();if ($result === false) {throw new Exception("【".date("Y-m-d H:i:s")."】  修改unipay_log失败!\r\n订单信息为【{$responseArr}】签名为【{$sign}】\r\n");}// 自己的业务逻辑//return $this->response("0","success");成功响应//return $this->response("-1","error");失败响应} catch (Exception $exception) {fwrite($file_pointer,$exception->getMessage());return $this->response("-1","error");}}/*** 工行回调应答* 张志强* 2021-07-15*/private function response($return_code,$return_msg) {// 应答$respBizContent = array('return_code' => $return_code,'return_msg' => $return_msg,'msg_id' => microtime());$answer['response_biz_content'] = json_encode($respBizContent);$answer['sign_type'] = C('icbc_sign_type');$answer['sign'] = IcbcSignature::sign(substr(json_encode($answer),1),C("icbc_sign_type"),C("icbc_private_key"),C("icbc_charset"),'');return json_encode($answer);}

强调:
在支付回调签名验证的时候的path不要自己手写,会发生验签不通过,切记要用

 $path = parse_url('域名' +'接口名', PHP_URL_PATH);

php工行SDK下载地址

php版工行聚合支付和e支付相关推荐

  1. 工行聚合支付经验总结

    工行聚合支付经验总结 1.被动通知查询验签结果ReturnValue.verifySign()为1(0为成功),可能是用的公钥不对,非文档或者demo里用的证书公钥(xxx.cer),而是需要用一个叫 ...

  2. 2018最新支付系统/第三方支付系统/第四方支付系统/聚合支

    2018最新支付系统/第三方支付系统/第四方支付系统/聚合支这里写自定义目录标题 2018最新第三方API第四方支付平台程序源码完整开源全套完美运营版聚合支付平台源码,此平台源码是客户独家运营的版本, ...

  3. 聚合项目访问后台接口失败_聚合支付系统和免签支付系统对未来支付市场有哪些影响...

    时势所趋,在如今支付通道不稳定的情况下,四方聚合支付的出现弥补了通道不稳的情况,四方聚合支付可以接入多个三方,实现在三方不稳的情况直接后台切换三方,实现一秒切换,还可以接入个人免签支付系统,实现商户实 ...

  4. 工行(工银聚富通)支付-子商户注册

    前段时间项目要接工银聚富通,上网找个好多有关资料感觉都不太合适,后来自己一点点摸索,最后完成了需求.项目是微信小程序商城.用户下单到门店,发起支付,并将工行支付返回的参数返回给前端,前端根据参数调起微 ...

  5. h5免签聚合支付系统yy支付-y币+yy陪玩-系统源码

    h5免签聚合支付系统+yy支付y币+yy陪玩-系统源码 亲测监控可以用 正常

  6. 聚合支付、单商户多商户支付、微信/支付宝/PayPal支付流程、支付政策法规

    目录 一.聚合支付 聚合支付的基本概念 如何选择合适的支付模式 政策相关 常见的聚合支付平台 二.多商户和单商户 多商户单商户区别 多商户入驻流程 多商户模式中常见的支付流程 普通支付 合单支付 留个 ...

  7. 聚合支付,未来支付的前哨站

    侯维科技# 不知从什么时候开始,二维码像雨后春笋一样到处生长,街头巷尾无论是卖红薯的大爷.还是卖凉皮的阿姨都在自己的移动摊点上贴上了二维码.二维码支付犹如一股旋风一般席卷了中国的大街小巷. 以支付宝. ...

  8. 聚合支付/免签支付/第四方支付/在线扫码支付/个人收款/第三方收款接口详解,能给用户提供什么价值,背景介绍

    随着互联网的发展,电子商务变成21世纪非常主流的一种经营模式,既然是线上商城必然离不开线上支付,从最早的银行卡支付.银联支付,到现在的扫码支付.一键支付.支付方式百花绽放,各大巨头纷纷推出越来越便捷的 ...

  9. 聚合支付:关于支付安全的思考(一)

    俗话说:好事不出门,坏事传千里.坏事传播得又快广是互联网的特点之一.由于涉及资金,若聚合支付一旦发生安全事件,就会如坏事一般,造成轰动效应,备受社会关注.聚合支付:关于支付安全问题的第一个思考,支付安 ...

最新文章

  1. 干货 | VMAF视频质量评估在视频云转码中的应用
  2. Win32API 窗口程序的创建7大步骤
  3. python使用ssh 中文_Python3制作简易SSH登录工具
  4. Python 只读属性的实现
  5. 【转】Delphi实现自动发贴和识别验证码 王泽宾
  6. CSS3渐变——gradient
  7. cnblog 闪存刷星星,每一条闪存都是星星
  8. A站没落了,付费会员成B站破解盈利难题的最优解?
  9. 通过css使文字有渐变的效果
  10. 火狐浏览器安装有道翻译插件
  11. Python英文搜索引擎(模糊搜索)
  12. re.search与re.findall的区别
  13. iOS之常用第三方库的介绍
  14. COL FIRST_NAME FORMAT A15
  15. java照片切换播放音乐_音乐播放器-图片切换-轮播图效果
  16. NLP(七):前馈神经网络基础回顾(NN模型及其正则化,dropout,各种梯度求解算法等模型优化策略)
  17. HTML5+CSS+JS--前端入门级网页尝试
  18. 云桌面-ThinVirt3-EXP操作手册(四)云终端连接虚拟机
  19. 用Python操控Minecraft我的世界 1.安装Spigot服务器并添加RaspberryJuice插件
  20. 美国精神的象征,就是美国队长,三维模型来了

热门文章

  1. Android长度单位详解
  2. rails网站分享到朋友圈功能是怎么实现的
  3. 计算机风扇介绍,如何选择计算机风扇?
  4. 安装算量软件快速计算管道管件功能
  5. Java常用加密解密算法全解
  6. 2个阶乘什么意思_两个阶乘符号连在一起是什么意思
  7. 洛谷1262 间谍网络 tarjan缩点
  8. 18个最好的代码编辑器/IDE工具,希望你会喜欢。
  9. 香港、澳门通行证网上申请
  10. Eclipse的快捷键设置及使用