forked from braintree-go/braintree-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
merchant_account_integration_test.go
105 lines (82 loc) · 2.04 KB
/
merchant_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
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
// +build integration
package braintree
import (
"context"
"encoding/xml"
"testing"
"github.com/lionelbarrow/braintree-go/testhelpers"
)
var acctId string
func TestMerchantAccountCreate(t *testing.T) {
t.Parallel()
ctx := context.Background()
acctId = testhelpers.RandomString()
acct := MerchantAccount{
MasterMerchantAccountId: testMerchantAccountId,
TOSAccepted: true,
Id: acctId,
Individual: &MerchantAccountPerson{
FirstName: "Kayle",
LastName: "Gishen",
Email: "[email protected]",
Phone: "5556789012",
DateOfBirth: "1-1-1989",
Address: &Address{
StreetAddress: "1 E Main St",
ExtendedAddress: "Suite 404",
Locality: "Chicago",
Region: "IL",
PostalCode: "60622",
},
},
FundingOptions: &MerchantAccountFundingOptions{
Destination: FUNDING_DEST_MOBILE_PHONE,
MobilePhone: "5552344567",
},
}
x, _ := xml.Marshal(&acct)
t.Log(string(x))
merchantAccount, err := testGateway.MerchantAccount().Create(ctx, &acct)
t.Log(merchantAccount)
if err != nil {
t.Fatal(err)
}
if merchantAccount.Id == "" {
t.Fatal("invalid merchant account id")
}
ma2, err := testGateway.MerchantAccount().Find(ctx, merchantAccount.Id)
t.Log(ma2)
if err != nil {
t.Fatal(err)
}
if ma2.Id != merchantAccount.Id {
t.Fatal("ids do not match")
}
}
func TestMerchantAccountTransaction(t *testing.T) {
ctx := context.Background()
if acctId == "" {
TestMerchantAccountCreate(t)
}
amount := NewDecimal(int64(randomAmount().Scale+500), 2)
tx, err := testGateway.Transaction().Create(ctx, &TransactionRequest{
Type: "sale",
Amount: amount,
CreditCard: &CreditCard{
Number: testCreditCards["visa"].Number,
ExpirationDate: "05/14",
},
ServiceFeeAmount: NewDecimal(500, 2),
MerchantAccountId: acctId,
})
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)
}
}