forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
transaction_android_pay_details_integration_test.go
158 lines (137 loc) · 4.48 KB
/
transaction_android_pay_details_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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// +build integration
package braintree
import (
"context"
"testing"
)
func TestTransactionAndroidPayDetails_AndroidPayProxyCardNonce(t *testing.T) {
ctx := context.Background()
tx, err := testGateway.Transaction().Create(ctx, &TransactionRequest{
Type: "sale",
Amount: NewDecimal(2000, 2),
PaymentMethodNonce: FakeNonceAndroidPayDiscover,
})
t.Log(tx)
if err != nil {
t.Fatal(err)
}
if tx.Id == "" {
t.Fatal("Received invalid ID on new transaction")
}
if tx.Status != TransactionStatusAuthorized {
t.Fatal(tx.Status)
}
if tx.AndroidPayDetails == nil {
t.Fatal("Expected AndroidPayDetails for transaction created with AndroidPay nonce")
}
t.Log(tx.AndroidPayDetails)
if tx.AndroidPayDetails.CardType == "" {
t.Fatal("Expected AndroidPayDetails to have CardType set")
}
if tx.AndroidPayDetails.Last4 == "" {
t.Fatal("Expected AndroidPayDetails to have Last4 set")
}
if tx.AndroidPayDetails.SourceCardType == "" {
t.Fatal("Expected AndroidPayDetails to have SourceCardType set")
}
if tx.AndroidPayDetails.SourceCardLast4 == "" {
t.Fatal("Expected AndroidPayDetails to have SourceCardLast4 set")
}
if tx.AndroidPayDetails.SourceDescription == "" {
t.Fatal("Expected AndroidPayDetails to have SourceDescription set")
}
if tx.AndroidPayDetails.VirtualCardType == "" {
t.Fatal("Expected AndroidPayDetails to have VirtualCardType set")
}
if tx.AndroidPayDetails.VirtualCardLast4 == "" {
t.Fatal("Expected AndroidPayDetails to have VirtualCardLast4 set")
}
if tx.AndroidPayDetails.ExpirationMonth == "" {
t.Fatal("Expected AndroidPayDetails to have ExpirationMonth set")
}
if tx.AndroidPayDetails.ExpirationYear == "" {
t.Fatal("Expected AndroidPayDetails to have ExpirationYear set")
}
if tx.AndroidPayDetails.GoogleTransactionID == "" {
t.Fatal("Expected AndroidPayDetails to have GoogleTransactionID set")
}
if tx.AndroidPayDetails.BIN == "" {
t.Fatal("Expected AndroidPayDetails to have BIN set")
}
}
func TestTransactionAndroidPayDetails_AndroidPayNetworkTokenNonce(t *testing.T) {
ctx := context.Background()
tx, err := testGateway.Transaction().Create(ctx, &TransactionRequest{
Type: "sale",
Amount: NewDecimal(2000, 2),
PaymentMethodNonce: FakeNonceAndroidPayMasterCard,
})
t.Log(tx)
if err != nil {
t.Fatal(err)
}
if tx.Id == "" {
t.Fatal("Received invalid ID on new transaction")
}
if tx.Status != TransactionStatusAuthorized {
t.Fatal(tx.Status)
}
if tx.AndroidPayDetails == nil {
t.Fatal("Expected AndroidPayDetails for transaction created with AndroidPay nonce")
}
t.Log(tx.AndroidPayDetails)
if tx.AndroidPayDetails.CardType == "" {
t.Fatal("Expected AndroidPayDetails to have CardType set")
}
if tx.AndroidPayDetails.Last4 == "" {
t.Fatal("Expected AndroidPayDetails to have Last4 set")
}
if tx.AndroidPayDetails.SourceCardType == "" {
t.Fatal("Expected AndroidPayDetails to have SourceCardType set")
}
if tx.AndroidPayDetails.SourceCardLast4 == "" {
t.Fatal("Expected AndroidPayDetails to have SourceCardLast4 set")
}
if tx.AndroidPayDetails.SourceDescription == "" {
t.Fatal("Expected AndroidPayDetails to have SourceDescription set")
}
if tx.AndroidPayDetails.VirtualCardType == "" {
t.Fatal("Expected AndroidPayDetails to have VirtualCardType set")
}
if tx.AndroidPayDetails.VirtualCardLast4 == "" {
t.Fatal("Expected AndroidPayDetails to have VirtualCardLast4 set")
}
if tx.AndroidPayDetails.ExpirationMonth == "" {
t.Fatal("Expected AndroidPayDetails to have ExpirationMonth set")
}
if tx.AndroidPayDetails.ExpirationYear == "" {
t.Fatal("Expected AndroidPayDetails to have ExpirationYear set")
}
if tx.AndroidPayDetails.GoogleTransactionID == "" {
t.Fatal("Expected AndroidPayDetails to have GoogleTransactionID set")
}
if tx.AndroidPayDetails.BIN == "" {
t.Fatal("Expected AndroidPayDetails to have BIN set")
}
}
func TestTransactionWithoutAndroidPayDetails(t *testing.T) {
ctx := context.Background()
tx, err := testGateway.Transaction().Create(ctx, &TransactionRequest{
Type: "sale",
Amount: NewDecimal(2000, 2),
PaymentMethodNonce: FakeNonceTransactable,
})
t.Log(tx)
if err != nil {
t.Fatal(err)
}
if tx.Id == "" {
t.Fatal("Received invalid ID on new transaction")
}
if tx.Status != TransactionStatusAuthorized {
t.Fatal(tx.Status)
}
if tx.AndroidPayDetails != nil {
t.Fatalf("Expected AndroidPayDetails to be nil for transaction created without AndroidPay, but was %#v", tx.AndroidPayDetails)
}
}