wx_CloseOrder.go 756 B

12345678910111213141516171819202122232425262728293031
  1. package wechat
  2. import (
  3. "fmt"
  4. "github.com/iGoogle-ink/gopay"
  5. "github.com/iGoogle-ink/gopay/wechat"
  6. )
  7. func CloseOrder() {
  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", "MfZC2segKxh0bnJSELbvKNeH3d9oWvvQ")
  17. bm.Set("nonce_str", gopay.GetRandomString(32))
  18. bm.Set("sign_type", wechat.SignType_MD5)
  19. // 请求关闭订单,成功后得到结果
  20. wxRsp, err := client.CloseOrder(bm)
  21. if err != nil {
  22. fmt.Println("Error:", err)
  23. return
  24. }
  25. fmt.Println("wxRsp:", *wxRsp)
  26. }