V2TradeSettlementSurrogateRequestDemo.php 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/V2TradeSettlementSurrogateRequest.php";
  12. use BsPaySdk\core\BsPayClient;
  13. use BsPaySdk\request\V2TradeSettlementSurrogateRequest;
  14. // 2.组装请求参数
  15. $request = new V2TradeSettlementSurrogateRequest();
  16. // 请求流水号
  17. $request->setReqSeqId(date("YmdHis").mt_rand());
  18. // 请求日期
  19. $request->setReqDate(date("Ymd"));
  20. // 商户号
  21. $request->setHuifuId("6666000000041651");
  22. // 代发金额
  23. $request->setCashAmt("9.00");
  24. // 代发用途描述
  25. $request->setPurposeDesc("v2测试用");
  26. // 省份选填,参见[代发省市地区码](https://cloudpnrcdn.oss-cn-shanghai.aliyuncs.com/opps/api/prod/download_file/area/%E6%96%97%E6%8B%B1%E4%BB%A3%E5%8F%91%E7%9C%81%E4%BB%BD%E5%9C%B0%E5%8C%BA%E7%BC%96%E7%A0%81.xlsx);&lt;font color&#x3D;&quot;green&quot;&gt;示例值:0013&lt;/font&gt;&lt;br/&gt;对公代发(省份+地区)与联行号信息二选一填入;对私代发非必填;
  27. $request->setProvince("0278");
  28. // 地区选填,参见[代发省市地区码](https://cloudpnrcdn.oss-cn-shanghai.aliyuncs.com/opps/api/prod/download_file/area/%E6%96%97%E6%8B%B1%E4%BB%A3%E5%8F%91%E7%9C%81%E4%BB%BD%E5%9C%B0%E5%8C%BA%E7%BC%96%E7%A0%81.xlsx);&lt;font color&#x3D;&quot;green&quot;&gt;示例值:1301&lt;/font&gt;&lt;br/&gt;对公代发(省份+地区)与联行号信息二选一填入;对私代发非必填;
  29. $request->setArea("2619");
  30. // 银行编号
  31. $request->setBankCode("01020000");
  32. // 联行号选填,参见:[银行支行编码](https://paas.huifu.com/partners/api/#/csfl/api_csfl_yhzhbm) &lt;font color&#x3D;&quot;green&quot;&gt;示例值:102290026507&lt;/font&gt;&lt;br/&gt;对公代发(省份+地区)与联行号信息二选一填入;对私代发非必填;
  33. $request->setCorrespondentCode("correspondentCode");
  34. // 银行卡用户名
  35. $request->setBankAccountName("王大锤");
  36. // 对公对私标识
  37. $request->setCardAcctType("E");
  38. // 银行账号密文
  39. $request->setBankCardNoCrypt("fM3G4fV8dfyA9GvSPckj7DM/0ZPgIuTrCj5chjRP2np/j+5xBkDp+hGLSskALgMijL837blhwVwfpPstkR2t+0aLtRLC1IpggVKKbNefoqcahF2a4zh+YssAulOoQ6T7DDWTjaa0qzILmLV+J/CCW6ioE+pdsBlGKee7Cc0iD6VqAjkSmnx2kWadz9CpaH8ayvyivdkc87SHsSgexQ5scyZdkGYSpXtRf/rSTcfsf5Q3NP+uKA6lJ0hnESiCw/1POoszJrSlGT2U7jpQLDWVENKcW06bReKxQuAdxFaX4DqkwbQeN5nzHvYh14IU8KrZZDAoiCx12x+IcHIVB2tBmw==");
  40. // 证件号密文
  41. $request->setCertificateNoCrypt("cw8BlH40+weHiFnIonCiSak1wWeCiRWpMF1cBHhuE+vagzKT37MRvouVboLnaWwIry3joQOoVJipDTPpzAMGVrbLQTdtZoHhgyynnD3MS0NTPch2W4i9dO3/ikLylbs2HitUlCThXEX7DIrIbLLYZ7zzeYUyXAs6dKlehMNxAaF4utJpxV84tB3ZmCKKFairE6+al4Id+/c7536G0j5lKn7lWSawl8A1UEbMMmHFvydGEBgaCAmvu0WEx7llhtPl1GpJnwqieAt9u+lM0cjUGEYfw54/JnmEF3uVuHqjco/EAMKmWiqONqCT4ptBLlOiT15FUejK0iFiUrS0Y3ytMg==");
  42. // 证件类型
  43. $request->setCertificateType("01");
  44. // 手机号密文
  45. $request->setMobileNoCrypt("Uc2rjt3iqQMIjUubLKvrE4ynG2XoZDXl4sSqHB7xFvz6EyhS+WMm+tp7WLzG97PqdsmlfURRLjmSR3u98Zz0HV7wO4zvUwdOMzA1rX2Ab9Cz6eKHBWwkRpEn8zmq3KdsHpifKd5y6/MuEyXJ6tdKjBrmXTn3Ut6goz+yhUcPbvV4HEMCybRmF9YTvblb7Yk8trMHjOkq6J6EIEfQL3X07WTNpseCtuYF/j5tNws4boezEmOnS2hNkneMR+OfRaZ6UndFAMHd/Lj9fY2mscpPnWNACtmsD2nh0Z8ziwzCYnYAH2EV988cSq2vi3fkgCtd5b8zNGp+XJBefPaK7Vcp+w==");
  46. // 到账日期类型
  47. $request->setIntoAcctDateType("T0");
  48. // 设置非必填字段
  49. $extendInfoMap = getExtendInfos();
  50. $request->setExtendInfo($extendInfoMap);
  51. // 3. 发起API调用
  52. $client = new BsPayClient();
  53. $result = $client->postRequest($request);
  54. if (!$result || $result->isError()) { //失败处理
  55. var_dump($result -> getErrorInfo());
  56. } else { //成功处理
  57. var_dump($result);
  58. }
  59. /**
  60. * 非必填字段
  61. *
  62. */
  63. function getExtendInfos() {
  64. // 设置非必填字段
  65. $extendInfoMap = array();
  66. // 支行名
  67. $extendInfoMap["subbranch_bank_name"]= "subbranchBankName";
  68. // 收款方三证合一码
  69. $extendInfoMap["bank_acct_three_in_one"]= "dfa";
  70. // 异步通知地址
  71. $extendInfoMap["notify_url"]= "http://www.gangcai.com";
  72. return $extendInfoMap;
  73. }