V2TerminaldeviceManageBindRequestDemo.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * 终端绑定 - 示例
  4. *
  5. * @author sdk-generator
  6. * @Description
  7. */
  8. namespace BsPayDemo;
  9. // 1. 资源及配置加载
  10. require_once dirname(__FILE__) . "/loader.php";
  11. require_once dirname(__FILE__). "/../BsPaySdk/request/V2TerminaldeviceManageBindRequest.php";
  12. use BsPaySdk\core\BsPayClient;
  13. use BsPaySdk\request\V2TerminaldeviceManageBindRequest;
  14. // 2.组装请求参数
  15. $request = new V2TerminaldeviceManageBindRequest();
  16. // 请求流水号
  17. $request->setReqSeqId(date("YmdHis").mt_rand());
  18. // 请求时间
  19. $request->setReqDate(date("Ymd"));
  20. // 汇付ID
  21. $request->setHuifuId("6666000104633016");
  22. // 终端号
  23. $request->setDeviceId("660035140101001076698");
  24. // 设置非必填字段
  25. $extendInfoMap = getExtendInfos();
  26. $request->setExtendInfo($extendInfoMap);
  27. // 3. 发起API调用
  28. $client = new BsPayClient();
  29. $result = $client->postRequest($request);
  30. if (!$result || $result->isError()) { //失败处理
  31. var_dump($result -> getErrorInfo());
  32. } else { //成功处理
  33. var_dump($result);
  34. }
  35. /**
  36. * 非必填字段
  37. *
  38. */
  39. function getExtendInfos() {
  40. // 设置非必填字段
  41. $extendInfoMap = array();
  42. return $extendInfoMap;
  43. }