forked from BoltApp/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaypal_account_integration_test.go
80 lines (61 loc) · 1.44 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
72
73
74
75
76
77
78
79
80
// +build integration
package braintree
import (
"context"
"testing"
)
func TestPayPalAccount(t *testing.T) {
t.Parallel()
ctx := context.Background()
cust, err := testGateway.Customer().Create(ctx, &CustomerRequest{})
if err != nil {
t.Fatal(err)
}
nonce := FakeNoncePayPalBillingAgreement
g := testGateway.PayPalAccount()
paymentMethod, err := testGateway.PaymentMethod().Create(ctx, &PaymentMethodRequest{
CustomerId: cust.Id,
PaymentMethodNonce: nonce,
})
if err != nil {
t.Fatal(err)
}
// Find
paypalAccount, err := g.Find(ctx, paymentMethod.GetToken())
if err != nil {
t.Fatal(err)
}
t.Log(paypalAccount)
if paypalAccount.Token == "" {
t.Fatal("invalid token")
}
// Update
paypalAccount2, err := g.Update(ctx, &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(ctx, paypalAccount2)
if err != nil {
t.Fatal(err)
}
}
func TestFindPayPalAccountBadData(t *testing.T) {
t.Parallel()
ctx := context.Background()
paypalAccount, err := testGateway.PayPalAccount().Find(ctx, "invalid_token")
t.Log(paypalAccount)
if err == nil {
t.Fatal("expected to get error because the token is invalid")
}
}