forked from plutov/paypal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_test.go
57 lines (47 loc) · 1.32 KB
/
order_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
56
57
package paypalsdk
import (
"fmt"
"testing"
)
func TestGetOrder(t *testing.T) {
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
c.GetAccessToken()
o, err := c.GetOrder(testOrderID)
if err != nil || o.ID != testOrderID {
t.Errorf("GetOrder failed for ID=" + testOrderID)
}
o, err = c.GetOrder(testFakeOrderID)
if err == nil {
t.Errorf("GetOrder must return error for ID=" + testFakeOrderID)
}
}
func TestAuthorizeOrder(t *testing.T) {
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
c.GetAccessToken()
_, err := c.AuthorizeOrder(testOrderID, &Amount{Total: "7.00", Currency: "USD"})
if err == nil {
t.Errorf("Order is expired, 400 error must be returned")
} else {
fmt.Println(err.Error())
}
}
func TestCaptureOrder(t *testing.T) {
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
c.GetAccessToken()
_, err := c.CaptureOrder(testOrderID, &Amount{Total: "100", Currency: "USD"}, true, nil)
if err == nil {
t.Errorf("Order is expired, 400 error must be returned")
} else {
fmt.Println(err.Error())
}
}
func TestVoidOrder(t *testing.T) {
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
c.GetAccessToken()
_, err := c.VoidOrder(testOrderID)
if err == nil {
t.Errorf("Order is expired, 400 error must be returned")
} else {
fmt.Println(err.Error())
}
}