V2QuickbuckleConfirmRequestDemo.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/V2QuickbuckleConfirmRequest.php";
  12. use BsPaySdk\core\BsPayClient;
  13. use BsPaySdk\request\V2QuickbuckleConfirmRequest;
  14. // 2.组装请求参数
  15. $request = new V2QuickbuckleConfirmRequest();
  16. // 请求日期
  17. $request->setReqDate(date("Ymd"));
  18. // 请求流水号
  19. $request->setReqSeqId(date("YmdHis").mt_rand());
  20. // 汇付商户Id
  21. $request->setHuifuId("6666000003078984");
  22. // 用户id
  23. $request->setOutCustId("6666000103633622");
  24. // 订单号
  25. $request->setOrderId("20220408105303542461831");
  26. // 订单日期
  27. $request->setOrderDate("20220408");
  28. // 银行卡号
  29. $request->setCardId("Ly+fnExeyPOTzfOtgRRur77nJB9TAe4PGgK9MB96o3LW2xINIxSA+B1jXDyvKNmJ5iE3wL+bbNoGd6tQXn6fmrY4vgeX8diCtP0PQVyS4UZkXzH4w8twgI+FduIukqTTl7o5/rrnL3H1HaP/Vutw3yBWrGq0l0NTebfc6XJXZss=");
  30. // 银行卡开户姓名
  31. $request->setCardName("CDszEs+NOr7m3rh7qJhciqMN4mP1yXJtwXX6HFzBJ3rwJYUxSXFEv4f6AAQychfVPB2BgZeEoK6gtjrTPfv4G3SHqoow0Way6kdsGZYmXotcq1TFmmL+QKJSAhE4tl+vs69wCHh/l4X+Rxp4AyDK7zb8XG1GWOZOwshU/SOUukM=");
  32. // 银行卡绑定证件类型
  33. $request->setCertType("00");
  34. // 银行卡绑定身份证
  35. $request->setCertId("EXDKKVOSFZCFyB5p7VWlYYH+M1Y2dg9PzVBtX9LqF3w4NWtWg/id+XTFtLuC2ntaflB9ioohwPUuiSg/mp15MKV86u7/DPT84DuM/NTOTRS/ajO8rJ1ERhtyRxT5czJWGbpysQOBA+msxOjIG5k0MkP18nZDhpg07HoGArjmp08=");
  36. // 银行卡绑定手机号
  37. $request->setCardMp("Qb6AcD/EaT0gKP7d2ercByeTw2oe5loZayPuKEzQi75nZKxCyJPoIvUHTvFLRqpLDNzkpvy/aAg6xvbsw1WXdKYWB15D9LpCnYQ7qHw16IjfnPA4FDR3CE5h+nU6lGoJDj+hNRkn3y73aCeNpp5E//uDKJdjrJv6ciACf4lofAo=");
  38. // 验证码
  39. $request->setVerifyCode("111111");
  40. // CVV2信用卡代扣专用需要密文传输,使用汇付RSA公钥加密(加密前3位,加密后最长2048位),[参见参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);&lt;br/&gt;&lt;font color&#x3D;&quot;green&quot;&gt;示例值:Ly+fnExeyPOTzf……rGq0l0NTebfc6XJXZss&#x3D;&lt;/font&gt;
  41. $request->setVipCode("BndOZvPCXIMcRJi1uCkw4DiNHht+KkARa+sbKbiLh4cXhjywxYM8GMl7g1a5cc1aD2PD6rVvnGzhhgpJ8mzeb/gbzNcYbU5hEXJZm5HShghGucQJB/SoqCIlyaWlz3hnclaGzznWJa5qNa50mCxVqX4zbpuGPWXv+8AnYTu8/Vk=");
  42. // 卡有效期信用卡代扣专用,格式:MMYY,需要密文传输。&lt;br/&gt;使用汇付RSA公钥加密(加密前4位,加密后最长2048位),[参见参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);&lt;br/&gt;&lt;font color&#x3D;&quot;green&quot;&gt;示例值:Ly+fnExeyPO……ebfc6XJXZss&#x3D;&lt;/font&gt;
  43. // $request->setExpiration("test");
  44. // 设备信息域 
  45. // $request->setTrxDeviceInf(getTrxDeviceInf());
  46. // 设置非必填字段
  47. $extendInfoMap = getExtendInfos();
  48. $request->setExtendInfo($extendInfoMap);
  49. // 3. 发起API调用
  50. $client = new BsPayClient();
  51. $result = $client->postRequest($request);
  52. if (!$result || $result->isError()) { //失败处理
  53. var_dump($result -> getErrorInfo());
  54. } else { //成功处理
  55. var_dump($result);
  56. }
  57. /**
  58. * 非必填字段
  59. *
  60. */
  61. function getExtendInfos() {
  62. // 设置非必填字段
  63. $extendInfoMap = array();
  64. // 商户名称
  65. $extendInfoMap["merch_name"]= "测试";
  66. // 验卡流水号
  67. $extendInfoMap["trans_id"]= "20220408105303542461831";
  68. // 卡的借贷类型
  69. // $extendInfoMap["dc_type"]= "";
  70. // 风控信息
  71. // $extendInfoMap["risk_info"]= getRiskInfo();
  72. return $extendInfoMap;
  73. }
  74. function getTrxDeviceInf() {
  75. $dto = array();
  76. // 银行预留手机号
  77. // $dto["trx_mobile_num"] = "test";
  78. // 设备类型
  79. // $dto["trx_device_type"] = "test";
  80. // 交易设备IP
  81. // $dto["trx_device_ip"] = "test";
  82. // 交易设备MAC
  83. // $dto["trx_device_mac"] = "";
  84. // 交易设备IMEI
  85. // $dto["trx_device_imei"] = "";
  86. // 交易设备IMSI
  87. // $dto["trx_device_imsi"] = "";
  88. // 交易设备ICCID
  89. // $dto["trx_device_icc_id"] = "";
  90. // 交易设备WIFIMAC
  91. // $dto["trx_device_wfifi_mac"] = "";
  92. // 交易设备GPS
  93. // $dto["trx_device_gps"] = "";
  94. return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
  95. }
  96. function getRiskInfo() {
  97. $dto = array();
  98. // IP类型
  99. // $dto["ip_type"] = "test";
  100. // IP值
  101. // $dto["source_ip"] = "test";
  102. // 设备标识
  103. // $dto["device_id"] = "";
  104. // 设备类型
  105. // $dto["device_type"] = "";
  106. // 银行预留手机号
  107. // $dto["mobile"] = "";
  108. return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
  109. }