V2QuickbuckleWithholdApplyRequestDemo.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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/V2QuickbuckleWithholdApplyRequest.php";
  12. use BsPaySdk\core\BsPayClient;
  13. use BsPaySdk\request\V2QuickbuckleWithholdApplyRequest;
  14. // 2.组装请求参数
  15. $request = new V2QuickbuckleWithholdApplyRequest();
  16. // 请求流水号
  17. $request->setReqSeqId(date("YmdHis").mt_rand());
  18. // 请求时间
  19. $request->setReqDate(date("Ymd"));
  20. // 汇付Id
  21. $request->setHuifuId("6666000003078984");
  22. // 返回地址
  23. $request->setReturnUrl("http://www.huifu1234.com/");
  24. // 用户id
  25. $request->setOutCustId("16666000106789536");
  26. // 绑卡订单号
  27. $request->setOrderId("20230525081932677893621");
  28. // 绑卡订单日期
  29. $request->setOrderDate("20230525");
  30. // 银行卡号
  31. $request->setCardId("ZSSW+34A2soLbwLQ5SkZJO4Azy6BknTGkk6EYDTbGA+G0v+zcF3TnU4iYH171KB4ReLjJlY+hSy8MvgVbAx7dL9V7LvLFJd8RE+Lp6XKiIbVUCA1wd2Otp2jI2D32z5gUFqUbB4clRZyRyltXV3xmAWH4fLZDER3H+QwC0/UNF4=");
  32. // 银行卡开户姓名 
  33. $request->setCardName("H12ShtAyV4I4sOQqbISH4eMQUcmzpYOHggxRcXhxNoForh5qLyFgDrsSTn0nnepnPO8okfZYSWQlWIBzsRyyHYwAk94s2sO2Sz/6q4Jg2xDieeGDGrnrAphc8/OAN2OK8dMdbQzL12MvPQU/GX148MCxJzGvvdRFqTEPRLOLXTs=");
  34. // 银行卡绑定证件类型 
  35. $request->setCertType("00");
  36. // 银行卡绑定身份证
  37. $request->setCertId("FviSPp2Xv6QYfRSYRZcouGAz4BvfZRS9nFKI/7daIUtn4JmBVMTDtrqKLCWeoY7WP4hQAz3rptjOe8WsuynRG3kQhBsXZB0v6e1X1+POD5FXVojquKQb1BF5tKlaOqTj/+G62URC3SWui26JzQQmjGhCORXXHFD7PPNJKusYhHI=");
  38. // 银行卡绑定手机号 
  39. $request->setCardMp("GmMLD+v2Mfc/vr9HOVFKOon3Dl4Q9cjze21X902G8Dnl2/2rpH8wpJUnufoYnI0nR9D2XkOm0ApOJL3ShiZxgLvnTaKrTDjRdrBJexhXbbhbfDx/2x+ZULvZHOEjzRI21tK2WKUzxDhX/lw/iXMjslKNVYlQ7as/aH5bLipf12g=");
  40. // CVV2信用卡代扣专用 需要密文传输,需要密文传输,使用汇付RSA公钥加密(加密前64位,加密后最长2048位),参见[参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);
  41. $request->setVipCode("HOVFKOon3Dl4Q9cjze21X902G8Dnl2LvLFJd8RE+Lp6XKiIbVUCA1wd2Otp2jI2D32z5gUFqUbB4clRZyRyltXV3xmAWH4fLZDER3H+YwAk94s2sO2Sz/6q4Jg2xDieesO2Sz/6q4Jg2xDieeGDGbQzL12MvPQU/GX14xJzGvvd=");
  42. // 卡有效期 信用卡代扣专用,格式:MMYY 需要密文传输,使用汇付RSA公钥加密(加密前64位,加密后最长2048位),参见[参考文档](https://paas.huifu.com/partners/guide/#/api_jiami_jiemi);
  43. $request->setExpiration("IUtn4JmBVMTDtrqKLCWeoY7WP4hQAz3rptjOe8WsuySW+34SkZJO4Azy6BknTGkk6EA2soLbwLQ5SkZJO4Azy6BknTGkk6EX902G8Dnl2/2rpH8wpJUnufoYnI0nR9YDTbGA+G0v+ApOJL3ShiZxgLvnTaKrnU4iYH171KB4=");
  44. // 个人证件有效期类型
  45. $request->setCertValidityType("0");
  46. // 个人证件有效期起始日
  47. $request->setCertBeginDate("20140504");
  48. // 个人证件有效期到期日长期有效不填.格式:YYYYMMDD;&lt;font color&#x3D;&quot;green&quot;&gt;示例值:20450112&lt;/font&gt;
  49. $request->setCertEndDate("20260504");
  50. // 卡的借贷类型
  51. // $request->setDcType("test");
  52. // 设置非必填字段
  53. $extendInfoMap = getExtendInfos();
  54. $request->setExtendInfo($extendInfoMap);
  55. // 3. 发起API调用
  56. $client = new BsPayClient();
  57. $result = $client->postRequest($request);
  58. if (!$result || $result->isError()) { //失败处理
  59. var_dump($result -> getErrorInfo());
  60. } else { //成功处理
  61. var_dump($result);
  62. }
  63. /**
  64. * 非必填字段
  65. *
  66. */
  67. function getExtendInfos() {
  68. // 设置非必填字段
  69. $extendInfoMap = array();
  70. // 页面有效期
  71. $extendInfoMap["expire_time"]= "15";
  72. // 设备信息域
  73. $extendInfoMap["trx_device_info"]= getTrxDeviceInfo();
  74. // 风控信息
  75. $extendInfoMap["risk_info"]= getRiskInfo();
  76. return $extendInfoMap;
  77. }
  78. function getTrxDeviceInfo() {
  79. $dto = array();
  80. // 银行预留手机号
  81. $dto["trx_mobile_num"] = "15556622368";
  82. // 设备类型
  83. $dto["trx_device_type"] = "1";
  84. // 交易设备IP
  85. $dto["trx_device_ip"] = "10.10.0.1";
  86. // 交易设备MAC
  87. $dto["trx_device_mac"] = "10.10.0.1";
  88. // 交易设备IMEI
  89. $dto["trx_device_imei"] = "030147441006000182623";
  90. // 交易设备IMSI
  91. $dto["trx_device_imsi"] = "030147441006000182623";
  92. // 交易设备ICCID
  93. $dto["trx_device_icc_id"] = "030147441006000182623";
  94. // 交易设备WIFIMAC
  95. $dto["trx_device_wfifi_mac"] = "030147441006000182623";
  96. // 交易设备GPS
  97. $dto["trx_device_gps"] = "030147441006000182623";
  98. return $dto;
  99. }
  100. function getRiskInfo() {
  101. $dto = array();
  102. // IP类型
  103. $dto["ip_type"] = "04";
  104. // IP值
  105. $dto["source_ip"] = "192.168.1.2";
  106. // 设备标识
  107. $dto["device_id"] = "123";
  108. // 设备类型
  109. $dto["device_type"] = "1";
  110. // 银行预留手机号
  111. $dto["mobile"] = "13778787106";
  112. return json_encode($dto,JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
  113. }