TradeRefund.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. "ordNo"=> time(), //商户订单号
  13. //下面三个至少传一个
  14. "origOrderNo"=> "", //原商户订单号
  15. "origUuid"=> "", //原交易科技公司订单号
  16. "origSxfUuid"=> "", //正交易落单号
  17. "amt"=> "88.88", //正交易落单号
  18. // "notifyUrl"=> "", //回调推送地址,用来接收科技公司的异步推送
  19. "refundReason"=> "退货", //退货原因
  20. "extend"=> "" //备用
  21. ];
  22. $reqBean = [
  23. "orgId" =>"26680846",
  24. "reqData"=>$array,
  25. "reqId" => time(),
  26. "signType" => "RSA",
  27. "timestamp" => date("Y-m-d h:i:s"),
  28. "version" => "1.0",
  29. ];
  30. $signContent = $aopClient->generateSign($reqBean,$privateKey);
  31. $sign =["sign" => $signContent];
  32. $reqStr = array_merge($reqBean, $sign);
  33. $reqStr = json_encode($reqStr,320);
  34. $requestUrl = 'https://openapi-test.tianquetech.com/order/refund';
  35. $resp = $aopClient->curl($requestUrl, $reqStr);
  36. $result = json_decode($resp,320);
  37. print_r($result);
  38. $signResult = $result["sign"];
  39. // result.remove("sign");
  40. unset($result["sign"]);
  41. // String resultStr = RSASignature.getOrderContent(result);
  42. //sign
  43. /// String resultSign = RSASignature.encryptBASE64(RSASignature.sign(signContent, privateKey));
  44. $signContent = $aopClient->getSignContent($result);
  45. $verify = $aopClient->verify($signContent, $signResult,$sxfPublic);
  46. //组装加密串
  47. if ($verify) {
  48. echo("验签成功");
  49. }else{
  50. echo("验签失败");
  51. }
  52. ?>