forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment_method_nonce_integration_test.go
56 lines (43 loc) · 1.37 KB
/
payment_method_nonce_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
// +build integration
package braintree
import (
"context"
"testing"
)
func TestPaymentMethodNonce(t *testing.T) {
t.Parallel()
ctx := context.Background()
customer, err := testGateway.Customer().Create(ctx, &CustomerRequest{})
if err != nil {
t.Fatal(err)
}
paymentMethod, err := testGateway.PaymentMethod().Create(ctx, &PaymentMethodRequest{
CustomerId: customer.Id,
PaymentMethodNonce: FakeNonceTransactableVisa,
})
if err != nil {
t.Fatal(err)
}
t.Logf("%#v", paymentMethod)
paymentMethodNonce, err := testGateway.PaymentMethodNonce().Create(ctx, paymentMethod.GetToken())
if err != nil {
t.Fatal(err)
}
t.Logf("%#v", paymentMethodNonce)
t.Logf("%#v", paymentMethodNonce.Details)
if paymentMethodNonce.Type != "CreditCard" {
t.Errorf("nonce type got %q, want %q", paymentMethodNonce.Type, "CreditCard")
}
paymentMethodNonceFound, err := testGateway.PaymentMethodNonce().Find(ctx, paymentMethodNonce.Nonce)
if err != nil {
t.Fatal(err)
}
t.Logf("%#v", paymentMethodNonceFound)
t.Logf("%#v", paymentMethodNonceFound.Details)
if paymentMethodNonceFound.Type != "CreditCard" {
t.Errorf("found nonce type got %q, want %q", paymentMethodNonceFound.Type, "CreditCard")
}
if paymentMethodNonceFound.Nonce != paymentMethodNonce.Nonce {
t.Errorf("found nonce got %q, want %q", paymentMethodNonceFound.Nonce, paymentMethodNonce.Nonce)
}
}