TradeJsApiScan.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. //聚合支付
  3. header("Content-type: text/html; charset=utf-8");
  4. require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'AopClient.php';
  5. $privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMMNNYaXLfqFBKNW
  6. j7wocV4s1cC88tGwYBt3lVD8WGm12iuqHB20ybUsCof4r4IYWR74IcyWUNqTrzSJ
  7. K3cEmk2MtAmI7COZJTv9r4DnxbCARnKgyN18l+idXQf91YiGREnGPKZ1R1kQ+A+7
  8. 6rtAsZILmg0lZAJ7xa4J8Za/0lafAgMBAAECgYBUeschGR+H7s74c8hjZVzcviyC
  9. gxPkcDDgFKYuYm1ks6ff25i74Q6wEngpNjPF9Ae9mxkAhGZWlTqAVZzmuq6dgG7D
  10. aKqXNXkdDgovHEwHcRO1Rhfb3Rv0oYhzhldi7m0QobuvslMZRoVH76Ehes2Pfu3Z
  11. Lcbq30D47CeRBUyA6QJBAOBIExJvtK6xIcOO1JBmi9dmk9SKuDrnltnGvT1E8WTg
  12. B/Di3d/moksNLYTijTjimnVcQ6XV6ZQkEZOkes/Q/HUCQQDeouOS0HQ35T04A9tM
  13. UDOKMObIAwAUyRi01N0/Shi5VQq2RyWPB8YQQT54NeeFkSGXnj4iJV+jWdsK8gkE
  14. ZrRDAkB3K/TuW+qu1DHznkY2QDbYCopMajVAH2RZbS+KicKWbi/qADIS0ZK0vFjO
  15. fi655jZaW98aFBLcA1pPkBstp4ctAkEA1Rt+Uq4OUOKxcsjeRXIPo5ujjJiynzLO
  16. 32lSTp6Sg/SPSGNZ5EtAn5aUQWT3tLZzPTpPp0e3ABmmvhdn4jqdGQJBANW54TYs
  17. Eh6jurxh77vtVS0I2RNhUS8dkDCFqDtFI99r2hN0hxIAz11U7p42gyUVmXb4PAgI
  18. awQyTrfxvQ8Mty0=";
  19. $sxfPublic =
  20. "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDDTWGly36hQSjVo+8KHFeLNXA
  21. vPLRsGAbd5VQ/FhptdorqhwdtMm1LAqH+K+CGFke+CHMllDak680iSt3BJpNjLQJ
  22. iOwjmSU7/a+A58WwgEZyoMjdfJfonV0H/dWIhkRJxjymdUdZEPgPu+q7QLGSC5oN
  23. JWQCe8WuCfGWv9JWnwIDAQAB";
  24. $aopClient = new AopClient();
  25. $array = [
  26. //业务参数
  27. "mno"=> "399190910000387", //商户编号
  28. "ordNo"=> time(), //商户订单号
  29. //"subMechId"=> "", //子商户号
  30. //"subAppid"=> "", //微信 subAppId
  31. "amt"=> "0.02", //订单总金额
  32. //"discountAmt"=> "", //参与优惠金额
  33. //"unDiscountAmt"=> "", //不参与优惠金额
  34. "payType"=> "WECHAT", //支付渠道
  35. "payWay"=> "02", //支付方式 02 公众号/服 务窗/js支付 03 小程序
  36. "subject"=> "聚合支付测试",
  37. "tradeSource"=> "01", //交易来源 01服务商,02收银台,03硬件
  38. "trmIp"=> "127.0.0.1",
  39. "customerIp"=> "", //持卡人ip地址,银联js支付时必传
  40. "userId"=> "2088101117955611", //用户号 微信:openid; 支付宝:userid;银联:userid;微信&支付宝必传,银联js为非必传
  41. //"hbFqNum"=> "6", //花呗分期数,仅可上送 6 或 12
  42. //"hbFqPercent"=> "0", //卖家承担分期 服务费比例,仅支持上送 0 或 100
  43. //"limitPay"=> "00", //限制卡类型: 00-全部 01-限定不能使 用信用卡支付 默认值 00
  44. //"timeExpire"=> "10", //订单失效时间
  45. //"goodsTag"=> "00", //订单优惠标识 00:是,01: 否
  46. //"couponDetail"=> "", //优惠详情信息,见下面三个字段
  47. //"costPrice"=> "200", //订单原价保留两 位小数;微信 独有
  48. //"receiptId"=> "123456789", //商品小票
  49. //"goodsDetail"=> "123456789", //单品优惠信息使用 json 数组格式提交
  50. //"goodsId"=> "200", //商品编码
  51. //"thirdGoodsId"=> "12345678", //微信/支付宝侧商品码
  52. //"goodsName"=> "苹果电脑", //商品名称
  53. //"quantity"=> "1", //商品数量
  54. //"price"=> "1.01", //商品单价
  55. //"goodsCategory"=> "", //商品类目;支 付宝独有
  56. //"categoriesTree"=> "124868003|126232002|126252004", //商品类目树
  57. //"goodsDesc"=> "", //商品描述;支 付宝独有
  58. //"showUrl"=> "", //商品展示地址 url;支付宝独有
  59. //"needReceipt"=> "00", //电子发票功能 微信开具电子 发票使用
  60. //"ledgerAccountFlag"=> "00", //是否做分账 分账交易使 用;00:做; 01:不做;不传默认为不做分账
  61. //"ledgerAccountEffectTime"=> "00", //分账有效时间 单位为天;是 否做分账选择 00 时该字段必传
  62. //"notifyUrl"=> "", //回调地址
  63. //"ylTrmNo"=> "", //银联终端号
  64. //"terminalId"=> "", //TQ机具编号
  65. //"deviceNo"=> "", //设备号
  66. //"identityFlag"=> "", //是否是实名支付
  67. //"buyerIdType"=> "IDCARD", //证件类型
  68. //"buyerIdNo"=> "410523198701054018", //证件号
  69. //"buyerName"=> "张三", //买家姓名
  70. //"mobileNum"=> "", //手机号
  71. //"extend"=> "" //备用
  72. ];
  73. $reqBean = [
  74. "orgId" =>"90589021",
  75. "reqData"=>$array,
  76. "reqId" => time(),
  77. "signType" => "RSA",
  78. "timestamp" => date("Y-m-d h:i:s"),
  79. "version" => "1.0",
  80. ];
  81. $signContent = $aopClient->generateSign($reqBean,$privateKey);
  82. $sign =["sign" => $signContent];
  83. $reqStr = array_merge($reqBean, $sign);
  84. $reqStr = json_encode($reqStr,320);
  85. $requestUrl = 'https://openapi-test.tianquetech.com/order/jsapiScan';
  86. $resp = $aopClient->curl($requestUrl, $reqStr);
  87. $result = json_decode($resp,320);
  88. print_r($result);
  89. $signResult = $result["sign"];
  90. // result.remove("sign");
  91. unset($result["sign"]);
  92. // String resultStr = RSASignature.getOrderContent(result);
  93. //sign
  94. /// String resultSign = RSASignature.encryptBASE64(RSASignature.sign(signContent, privateKey));
  95. $signContent = $aopClient->getSignContent($result);
  96. $verify = $aopClient->verify($signContent, $signResult,$sxfPublic);
  97. //组装加密串
  98. if ($verify) {
  99. echo("验签成功");
  100. }else{
  101. echo("验签失败");
  102. }
  103. ?>