蛋蛋星球-制度模式
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zhima_api_test.go 14 KiB

1 month ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. package alipay
  2. import (
  3. "errors"
  4. "testing"
  5. "github.com/go-pay/gopay"
  6. "github.com/go-pay/util"
  7. "github.com/go-pay/xlog"
  8. )
  9. // 芝麻企业信用信用评估初始化测试
  10. func TestZhimaCreditEpSceneRatingInitialize(t *testing.T) {
  11. // 请求参数
  12. bm := make(gopay.BodyMap)
  13. bm.Set("credit_category", "ZMSCCO_5_1_1")
  14. bm.Set("product_code", "w1010100100000000001")
  15. bm.Set("out_order_no", "201805301527674106562F0000954216")
  16. bm.Set("user_id", "2088302248028263")
  17. aliRsp, err := client.ZhimaCreditEpSceneRatingInitialize(ctx, bm)
  18. if err != nil {
  19. //xlog.Errorf("client.ZhimaCreditEpSceneRatingInitialize(%+v),error:%+v", bm, err)
  20. return
  21. }
  22. xlog.Debug("aliRsp:", *aliRsp)
  23. }
  24. // 信用服务履约同步测试
  25. func TestZhimaCreditEpSceneFulfillmentSync(t *testing.T) {
  26. // 请求参数
  27. bm := make(gopay.BodyMap)
  28. bm.Set("credit_order_no", "zme20181106154144733795615964647")
  29. bm.Set("out_order_no", "trade201805301527674106562F0000954217")
  30. bm.Set("biz_time", "2018-12-06 18:53:59")
  31. bm.Set("biz_ext_param", "{\"total_amount\":\"32890\"}")
  32. aliRsp, err := client.ZhimaCreditEpSceneFulfillmentSync(ctx, bm)
  33. if err != nil {
  34. //xlog.Errorf("client.ZhimaCreditEpSceneFulfillmentSync(%+v),error:%+v", bm, err)
  35. return
  36. }
  37. xlog.Debug("aliRsp:", *aliRsp)
  38. }
  39. // 加入信用服务测试
  40. func TestZhimaCreditEpSceneAgreementUse(t *testing.T) {
  41. // 请求参数
  42. bm := make(gopay.BodyMap)
  43. bm.Set("rating_order_no", "zme20181106154144730565715957902")
  44. bm.Set("out_order_no", "test201805301527674106562F0000954216")
  45. bm.Set("biz_time", "2018-12-06 18:53:59")
  46. bm.Set("provision_code", "P$ZMSCCO_5_1_1$00001")
  47. bm.Set("biz_ext_param", "{\"total_amount\":\"32890\"}")
  48. aliRsp, err := client.ZhimaCreditEpSceneAgreementUse(ctx, bm)
  49. if err != nil {
  50. //xlog.Errorf("client.ZhimaCreditEpSceneAgreementUse(%+v),error:%+v", bm, err)
  51. return
  52. }
  53. xlog.Debug("aliRsp:", *aliRsp)
  54. }
  55. // 取消信用服务测试
  56. func TestZhimaCreditEpSceneAgreementCancel(t *testing.T) {
  57. // 请求参数
  58. bm := make(gopay.BodyMap)
  59. bm.Set("credit_order_no", "zme20181106154144733795615964647")
  60. bm.Set("out_order_no", util.RandomString(64))
  61. bm.Set("biz_time", "2018-12-06 18:53:59")
  62. aliRsp, err := client.ZhimaCreditEpSceneAgreementCancel(ctx, bm)
  63. if err != nil {
  64. //xlog.Errorf("client.ZhimaCreditEpSceneAgreementCancel(%+v),error:%+v", bm, err)
  65. return
  66. }
  67. xlog.Debug("aliRsp:", *aliRsp)
  68. }
  69. // 信用服务履约同步(批量)测试
  70. func TestZhimaCreditEpSceneFulfillmentlistSync(t *testing.T) {
  71. // 请求参数
  72. bm := make(gopay.BodyMap)
  73. bm.Set("credit_order_no", "zme20181106154144733795615964647")
  74. bm.SetBodyMap("fulfillment_info_list", func(bm gopay.BodyMap) {
  75. bm.Set("out_order_no", "trade201805301527674106562F0000954217")
  76. bm.Set("biz_time", "2018-12-06 18:53:59")
  77. bm.Set("biz_ext_param", "{\"total_amount\":\"32890\"}")
  78. })
  79. aliRsp, err := client.ZhimaCreditEpSceneFulfillmentlistSync(ctx, bm)
  80. if err != nil {
  81. //xlog.Errorf("client.ZhimaCreditEpSceneFulfillmentlistSync(%+v),error:%+v", bm, err)
  82. return
  83. }
  84. xlog.Debug("aliRsp:", *aliRsp)
  85. }
  86. // 芝麻go用户数据回传测试
  87. func TestZhimaCreditPeZmgoCumulationSync(t *testing.T) {
  88. // 请求参数
  89. bm := make(gopay.BodyMap)
  90. bm.Set("agreement_no", "20195108518085620000")
  91. bm.Set("user_id", "2088602002015001")
  92. bm.Set("partner_id", "2088621805983504")
  93. bm.Set("out_biz_no", "2020081211223006150094012926289")
  94. bm.Set("biz_time", "2019-03-08 19:51:35")
  95. bm.Set("request_from", "ExternalMerchantSource")
  96. bm.Set("biz_action", "ORDER_PAID")
  97. // 可选
  98. bm.Set("cumulate_data_type", "AMOUNT")
  99. bm.Set("pay_out_biz_no", "2020081211223006150094012926289")
  100. bm.Set("has_alipay_trade", "false")
  101. bm.Set("ext_info", "{\"number\":\"20200303938282939\"}")
  102. bm.SetBodyMap("task_type_data", func(bm gopay.BodyMap) {
  103. bm.Set("name", "滴滴打车任务001")
  104. })
  105. bm.SetBodyMap("amount_type_data", func(bm gopay.BodyMap) {
  106. bm.Set("name", "优惠累计名称001")
  107. bm.SetBodyMap("trade_info", func(bm gopay.BodyMap) {
  108. bm.Set("trade_no", "2020081722001435461000061785")
  109. bm.Set("amount", "3.57")
  110. })
  111. bm.SetBodyMap("out_discount_infos", func(bm gopay.BodyMap) {
  112. bm.Set("discount_name", "滴滴打车优惠001")
  113. bm.Set("discount_type", "exclusiveBenefit")
  114. bm.Set("discount_amount", "8.75")
  115. })
  116. })
  117. aliRsp, err := client.ZhimaCreditPeZmgoCumulationSync(ctx, bm)
  118. if err != nil {
  119. //xlog.Errorf("client.ZhimaCreditPeZmgoCumulationSync(%+v),error:%+v", bm, err)
  120. return
  121. }
  122. xlog.Debug("aliRsp:", *aliRsp)
  123. }
  124. // 商家芝麻GO累计数据回传接口测试
  125. func TestZhimaMerchantZmgoCumulateSync(t *testing.T) {
  126. // 请求参数
  127. bm := make(gopay.BodyMap)
  128. bm.Set("agreement_id", "20195108518085620000")
  129. bm.Set("user_id", "2088602002015001")
  130. bm.Set("provider_pid", "2088621805983504")
  131. bm.Set("out_biz_no", "2020081211223006150094012926289")
  132. bm.Set("biz_time", "2019-03-08 19:51:35")
  133. bm.Set("biz_action", "POSITIVE")
  134. bm.Set("sub_biz_action", "ADD")
  135. bm.Set("data_type", "TASK")
  136. // 可选
  137. bm.Set("refer_out_biz_no", "2020081211223006150094012926289")
  138. bm.SetBodyMap("amount_type_sync_data", func(bm gopay.BodyMap) {
  139. bm.Set("task_desc", "完成一次任务001")
  140. bm.Set("task_amount", "3.57")
  141. bm.Set("trade_no", "2020081722001435461000061785")
  142. bm.Set("has_alipay_trade", "false")
  143. bm.Set("discount_desc", "消费满减优惠001")
  144. bm.Set("discount_amount", "8.75")
  145. })
  146. bm.SetBodyMap("times_type_sync_data", func(bm gopay.BodyMap) {
  147. bm.Set("task_desc", "完成一次任务001")
  148. bm.Set("task_times", "1")
  149. bm.Set("task_amount", "3.57")
  150. bm.Set("discount_desc", "消费满减优惠001")
  151. bm.Set("discount_amount", "8.75")
  152. })
  153. bm.SetBodyMap("discount_type_sync_data", func(bm gopay.BodyMap) {
  154. bm.Set("discount_desc", "消费满减优惠001")
  155. bm.Set("discount_amount", "8.75")
  156. })
  157. aliRsp, err := client.ZhimaMerchantZmgoCumulateSync(ctx, bm)
  158. if err != nil {
  159. //xlog.Errorf("client.ZhimaMerchantZmgoCumulateSync(%+v),error:%+v", bm, err)
  160. return
  161. }
  162. xlog.Debug("aliRsp:", *aliRsp)
  163. }
  164. // 商家芝麻GO累计数据查询接口测试
  165. func TestZhimaMerchantZmgoCumulateQuery(t *testing.T) {
  166. // 请求参数
  167. bm := make(gopay.BodyMap)
  168. bm.Set("agreement_id", "20195108518085620000")
  169. bm.Set("user_id", "2088602002015001")
  170. bm.Set("provider_pid", "2088621805983504")
  171. // 可选
  172. bm.Set("need_detail", "false")
  173. bm.Set("page_no", "1")
  174. bm.Set("page_size", "20")
  175. aliRsp, err := client.ZhimaMerchantZmgoCumulateQuery(ctx, bm)
  176. if err != nil {
  177. //xlog.Errorf("client.ZhimaMerchantZmgoCumulateQuery(%+v),error:%+v", bm, err)
  178. return
  179. }
  180. xlog.Debug("aliRsp:", *aliRsp)
  181. }
  182. // 芝麻GO签约关单测试
  183. func TestZhimaCreditPeZmgoBizoptClose(t *testing.T) {
  184. // 请求参数
  185. bm := make(gopay.BodyMap)
  186. bm.Set("alipay_user_id", "2088302841345600")
  187. bm.Set("partner_id", "2088302424614288")
  188. bm.Set("out_request_no", "99202005050100930053707258")
  189. bm.Set("template_id", "2021012300020903090008858258")
  190. aliRsp, err := client.ZhimaCreditPeZmgoBizoptClose(ctx, bm)
  191. if err != nil {
  192. //xlog.Errorf("client.ZhimaCreditPeZmgoBizoptClose(%+v),error:%+v", bm, err)
  193. return
  194. }
  195. xlog.Debug("aliRsp:", *aliRsp)
  196. }
  197. // 芝麻GO结算退款接口测试
  198. func TestZhimaCreditPeZmgoSettleRefund(t *testing.T) {
  199. // 请求参数
  200. bm := make(gopay.BodyMap)
  201. bm.Set("agreement_id", "ZMGO_AGR2021010510020604080000006001")
  202. bm.Set("partner_id", "2088302424614288")
  203. bm.Set("alipay_user_id", "2088302841345600")
  204. bm.Set("refund_amount", "3.00")
  205. bm.Set("out_request_no", "99202005050100930053707258")
  206. // 可选
  207. bm.Set("memo", "退款")
  208. bm.Set("withhold_plan_no", "ZMGO_WHD2021010510020603410000006001")
  209. bm.Set("refund_type", "MEMBER_FEE_REFUND")
  210. aliRsp, err := client.ZhimaCreditPeZmgoSettleRefund(ctx, bm)
  211. if err != nil {
  212. //xlog.Errorf("client.ZhimaCreditPeZmgoSettleRefund(%+v),error:%+v", bm, err)
  213. return
  214. }
  215. xlog.Debug("aliRsp:", *aliRsp)
  216. }
  217. // 芝麻GO签约预创单测试
  218. func TestZhimaCreditPeZmgoPreorderCreate(t *testing.T) {
  219. // 请求参数
  220. bm := make(gopay.BodyMap)
  221. bm.Set("partner_id", "2088437463829741")
  222. bm.Set("template_id", "2020122200020903760008552025")
  223. bm.Set("out_request_no", "ORDER_12345678")
  224. bm.Set("biz_time", "2016-07-06 00:00:02")
  225. // 可选
  226. bm.Set("freeze_amount", "1.00")
  227. bm.Set("timeout_express", "15m")
  228. bm.Set("alipay_user_id", "2088759402857364")
  229. bm.Set("partner_user_identifier", "user102934889234")
  230. bm.Set("isv_pid", "2088374762857463")
  231. bm.Set("sign_aisle_data", "业务方签约标识")
  232. bm.Set("expire_aisle_data", "业务方签约标识")
  233. bm.Set("pay_aisle_data", "业务方签约标识")
  234. bm.SetBodyMap("ext_template_conf", func(bm gopay.BodyMap) {
  235. bm.Set("xxhm_info_id", "687542")
  236. bm.Set("buyer_id", "11212321121")
  237. })
  238. aliRsp, err := client.ZhimaCreditPeZmgoPreorderCreate(ctx, bm)
  239. if err != nil {
  240. //xlog.Errorf("client.ZhimaCreditPeZmgoPreorderCreate(%+v),error:%+v", bm, err)
  241. return
  242. }
  243. xlog.Debug("aliRsp:", *aliRsp)
  244. }
  245. // 芝麻GO协议解约测试
  246. func TestZhimaCreditPeZmgoAgreementUnsign(t *testing.T) {
  247. // 请求参数
  248. bm := make(gopay.BodyMap)
  249. bm.Set("agreement_id", "ZMGO_AGR2020122710020604120000000001")
  250. bm.Set("partner_id", "2088302424614288")
  251. // 可选
  252. bm.Set("alipay_user_id", "2088302841345600")
  253. bm.Set("quit_type", "SETTLE_APPLY_QUIT")
  254. aliRsp, err := client.ZhimaCreditPeZmgoAgreementUnsign(ctx, bm)
  255. if err != nil {
  256. //xlog.Errorf("client.ZhimaCreditPeZmgoAgreementUnsign(%+v),error:%+v", bm, err)
  257. return
  258. }
  259. xlog.Debug("aliRsp:", *aliRsp)
  260. }
  261. // 芝麻Go协议查询接口测试
  262. func TestZhimaCreditPeZmgoAgreementQuery(t *testing.T) {
  263. // 请求参数
  264. bm := make(gopay.BodyMap)
  265. bm.Set("agreement_id", "20185513447859192007")
  266. bm.Set("alipay_user_id", "2088101117955611")
  267. aliRsp, err := client.ZhimaCreditPeZmgoAgreementQuery(ctx, bm)
  268. if err != nil {
  269. //xlog.Errorf("client.ZhimaCreditPeZmgoAgreementQuery(%+v),error:%+v", bm, err)
  270. return
  271. }
  272. xlog.Debug("aliRsp:", *aliRsp)
  273. }
  274. // 芝麻Go解冻接口测试
  275. func TestZhimaCreditPeZmgoSettleUnfreeze(t *testing.T) {
  276. // 请求参数
  277. bm := make(gopay.BodyMap)
  278. bm.Set("agreement_id", "20185513447859192007")
  279. bm.Set("out_request_no", "8077735255938032")
  280. bm.Set("unfreeze_amount", "3.00")
  281. bm.Set("biz_time", "2014-09-15 11:23:04")
  282. bm.Set("alipay_user_id", "2088101117955611")
  283. // 可选
  284. bm.Set("partner_id", "2088411663864410")
  285. bm.Set("order_title", "2088411663864410")
  286. bm.SetBodyMap("unfreeze_extend_params", func(bm gopay.BodyMap) {
  287. bm.Set("total_real_pay_amount", "3.00")
  288. bm.Set("total_discount_amount", "3.00")
  289. bm.Set("total_task_count", "0")
  290. bm.Set("quit_type", "SETTLE_APPLY_QUIT")
  291. })
  292. aliRsp, err := client.ZhimaCreditPeZmgoSettleUnfreeze(ctx, bm)
  293. if err != nil {
  294. //xlog.Errorf("client.ZhimaCreditPeZmgoSettleUnfreeze(%+v),error:%+v", bm, err)
  295. return
  296. }
  297. xlog.Debug("aliRsp:", *aliRsp)
  298. }
  299. // 芝麻GO支付下单链路签约申请测试
  300. func TestZhimaCreditPeZmgoPaysignApply(t *testing.T) {
  301. // 请求参数
  302. bm := make(gopay.BodyMap)
  303. bm.Set("alipay_user_id", "2088302841345600")
  304. bm.Set("partner_id", "2088302424614288")
  305. bm.Set("template_id", "2021012300020903090008858258")
  306. bm.Set("merchant_app_id", "2021001118641054")
  307. bm.Set("out_request_no", "99202005050100930053707258")
  308. bm.Set("biz_time", "2016-07-06 00:00:02")
  309. bm.Set("timeout_express", "1m")
  310. // 可选
  311. aliRsp, err := client.ZhimaCreditPeZmgoPaysignApply(ctx, bm)
  312. if err != nil {
  313. //xlog.Errorf("client.ZhimaCreditPeZmgoPaysignApply(%+v),error:%+v", bm, err)
  314. return
  315. }
  316. xlog.Debug("aliRsp:", *aliRsp)
  317. }
  318. // 芝麻GO支付下单链路签约确认测试
  319. func TestZhimaCreditPeZmgoPaysignConfirm(t *testing.T) {
  320. // 请求参数
  321. bm := make(gopay.BodyMap)
  322. bm.Set("alipay_user_id", "20195108518085620000")
  323. bm.Set("partner_id", "2088302424614288")
  324. bm.Set("merchant_app_id", "2021001118641054")
  325. bm.Set("zmgo_opt_no", "ZMGO_OPT2021040110020607570001198871")
  326. bm.Set("biz_type", "hongbaoqiandao")
  327. // 可选
  328. aliRsp, err := client.ZhimaCreditPeZmgoPaysignConfirm(ctx, bm)
  329. if err != nil {
  330. //xlog.Errorf("client.ZhimaCreditPeZmgoPaysignConfirm(%+v),error:%+v", bm, err)
  331. return
  332. }
  333. xlog.Debug("aliRsp:", *aliRsp)
  334. }
  335. // 职得工作证信息匹配度查询测试
  336. func TestZhimaCustomerJobworthAdapterQuery(t *testing.T) {
  337. // 请求参数
  338. bm := make(gopay.BodyMap)
  339. // 可选
  340. bm.Set("user_id", "2088302887413828")
  341. bm.Set("cert_no", "01011219900101XXXX")
  342. bm.Set("user_name", "张三")
  343. bm.Set("cert_type", "1")
  344. bm.Set("job_name", "java开发")
  345. bm.SetBodyMap("adapter", func(bm gopay.BodyMap) {
  346. bm.Set("edu_level", "BACHELOR")
  347. bm.Set("skill_certificate", "电工证")
  348. bm.Set("age", "18.35")
  349. bm.Set("gender", "男")
  350. bm.Set("city", "330100")
  351. bm.Set("recommend", "5")
  352. })
  353. aliRsp, err := client.ZhimaCustomerJobworthAdapterQuery(ctx, bm)
  354. if err != nil {
  355. //xlog.Errorf("client.ZhimaCustomerJobworthAdapterQuery(%+v),error:%+v", bm, err)
  356. return
  357. }
  358. xlog.Debug("aliRsp:", *aliRsp)
  359. }
  360. // 职得工作证外部渠道应用数据回流测试
  361. func TestZhimaCustomerJobworthSceneUse(t *testing.T) {
  362. // 请求参数
  363. bm := make(gopay.BodyMap)
  364. // 可选
  365. bm.Set("scene_type", "zhima_job_ext_exposure_info")
  366. bm.SetBodyMap("extra_info", func(bm gopay.BodyMap) {
  367. bm.Set("user_id", "2088302887413828")
  368. bm.Set("cert_no", "01011219900101XXXX")
  369. bm.Set("user_name", "张三")
  370. bm.Set("job_name", "java开发")
  371. bm.Set("job_id", "123456")
  372. bm.Set("scene_time", "1624278367975")
  373. bm.Set("job_category_id", "project")
  374. bm.Set("company_name", "58")
  375. bm.Set("company_id", "123456789")
  376. bm.Set("job_category", "技术")
  377. bm.Set("employer_visit", "true")
  378. bm.Set("self_visit", "true")
  379. })
  380. aliRsp, err := client.ZhimaCustomerJobworthSceneUse(ctx, bm)
  381. if err != nil {
  382. if errors.Is(err, gopay.UnmarshalErr) {
  383. //xlog.Errorf("%v", err)
  384. return
  385. }
  386. xlog.Errorf("client.ZhimaCustomerJobworthSceneUse(%+v),error:%+v", bm, err)
  387. return
  388. }
  389. xlog.Debug("aliRsp:", *aliRsp)
  390. }