client_test.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. package wechat
  2. import (
  3. "fmt"
  4. "os"
  5. "strconv"
  6. "testing"
  7. "time"
  8. "github.com/iGoogle-ink/gopay"
  9. )
  10. var (
  11. client *Client
  12. appId = "wxdaa2ab9ef87b5497"
  13. mchId = "1368139502"
  14. apiKey = "GFDS8j98rewnmgl45wHTt980jg543abc"
  15. )
  16. func TestMain(m *testing.M) {
  17. // 初始化微信客户端
  18. // appId:应用ID
  19. // mchId:商户ID
  20. // apiKey:API秘钥值
  21. // isProd:是否是正式环境
  22. client = NewClient(appId, mchId, apiKey, false)
  23. // 设置国家,不设置默认就是 China
  24. client.SetCountry(China)
  25. //err := client.AddCertFilePath(nil, nil, nil)
  26. //if err != nil {
  27. // panic(err)
  28. //}
  29. os.Exit(m.Run())
  30. }
  31. func TestClient_UnifiedOrder(t *testing.T) {
  32. number := gopay.GetRandomString(32)
  33. fmt.Println("out_trade_no:", number)
  34. // 初始化参数Map
  35. bm := make(gopay.BodyMap)
  36. bm.Set("nonce_str", gopay.GetRandomString(32))
  37. bm.Set("body", "H5支付")
  38. bm.Set("out_trade_no", number)
  39. bm.Set("total_fee", 1)
  40. bm.Set("spbill_create_ip", "127.0.0.1")
  41. bm.Set("notify_url", "http://www.gopay.ink")
  42. bm.Set("trade_type", TradeType_H5)
  43. bm.Set("device_info", "WEB")
  44. bm.Set("sign_type", SignType_MD5)
  45. sceneInfo := make(map[string]map[string]string)
  46. h5Info := make(map[string]string)
  47. h5Info["type"] = "Wap"
  48. h5Info["wap_url"] = "http://www.gopay.ink"
  49. h5Info["wap_name"] = "H5测试支付"
  50. sceneInfo["h5_info"] = h5Info
  51. bm.Set("scene_info", sceneInfo)
  52. //bm.Set("openid", "o0Df70H2Q0fY8JXh1aFPIRyOBgu8")
  53. // 正式
  54. //sign := gopay.GetWeChatParamSign("wxdaa2ab9ef87b5497", "1368139502", "GFDS8j98rewnmgl45wHTt980jg543abc", body)
  55. // 沙箱
  56. //sign, _ := gopay.GetWeChatSanBoxParamSign("wxdaa2ab9ef87b5497", "1368139502", "GFDS8j98rewnmgl45wHTt980jg543abc", body)
  57. //body.Set("sign", sign)
  58. // 请求支付下单,成功后得到结果
  59. wxRsp, err := client.UnifiedOrder(bm)
  60. if err != nil {
  61. fmt.Println("Error:", err)
  62. return
  63. }
  64. fmt.Println("wxRsp:", *wxRsp)
  65. //fmt.Println("wxRsp.MwebUrl:", wxRsp.MwebUrl)
  66. timeStamp := strconv.FormatInt(time.Now().Unix(), 10)
  67. // 获取小程序支付需要的paySign
  68. //pac := "prepay_id=" + wxRsp.PrepayId
  69. //paySign := GetMiniPaySign(appId, wxRsp.NonceStr, pac, SignType_MD5, timeStamp, apiKey)
  70. //fmt.Println("paySign:", paySign)
  71. // 获取H5支付需要的paySign
  72. pac := "prepay_id=" + wxRsp.PrepayId
  73. paySign := GetH5PaySign(appId, wxRsp.NonceStr, pac, SignType_MD5, timeStamp, apiKey)
  74. fmt.Println("paySign:", paySign)
  75. // 获取小程序需要的paySign
  76. //paySign := GetAppPaySign(appId,"partnerid", wxRsp.NonceStr, wxRsp.PrepayId, SignType_MD5, timeStamp, apiKey)
  77. //fmt.Println("paySign:", paySign)
  78. }
  79. func TestClient_QueryOrder(t *testing.T) {
  80. // 初始化参数结构体
  81. bm := make(gopay.BodyMap)
  82. bm.Set("out_trade_no", "MfZC2segKxh0bnJSELbvKNeH3d9oWvvQ")
  83. bm.Set("nonce_str", gopay.GetRandomString(32))
  84. bm.Set("sign_type", SignType_MD5)
  85. // 请求订单查询,成功后得到结果
  86. wxRsp, err := client.QueryOrder(bm)
  87. if err != nil {
  88. fmt.Println("Error:", err)
  89. return
  90. }
  91. fmt.Println("wxRsp:", *wxRsp)
  92. }
  93. func TestClient_CloseOrder(t *testing.T) {
  94. // 初始化参数结构体
  95. bm := make(gopay.BodyMap)
  96. bm.Set("out_trade_no", "MfZC2segKxh0bnJSELbvKNeH3d9oWvvQ")
  97. bm.Set("nonce_str", gopay.GetRandomString(32))
  98. bm.Set("sign_type", SignType_MD5)
  99. // 请求关闭订单,成功后得到结果
  100. wxRsp, err := client.CloseOrder(bm)
  101. if err != nil {
  102. fmt.Println("Error:", err)
  103. return
  104. }
  105. fmt.Println("wxRsp:", *wxRsp)
  106. }
  107. func TestClient_Micropay(t *testing.T) {
  108. number := gopay.GetRandomString(32)
  109. fmt.Println("out_trade_no:", number)
  110. // 初始化参数Map
  111. bm := make(gopay.BodyMap)
  112. bm.Set("nonce_str", gopay.GetRandomString(32))
  113. bm.Set("body", "扫用户付款码支付")
  114. bm.Set("out_trade_no", number)
  115. bm.Set("total_fee", 1)
  116. bm.Set("spbill_create_ip", "127.0.0.1")
  117. bm.Set("auth_code", "134622817080551492")
  118. bm.Set("sign_type", SignType_MD5)
  119. // 请求支付,成功后得到结果
  120. wxRsp, err := client.Micropay(bm)
  121. if err != nil {
  122. fmt.Println("Error:", err)
  123. return
  124. }
  125. fmt.Println("Response:", *wxRsp)
  126. ok, err := VerifySign(apiKey, SignType_MD5, wxRsp)
  127. if err != nil {
  128. fmt.Println("err:", err)
  129. }
  130. fmt.Println("同步验签结果:", ok) // 沙箱环境验签失败请用正式环境测
  131. }
  132. func TestClient_AuthCodeToOpenId(t *testing.T) {
  133. // 初始化参数Map
  134. bm := make(gopay.BodyMap)
  135. bm.Set("nonce_str", gopay.GetRandomString(32))
  136. bm.Set("auth_code", "134753997737645794")
  137. wxRsp, err := client.AuthCodeToOpenId(bm)
  138. if err != nil {
  139. fmt.Println("Error:", err)
  140. return
  141. }
  142. fmt.Println("Response:", *wxRsp)
  143. }
  144. func TestClient_Refund(t *testing.T) {
  145. // 初始化参数结构体
  146. bm := make(gopay.BodyMap)
  147. bm.Set("out_trade_no", "QRcTBTbJLoDrWSW9FtpSFlgWhft2QbaY")
  148. bm.Set("nonce_str", gopay.GetRandomString(32))
  149. bm.Set("sign_type", SignType_MD5)
  150. s := gopay.GetRandomString(64)
  151. fmt.Println("out_refund_no:", s)
  152. bm.Set("out_refund_no", s)
  153. bm.Set("total_fee", 101)
  154. bm.Set("refund_fee", 101)
  155. bm.Set("notify_url", "https://www.gopay.ink")
  156. // 请求申请退款(沙箱环境下,证书路径参数可传空)
  157. // body:参数Body
  158. // certFilePath:cert证书路径
  159. // keyFilePath:Key证书路径
  160. // pkcs12FilePath:p12证书路径
  161. wxRsp, err := client.Refund(bm, nil, nil, nil)
  162. if err != nil {
  163. fmt.Println("Error:", err)
  164. return
  165. }
  166. fmt.Println("wxRsp:", *wxRsp)
  167. }
  168. func TestClient_QueryRefund(t *testing.T) {
  169. // 初始化参数结构体
  170. bm := make(gopay.BodyMap)
  171. bm.Set("out_trade_no", "97HiM5j6kGmM2fk7fYMc8MgKhPnEQ5Rk")
  172. //bm.Set("out_refund_no", "vk4264I1UQ3Hm3E4AKsavK8npylGSgQA092f9ckUxp8A2gXmnsLEdsupURVTcaC7")
  173. //bm.Set("transaction_id", "97HiM5j6kGmM2fk7fYMc8MgKhPnEQ5Rk")
  174. //bm.Set("refund_id", "97HiM5j6kGmM2fk7fYMc8MgKhPnEQ5Rk")
  175. bm.Set("nonce_str", gopay.GetRandomString(32))
  176. bm.Set("sign_type", SignType_MD5)
  177. // 请求申请退款
  178. wxRsp, err := client.QueryRefund(bm)
  179. if err != nil {
  180. fmt.Println("Error:", err)
  181. return
  182. }
  183. fmt.Println("wxRsp:", *wxRsp)
  184. }
  185. func TestClient_Reverse(t *testing.T) {
  186. // 初始化参数Map
  187. bm := make(gopay.BodyMap)
  188. bm.Set("nonce_str", gopay.GetRandomString(32))
  189. bm.Set("out_trade_no", "6aDCor1nUcAihrV5JBlI09tLvXbUp02B")
  190. bm.Set("sign_type", SignType_MD5)
  191. // 请求撤销订单,成功后得到结果,沙箱环境下,证书路径参数可传nil
  192. wxRsp, err := client.Reverse(bm, nil, nil, nil)
  193. if err != nil {
  194. fmt.Println("Error:", err)
  195. return
  196. }
  197. fmt.Println("Response:", wxRsp)
  198. }
  199. func TestClient_Transfer(t *testing.T) {
  200. // 初始化参数结构体
  201. bm := make(gopay.BodyMap)
  202. bm.Set("nonce_str", gopay.GetRandomString(32))
  203. bm.Set("partner_trade_no", gopay.GetRandomString(32))
  204. bm.Set("openid", "o0Df70H2Q0fY8JXh1aFPIRyOBgu8")
  205. bm.Set("check_name", "FORCE_CHECK") // NO_CHECK:不校验真实姓名 , FORCE_CHECK:强校验真实姓名
  206. bm.Set("re_user_name", "付明明") // 收款用户真实姓名。 如果check_name设置为FORCE_CHECK,则必填用户真实姓名
  207. bm.Set("amount", 30) // 企业付款金额,单位为分
  208. bm.Set("desc", "测试转账") // 企业付款备注,必填。注意:备注中的敏感词会被转成字符*
  209. bm.Set("spbill_create_ip", "127.0.0.1")
  210. // 企业向微信用户个人付款(不支持沙箱环境)
  211. // body:参数Body
  212. // certFilePath:cert证书路径
  213. // keyFilePath:Key证书路径
  214. // pkcs12FilePath:p12证书路径
  215. wxRsp, err := client.Transfer(bm, nil, nil, nil)
  216. if err != nil {
  217. fmt.Println("Error:", err)
  218. return
  219. }
  220. fmt.Println("wxRsp:", *wxRsp)
  221. }
  222. func TestClient_DownloadBill(t *testing.T) {
  223. // 初始化参数结构体
  224. bm := make(gopay.BodyMap)
  225. bm.Set("nonce_str", gopay.GetRandomString(32))
  226. bm.Set("sign_type", SignType_MD5)
  227. bm.Set("bill_date", "20190722")
  228. bm.Set("bill_type", "ALL")
  229. // 请求下载对账单,成功后得到结果(string类型字符串)
  230. wxRsp, err := client.DownloadBill(bm)
  231. if err != nil {
  232. fmt.Println("Error:", err)
  233. return
  234. }
  235. fmt.Println("wxRsp:", wxRsp)
  236. }
  237. func TestClient_DownloadFundFlow(t *testing.T) {
  238. // 初始化参数结构体
  239. bm := make(gopay.BodyMap)
  240. bm.Set("nonce_str", gopay.GetRandomString(32))
  241. bm.Set("sign_type", SignType_HMAC_SHA256)
  242. bm.Set("bill_date", "20190122")
  243. bm.Set("account_type", "Basic")
  244. // 请求下载资金账单,成功后得到结果,沙箱环境下,证书路径参数可传nil
  245. wxRsp, err := client.DownloadFundFlow(bm, nil, nil, nil)
  246. if err != nil {
  247. fmt.Println("Error:", err)
  248. return
  249. }
  250. fmt.Println("wxRsp:", wxRsp)
  251. }
  252. func TestClient_BatchQueryComment(t *testing.T) {
  253. // 初始化参数结构体
  254. bm := make(gopay.BodyMap)
  255. bm.Set("nonce_str", gopay.GetRandomString(32))
  256. bm.Set("sign_type", SignType_HMAC_SHA256)
  257. bm.Set("begin_time", "20190120000000")
  258. bm.Set("end_time", "20190122174000")
  259. bm.Set("offset", "0")
  260. // 请求拉取订单评价数据,成功后得到结果,沙箱环境下,证书路径参数可传nil
  261. wxRsp, err := client.BatchQueryComment(bm, nil, nil, nil)
  262. if err != nil {
  263. fmt.Println("Error:", err)
  264. return
  265. }
  266. fmt.Println("wxRsp:", wxRsp)
  267. }
  268. func TestClient_EntrustPublic(t *testing.T) {
  269. // 初始化参数结构体
  270. bm := make(gopay.BodyMap)
  271. bm.Set("plan_id", "12535")
  272. bm.Set("contract_code", "100000")
  273. bm.Set("request_serial", "1000")
  274. bm.Set("contract_display_account", "微信代扣")
  275. bm.Set("notify_url", "https://www.igoogle.ink")
  276. bm.Set("version", "1.0")
  277. bm.Set("timestamp", time.Now().Unix())
  278. // 公众号纯签约
  279. wxRsp, err := client.EntrustPublic(bm)
  280. if err != nil {
  281. fmt.Println("Error:", err)
  282. return
  283. }
  284. fmt.Println("wxRsp:", wxRsp)
  285. }
  286. func TestClient_EntrustAppPre(t *testing.T) {
  287. // 初始化参数结构体
  288. bm := make(gopay.BodyMap)
  289. bm.Set("plan_id", "12535")
  290. bm.Set("contract_code", "100000")
  291. bm.Set("request_serial", "1000")
  292. bm.Set("contract_display_account", "微信代扣")
  293. bm.Set("notify_url", "https://www.igoogle.ink")
  294. bm.Set("version", "1.0")
  295. bm.Set("timestamp", time.Now().Unix())
  296. // APP纯签约
  297. wxRsp, err := client.EntrustAppPre(bm)
  298. if err != nil {
  299. fmt.Println("Error:", err)
  300. return
  301. }
  302. fmt.Println("wxRsp:", wxRsp)
  303. }
  304. func TestClient_EntrustH5(t *testing.T) {
  305. // 初始化参数结构体
  306. bm := make(gopay.BodyMap)
  307. bm.Set("plan_id", "12535")
  308. bm.Set("contract_code", "100000")
  309. bm.Set("request_serial", "1000")
  310. bm.Set("contract_display_account", "微信代扣")
  311. bm.Set("notify_url", "https://www.igoogle.ink")
  312. bm.Set("version", "1.0")
  313. bm.Set("timestamp", time.Now().Unix())
  314. bm.Set("clientip", "127.0.0.1")
  315. // H5纯签约
  316. wxRsp, err := client.EntrustH5(bm)
  317. if err != nil {
  318. fmt.Println("Error:", err)
  319. return
  320. }
  321. fmt.Println("wxRsp:", wxRsp)
  322. }
  323. func TestClient_EntrustPaying(t *testing.T) {
  324. number := gopay.GetRandomString(32)
  325. fmt.Println("out_trade_no:", number)
  326. // 初始化参数结构体
  327. bm := make(gopay.BodyMap)
  328. bm.Set("contract_mchid", mchId)
  329. bm.Set("contract_appid", appId)
  330. bm.Set("out_trade_no", number)
  331. bm.Set("nonce_str", gopay.GetRandomString(32))
  332. bm.Set("body", "测试签约")
  333. bm.Set("total_fee", 1)
  334. bm.Set("spbill_create_ip", "127.0.0.1")
  335. bm.Set("trade_type", TradeType_App)
  336. bm.Set("plan_id", "12535")
  337. bm.Set("contract_code", "100000")
  338. bm.Set("request_serial", "1000")
  339. bm.Set("contract_display_account", "微信代扣")
  340. bm.Set("notify_url", "https://www.igoogle.ink")
  341. bm.Set("contract_notify_url", "https://www.igoogle.ink")
  342. //bm.Set("openid", "o0Df70H2Q0fY8JXh1aFPIRyOBgu8")
  343. // 支付中签约
  344. wxRsp, err := client.EntrustPaying(bm)
  345. if err != nil {
  346. fmt.Println("Error:", err)
  347. return
  348. }
  349. fmt.Println("wxRsp:", wxRsp)
  350. }
  351. // =======================
  352. func TestDecryptOpenDataToStruct(t *testing.T) {
  353. data := "Kf3TdPbzEmhWMuPKtlKxIWDkijhn402w1bxoHL4kLdcKr6jT1jNcIhvDJfjXmJcgDWLjmBiIGJ5acUuSvxLws3WgAkERmtTuiCG10CKLsJiR+AXVk7B2TUQzsq88YVilDz/YAN3647REE7glGmeBPfvUmdbfDzhL9BzvEiuRhABuCYyTMz4iaM8hFjbLB1caaeoOlykYAFMWC5pZi9P8uw=="
  354. iv := "Cds8j3VYoGvnTp1BrjXdJg=="
  355. session := "lyY4HPQbaOYzZdG+JcYK9w=="
  356. phone := new(UserPhone)
  357. //解密开放数据
  358. // encryptedData:包括敏感数据在内的完整用户信息的加密数据
  359. // iv:加密算法的初始向量
  360. // sessionKey:会话密钥
  361. // beanPtr:需要解析到的结构体指针
  362. err := DecryptOpenDataToStruct(data, iv, session, phone)
  363. if err != nil {
  364. fmt.Println("err:", err)
  365. return
  366. }
  367. fmt.Println("PhoneNumber:", phone.PhoneNumber)
  368. fmt.Println("PurePhoneNumber:", phone.PurePhoneNumber)
  369. fmt.Println("CountryCode:", phone.CountryCode)
  370. fmt.Println("Watermark:", phone.Watermark)
  371. sessionKey := "tiihtNczf5v6AKRyjwEUhQ=="
  372. encryptedData := "CiyLU1Aw2KjvrjMdj8YKliAjtP4gsMZMQmRzooG2xrDcvSnxIMXFufNstNGTyaGS9uT5geRa0W4oTOb1WT7fJlAC+oNPdbB+3hVbJSRgv+4lGOETKUQz6OYStslQ142dNCuabNPGBzlooOmB231qMM85d2/fV6ChevvXvQP8Hkue1poOFtnEtpyxVLW1zAo6/1Xx1COxFvrc2d7UL/lmHInNlxuacJXwu0fjpXfz/YqYzBIBzD6WUfTIF9GRHpOn/Hz7saL8xz+W//FRAUid1OksQaQx4CMs8LOddcQhULW4ucetDf96JcR3g0gfRK4PC7E/r7Z6xNrXd2UIeorGj5Ef7b1pJAYB6Y5anaHqZ9J6nKEBvB4DnNLIVWSgARns/8wR2SiRS7MNACwTyrGvt9ts8p12PKFdlqYTopNHR1Vf7XjfhQlVsAJdNiKdYmYVoKlaRv85IfVunYzO0IKXsyl7JCUjCpoG20f0a04COwfneQAGGwd5oa+T8yO5hzuyDb/XcxxmK01EpqOyuxINew=="
  373. iv2 := "r7BXXKkLb8qrSNn05n0qiA=="
  374. //微信小程序 用户信息
  375. userInfo := new(AppletUserInfo)
  376. err = DecryptOpenDataToStruct(encryptedData, iv2, sessionKey, userInfo)
  377. if err != nil {
  378. fmt.Println("err:", err)
  379. return
  380. }
  381. fmt.Println("NickName:", userInfo.NickName)
  382. fmt.Println("AvatarUrl:", userInfo.AvatarUrl)
  383. fmt.Println("Country:", userInfo.Country)
  384. fmt.Println("Province:", userInfo.Province)
  385. fmt.Println("City:", userInfo.City)
  386. fmt.Println("Gender:", userInfo.Gender)
  387. fmt.Println("OpenId:", userInfo.OpenId)
  388. fmt.Println("UnionId:", userInfo.UnionId)
  389. fmt.Println("Watermark:", userInfo.Watermark)
  390. }
  391. func TestDecryptOpenDataToBodyMap(t *testing.T) {
  392. data := "Kf3TdPbzEmhWMuPKtlKxIWDkijhn402w1bxoHL4kLdcKr6jT1jNcIhvDJfjXmJcgDWLjmBiIGJ5acUuSvxLws3WgAkERmtTuiCG10CKLsJiR+AXVk7B2TUQzsq88YVilDz/YAN3647REE7glGmeBPfvUmdbfDzhL9BzvEiuRhABuCYyTMz4iaM8hFjbLB1caaeoOlykYAFMWC5pZi9P8uw=="
  393. iv := "Cds8j3VYoGvnTp1BrjXdJg=="
  394. session := "lyY4HPQbaOYzZdG+JcYK9w=="
  395. //解密开放数据
  396. // encryptedData:包括敏感数据在内的完整用户信息的加密数据
  397. // iv:加密算法的初始向量
  398. // sessionKey:会话密钥
  399. bm, err := DecryptOpenDataToBodyMap(data, iv, session)
  400. if err != nil {
  401. fmt.Println("err:", err)
  402. return
  403. }
  404. fmt.Println("WeChatUserPhone:", bm)
  405. }
  406. func TestDecryptRefundNotifyReqInfo(t *testing.T) {
  407. key := "ziR0QKsTUfMOuochC9RfCdmfHECorQAP"
  408. data := "YYwp8C48th0wnQzTqeI+41pflB26v+smFj9z6h9RPBgxTyZyxc+4YNEz7QEgZNWj/6rIb2MfyWMZmCc41CfjKSssoSZPXxOhUayb6KvNSZ1p6frOX1PDWzhyruXK7ouNND+gDsG4yZ0XXzsL4/pYNwLLba/71QrnkJ/BHcByk4EXnglju5DLup9pJQSnTxjomI9Rxu57m9jg5lLQFxMWXyeASZJNvof0ulnHlWJswS4OxKOkmW7VEyKyLGV6npoOm03Qsx2wkRxLsSa9gPpg4hdaReeUqh1FMbm7aWjyrVYT/MEZWg98p4GomEIYvz34XfDncTezX4bf/ZiSLXt79aE1/YTZrYfymXeCrGjlbe0rg/T2ezJHAC870u2vsVbY1/KcE2A443N+DEnAziXlBQ1AeWq3Rqk/O6/TMM0lomzgctAOiAMg+bh5+Gu1ubA9O3E+vehULydD5qx2o6i3+qA9ORbH415NyRrQdeFq5vmCiRikp5xYptWiGZA0tkoaLKMPQ4ndE5gWHqiBbGPfULZWokI+QjjhhBmwgbd6J0VqpRorwOuzC/BHdkP72DCdNcm7IDUpggnzBIy0+seWIkcHEryKjge3YDHpJeQCqrAH0CgxXHDt1xtbQbST1VqFyuhPhUjDXMXrknrGPN/oE1t0rLRq+78cI+k8xe5E6seeUXQsEe8r3358mpcDYSmXWSXVZxK6er9EF98APqHwcndyEJD2YyCh/mMVhERuX+7kjlRXSiNUWa/Cv/XAKFQuvUYA5ea2eYWtPRHa4DpyuF1SNsaqVKfgqKXZrJHfAgslVpSVqUpX4zkKszHF4kwMZO3M7J1P94Mxa7Tm9mTOJePOoHPXeEB+m9rX6pSfoi3mJDQ5inJ+Vc4gOkg/Wd/lqiy6TTyP/dHDN6/v+AuJx5AXBo/2NDD3fWhHjkqEKIuARr2ClZt9ZRQO4HkXdZo7CN06sGCHk48Tg8PmxnxKcMZm7Aoquv5yMIM2gWSWIRJhwJ8cUpafIHc+GesDlbF6Zbt+/KXkafJAQq2RklEN+WvZ/zFz113EPgWPjp16TwBoziq96MMekvWKY/vdhjol8VFtGH9F61Oy1Xwf6DJtPw=="
  409. refundNotify, err := DecryptRefundNotifyReqInfo(data, key)
  410. if err != nil {
  411. fmt.Println("err:", err)
  412. return
  413. }
  414. fmt.Println("refundNotify:", *refundNotify)
  415. }
  416. func TestGetAppletAccessToken(t *testing.T) {
  417. token, err := GetAppletAccessToken("wxdaa2ab9ef87b5497", "AppSecret")
  418. if err != nil {
  419. fmt.Println(err)
  420. return
  421. }
  422. fmt.Println("token:", token)
  423. }
  424. func TestCode2Session(t *testing.T) {
  425. session, err := Code2Session("wx2e92b2ff5ed4db71", "AppSecret", "081XxRPj1e8Krp0uGUQj1s0MPj1XxRP5")
  426. if err != nil {
  427. return
  428. }
  429. fmt.Println("Openid:", session.Openid)
  430. }