wx_QueryRefund.go 952 B

1234567891011121314151617181920212223242526272829303132333435
  1. package wechat
  2. import (
  3. "fmt"
  4. "github.com/iGoogle-ink/gopay"
  5. "github.com/iGoogle-ink/gopay/wechat"
  6. )
  7. func QueryRefund() {
  8. //初始化微信客户端
  9. // appId:应用ID
  10. // MchID:商户ID
  11. // ApiKey:Key值
  12. // isProd:是否是正式环境
  13. client := wechat.NewClient("wxdaa2ab9ef87b5497", "1368139502", "GFDS8j98rewnmgl45wHTt980jg543abc", false)
  14. // 初始化参数结构体
  15. bm := make(gopay.BodyMap)
  16. bm.Set("out_trade_no", "97HiM5j6kGmM2fk7fYMc8MgKhPnEQ5Rk")
  17. //bm.Set("out_refund_no", "vk4264I1UQ3Hm3E4AKsavK8npylGSgQA092f9ckUxp8A2gXmnsLEdsupURVTcaC7")
  18. //bm.Set("transaction_id", "97HiM5j6kGmM2fk7fYMc8MgKhPnEQ5Rk")
  19. //bm.Set("refund_id", "97HiM5j6kGmM2fk7fYMc8MgKhPnEQ5Rk")
  20. bm.Set("nonce_str", gopay.GetRandomString(32))
  21. bm.Set("sign_type", wechat.SignType_MD5)
  22. //请求申请退款
  23. wxRsp, err := client.QueryRefund(bm)
  24. if err != nil {
  25. fmt.Println("Error:", err)
  26. return
  27. }
  28. fmt.Println("wxRsp:", *wxRsp)
  29. }