forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaypal_account_integration_test.go
71 lines (55 loc) · 1.31 KB
/
paypal_account_integration_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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package braintree
import "testing"
func TestPayPalAccount(t *testing.T) {
t.Parallel()
cust, err := testGateway.Customer().Create(&Customer{})
if err != nil {
t.Fatal(err)
}
nonce := FakeNoncePayPalBillingAgreement
g := testGateway.PayPalAccount()
paymentMethod, err := testGateway.PaymentMethod().Create(&PaymentMethodRequest{
CustomerId: cust.Id,
PaymentMethodNonce: nonce,
})
if err != nil {
t.Fatal(err)
}
// Find
paypalAccount, err := g.Find(paymentMethod.GetToken())
if err != nil {
t.Fatal(err)
}
t.Log(paypalAccount)
if paypalAccount.Token == "" {
t.Fatal("invalid token")
}
// Update
paypalAccount2, err := g.Update(&PayPalAccount{
Token: paypalAccount.Token,
Email: "[email protected]",
})
if err != nil {
t.Fatal(err)
}
t.Log(paypalAccount2)
if paypalAccount2.Token != paypalAccount.Token {
t.Fatal("tokens do not match")
}
if paypalAccount2.Email != "[email protected]" {
t.Fatal("paypalAccount email does not match")
}
// Delete
err = g.Delete(paypalAccount2)
if err != nil {
t.Fatal(err)
}
}
func TestFindPayPalAccountBadData(t *testing.T) {
t.Parallel()
paypalAccount, err := testGateway.PayPalAccount().Find("invalid_token")
t.Log(paypalAccount)
if err == nil {
t.Fatal("expected to get error because the token is invalid")
}
}