client_test.go 882 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package qq
  2. import (
  3. "fmt"
  4. "os"
  5. "testing"
  6. "github.com/iGoogle-ink/gopay"
  7. )
  8. var (
  9. client *Client
  10. mchId = "1368139502"
  11. apiKey = "GFDS8j98rewnmgl45wHTt980jg543abc"
  12. )
  13. func TestMain(m *testing.M) {
  14. // 初始化QQ客户端
  15. // mchId:商户ID
  16. // apiKey:API秘钥值
  17. client = NewClient(mchId, apiKey)
  18. //err := client.AddCertFilePath(nil, nil, nil)
  19. //if err != nil {
  20. // panic(err)
  21. //}
  22. os.Exit(m.Run())
  23. }
  24. func TestClient_MicroPay(t *testing.T) {
  25. bm := make(gopay.BodyMap)
  26. bm.Set("nonce_str", gopay.GetRandomString(32))
  27. qqRsp, err := client.MicroPay(bm)
  28. if err != nil {
  29. fmt.Println("err:", err)
  30. return
  31. }
  32. fmt.Println("qqRsp:", *qqRsp)
  33. }
  34. func TestNotifyResponse_ToXmlString(t *testing.T) {
  35. n := new(NotifyResponse)
  36. n.ReturnCode = "SUCCESS"
  37. fmt.Println(n.ToXmlString())
  38. n.ReturnCode = "FAIL"
  39. n.ReturnMsg = "abc"
  40. fmt.Println(n.ToXmlString())
  41. }