-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipay_test.go
55 lines (48 loc) · 1.04 KB
/
ipay_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package ipay
import (
"encoding/json"
"fmt"
"os"
"testing"
)
func getAppId() string {
appid := os.Getenv("APPID")
if appid == "" {
panic("please set env var APPID")
}
return appid
}
func TestCreateOrder(t *testing.T) {
h, err := NewIpayHelperWithPem(getAppId(), "test_private_key.pem", "test_public_key.pem")
if err != nil {
t.Error(err)
}
transId, err := h.CreateIpayOrder(1, "打架=服务费", "A34544", 3.45, "10086", "123", "")
if err != nil {
t.Error(err)
return
}
payUrl, err := h.GetHtml5RedirectUrl(transId, "http://here", "")
if err != nil {
t.Error(err)
return
}
fmt.Printf("transid = %s\npayUrl = %s\n", transId, payUrl)
}
func prettyPrint(d interface{}) {
jb, _ := json.MarshalIndent(d, "", " ")
fmt.Println(string(jb))
}
func TestQueryResult(t *testing.T) {
h, err := NewIpayHelperWithPem(getAppId(), "test_private_key.pem", "test_public_key.pem")
if err != nil {
t.Error(err)
}
r, err := h.QueryResult("A34544")
if err != nil {
t.Error(err)
}
prettyPrint(r)
}
func TestParseNotifyInfo(t *testing.T) {
}