TradeQuery.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. //正交易(主扫,被扫,聚合支付)查询
  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. //下面三个至少传一个
  13. "ordNo"=> "", //商户订单号
  14. "uuid"=> "", //科技公司订单号
  15. "transactionId"=> "", //正交易落单号
  16. //"terminalId"=> "", //TQ 机具编号, 支付来源为硬 件时,该参数 为必传;
  17. //"deviceNo"=> ""//设备号
  18. ];
  19. $reqBean = [
  20. "orgId" =>"26680846",
  21. "reqData"=>$array,
  22. "reqId" => time(),
  23. "signType" => "RSA",
  24. "timestamp" => date("Y-m-d h:i:s"),
  25. "version" => "1.0",
  26. ];
  27. $signContent = $aopClient->generateSign($reqBean,$privateKey);
  28. $sign =["sign" => $signContent];
  29. $reqStr = array_merge($reqBean, $sign);
  30. $reqStr = json_encode($reqStr,320);
  31. $requestUrl = 'https://openapi-test.tianquetech.com/query/tradeQuery';
  32. $resp = $aopClient->curl($requestUrl, $reqStr);
  33. $result = json_decode($resp,320);
  34. print_r($result);
  35. $signResult = $result["sign"];
  36. // result.remove("sign");
  37. unset($result["sign"]);
  38. // String resultStr = RSASignature.getOrderContent(result);
  39. //sign
  40. /// String resultSign = RSASignature.encryptBASE64(RSASignature.sign(signContent, privateKey));
  41. $signContent = $aopClient->getSignContent($result);
  42. $verify = $aopClient->verify($signContent, $signResult,$sxfPublic);
  43. //组装加密串
  44. if ($verify) {
  45. echo("验签成功");
  46. }else{
  47. echo("验签失败");
  48. }
  49. ?>