TradeActiveScan.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. //交易主扫(C扫B)
  3. header("Content-type: text/html; charset=utf-8");
  4. require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'AopClient.php';
  5. $privateKey = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAI6aysW0U9OcTN+kn+EOXlE4MHHDiL0THc2aYb83sDX5vLTfbNlmAsul02HzLmi2MVjQTfs3KvgUYoVFJK4OJOTy9/Hem/oiZLVHGOODip1Uch+qEJ4HRnZk+4EPcZuPyEcUS1dmrz6awAW7/llCOJWGCzlZYGOHngthZK6b5337AgMBAAECgYAEqku37A5R/esF5fzVAANV5OCw2BTBGr7+2u4Xs1qwaVsjD6wf8JZm0yX3Ll12T3+NyELE1SkytHgEpB5vE0dhqW0BEft+Z0RWERxyszAbW2y/lk23rN0TMefmxbGUYR2CJF1x5cGv0Cl+s8RtJ/3OcpNmiZoystRvWhMbySClAQJBAN3ewdzK5i/T/kXXEmNkptQO0AI0eNdj9v0s2NWIDj7q7yE8OK7U4cPv+E7qvzq3IrJATwRFJUzZ4xsqAvLjTOUCQQCkio+mhoY+p/VmNeYvGMNz9RnMevQplhKhtMj9sPI/cfg0EEhdoktsoG1Gfnn6u+dRqVl/DGa0LuHEBmODO9FfAkAIIAA5dbS4S6skI5wox6bUXTaA3isOuDpzSxElwLXE2BWpwerRfDpIUqFlQnN+UvaSUIiUP3P+PHx0ojU5b9mBAkBZ8m0IyW1FfyeFUl2czVq7XvdVcrlaqnFQ+LUPCdXDnRfjzirhFMFKhoB2Etm3mVSgrYUBENRsF1zPffaUXPTdAkBsy1U3YULc1lbgIZoa5N+nn60IbEuLkcW22DM+GGS+BejCR4cGF/4NPw6yVLEikGGxvaX6jg+/jAoF0GDlYmVH";
  6. $sxfPublic =
  7. "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCOmsrFtFPTnEzfpJ/hDl5RODBxw4i9Ex3NmmG/N7A1+by032zZZgLLpdNh8y5otjFY0E37Nyr4FGKFRSSuDiTk8vfx3pv6ImS1Rxjjg4qdVHIfqhCeB0Z2ZPuBD3Gbj8hHFEtXZq8+msAFu/5ZQjiVhgs5WWBjh54LYWSum+d9+wIDAQAB";
  8. $aopClient = new AopClient();
  9. $array = [
  10. //业务参数
  11. "mno"=> "399190910000387", //商户编号
  12. "ordNo"=> time(), //商户订单号
  13. //"subMechId"=> "", //子商户号
  14. //"subAppid"=> "", //微信 subAppId
  15. "amt"=> "0.02", //订单总金额
  16. //"discountAmt"=> "", //参与优惠金额
  17. //"unDiscountAmt"=> "", //不参与优惠金额
  18. "payType"=> "WECHAT", //支付渠道
  19. "subject"=> "C扫B测试",
  20. "tradeSource"=> "01", //交易来源 01服务商,02收银台,03硬件
  21. "trmIp"=> "127.0.0.1",
  22. //"hbFqNum"=> "6", //花呗分期数,仅可上送 6 或 12
  23. //"hbFqPercent"=> "0", //卖家承担分期 服务费比例,仅支持上送 0 或 100
  24. //"limitPay"=> "00", //限制卡类型: 00-全部 01-限定不能使 用信用卡支付 默认值 00
  25. //"timeExpire"=> "10", //订单失效时间
  26. //"goodsTag"=> "00", //订单优惠标识 00:是,01: 否
  27. //"couponDetail"=> "", //优惠详情信息,见下面三个字段
  28. //"costPrice"=> "200", //订单原价保留两 位小数;微信 独有
  29. //"receiptId"=> "123456789", //商品小票
  30. //"goodsDetail"=> "123456789", //单品优惠信息使用 json 数组格式提交
  31. //"goodsId"=> "200", //商品编码
  32. //"thirdGoodsId"=> "12345678", //微信/支付宝侧商品码
  33. //"goodsName"=> "苹果电脑", //商品名称
  34. //"quantity"=> "1", //商品数量
  35. //"price"=> "1.01", //商品单价
  36. //"goodsCategory"=> "", //商品类目;支 付宝独有
  37. //"categoriesTree"=> "124868003|126232002|126252004", //商品类目树
  38. //"goodsDesc"=> "", //商品描述;支 付宝独有
  39. //"showUrl"=> "", //商品展示地址 url;支付宝独有
  40. //"needReceipt"=> "00", //电子发票功能 微信开具电子 发票使用
  41. //"ledgerAccountFlag"=> "00", //是否做分账 分账交易使 用;00:做; 01:不做;不传默认为不做分账
  42. //"ledgerAccountEffectTime"=> "00", //分账有效时间 单位为天;是 否做分账选择 00 时该字段必传
  43. //"notifyUrl"=> "", //回调地址
  44. //"ylTrmNo"=> "", //银联终端号
  45. //"terminalId"=> "", //TQ机具编号
  46. //"deviceNo"=> "", //设备号
  47. //"identityFlag"=> "", //是否是实名支付
  48. //"buyerIdType"=> "IDCARD", //证件类型
  49. //"buyerIdNo"=> "410523198701054018", //证件号
  50. //"buyerName"=> "张三", //买家姓名
  51. //"mobileNum"=> "", //手机号
  52. //"extend"=> "" //备用
  53. ];
  54. $reqBean = [
  55. "orgId" =>"26680846",
  56. "reqData"=>$array,
  57. "reqId" => time(),
  58. "signType" => "RSA",
  59. "timestamp" => date("Y-m-d h:i:s"),
  60. "version" => "1.0",
  61. ];
  62. $signContent = $aopClient->generateSign($reqBean,$privateKey);
  63. $sign =["sign" => $signContent];
  64. $reqStr = array_merge($reqBean, $sign);
  65. $reqStr = json_encode($reqStr,320);
  66. $requestUrl = 'https://openapi-test.tianquetech.com/order/activeScan';
  67. $resp = $aopClient->curl($requestUrl, $reqStr);
  68. $result = json_decode($resp,320);
  69. print_r($result);
  70. $signResult = $result["sign"];
  71. // result.remove("sign");
  72. unset($result["sign"]);
  73. // String resultStr = RSASignature.getOrderContent(result);
  74. //sign
  75. /// String resultSign = RSASignature.encryptBASE64(RSASignature.sign(signContent, privateKey));
  76. $signContent = $aopClient->getSignContent($result);
  77. $verify = $aopClient->verify($signContent, $signResult,$sxfPublic);
  78. //组装加密串
  79. if ($verify) {
  80. echo("验签成功");
  81. }else{
  82. echo("验签失败");
  83. }
  84. ?>