2015-12-17 08:50:25 +01:00
|
|
|
package paypalsdk
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGetOrder(t *testing.T) {
|
2015-12-22 05:31:12 +01:00
|
|
|
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
|
2015-12-17 08:50:25 +01:00
|
|
|
c.GetAccessToken()
|
|
|
|
|
2015-12-22 05:31:12 +01:00
|
|
|
o, err := c.GetOrder(testOrderID)
|
|
|
|
if err != nil || o.ID != testOrderID {
|
|
|
|
t.Errorf("GetOrder failed for ID=" + testOrderID)
|
2015-12-17 08:50:25 +01:00
|
|
|
}
|
2015-12-22 06:09:57 +01:00
|
|
|
|
|
|
|
o, err = c.GetOrder(testFakeOrderID)
|
|
|
|
if err == nil {
|
|
|
|
t.Errorf("GetOrder must return error for ID=" + testFakeOrderID)
|
|
|
|
}
|
2015-12-17 08:50:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAuthorizeOrder(t *testing.T) {
|
2015-12-22 05:31:12 +01:00
|
|
|
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
|
2015-12-17 08:50:25 +01:00
|
|
|
c.GetAccessToken()
|
|
|
|
|
2015-12-22 05:31:12 +01:00
|
|
|
_, err := c.AuthorizeOrder(testOrderID, &Amount{Total: "7.00", Currency: "USD"})
|
2015-12-17 08:50:25 +01:00
|
|
|
if err == nil {
|
2015-12-22 05:31:12 +01:00
|
|
|
t.Errorf("Order is expired, 400 error must be returned")
|
2015-12-17 08:50:25 +01:00
|
|
|
} else {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCaptureOrder(t *testing.T) {
|
2015-12-22 05:31:12 +01:00
|
|
|
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
|
2015-12-17 08:50:25 +01:00
|
|
|
c.GetAccessToken()
|
|
|
|
|
2015-12-22 05:31:12 +01:00
|
|
|
_, err := c.CaptureOrder(testOrderID, &Amount{Total: "100", Currency: "USD"}, true, nil)
|
2015-12-17 08:50:25 +01:00
|
|
|
if err == nil {
|
2015-12-22 05:31:12 +01:00
|
|
|
t.Errorf("Order is expired, 400 error must be returned")
|
2015-12-17 08:50:25 +01:00
|
|
|
} else {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestVoidOrder(t *testing.T) {
|
2015-12-22 05:31:12 +01:00
|
|
|
c, _ := NewClient(testClientID, testSecret, APIBaseSandBox)
|
2015-12-17 08:50:25 +01:00
|
|
|
c.GetAccessToken()
|
|
|
|
|
2015-12-22 05:31:12 +01:00
|
|
|
_, err := c.VoidOrder(testOrderID)
|
2015-12-17 08:50:25 +01:00
|
|
|
if err == nil {
|
2015-12-22 05:31:12 +01:00
|
|
|
t.Errorf("Order is expired, 400 error must be returned")
|
2015-12-17 08:50:25 +01:00
|
|
|
} else {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
}
|
|
|
|
}
|