querylist.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * 订单批量查询
  4. *
  5. * @date 2017年3月13日
  6. * @copyright 重庆迅虎网络有限公司
  7. */
  8. require_once 'api.php';
  9. $out_trade_order = '20180921023800';//商户网站订单号
  10. $appid = '2147483647';//测试账户,
  11. $appsecret = '160130736b1ac0d54ed7abe51e44840b';//测试账户,
  12. $request=array(
  13. 'appid' => $appid, //必须的,APPID
  14. 'skip' =>0,//跳过订单条数
  15. 'take' =>50,//每页取订单条数(最大1000)
  16. 'status' =>'',//可选,取值OD已支付, WP待支付, CD已取消
  17. 'start' =>'',//可选 ,订单开始时间 格式:2018-12-20 12:00
  18. 'end' =>'',//可选 ,订单结束时间 格式:2018-12-20 12:00
  19. 'time' => time(),//必须的,当前时间戳,根据此字段判断订单请求是否已超时,防止第三方攻击服务器
  20. 'nonce_str' => str_shuffle(time())//必须的,随机字符串,作用:1.避免服务器缓存,2.防止安全密钥被猜测出来
  21. );
  22. $request['hash'] = XH_Payment_Api::generate_xh_hash($request,$appsecret);
  23. $url = 'https://api.xunhupay.com/payment/querylist.html';
  24. try {
  25. $response = XH_Payment_Api::http_post($url, http_build_query($request));
  26. /**
  27. * 支付回调数据
  28. * @var array(
  29. * status,//OD:已支付 WP:未支付 CD 已取消
  30. * )
  31. */
  32. $result = $response?json_decode($response,true):null;
  33. if(!$result){
  34. throw new Exception('Internal server error:'.$response,500);
  35. }
  36. print_r($result);exit;
  37. } catch (Exception $e) {
  38. echo "errcode:{$e->getCode()},errmsg:{$e->getMessage()}";
  39. //TODO:处理支付调用异常的情况
  40. }
  41. ?>