-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction_test.go
39 lines (32 loc) · 923 Bytes
/
transaction_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
package stripego_test
import (
"encoding/json"
"os"
"strings"
"testing"
"github.com/pilinux/stripego"
"github.com/stripe/stripe-go/v74"
)
var BTxID string
func TestGetBalanceTx(t *testing.T) {
StripeSK = strings.TrimSpace(os.Getenv("STRIPE_SK"))
Currency = strings.TrimSpace(os.Getenv("CURRENCY"))
BTxID = strings.TrimSpace(os.Getenv("BALANCE_TRANSACTION_ID"))
txn, err := stripego.GetBalanceTx(StripeSK, BTxID)
if err != nil {
t.Errorf("got error when retrieving a transaction details: %v", err)
return
}
res := &stripe.BalanceTransaction{}
err = json.Unmarshal(txn.LastResponse.RawJSON, &res)
if err != nil {
t.Errorf("got error when unmarshalling transaction details: %v", err)
return
}
if res.ID != BTxID {
t.Errorf("balance transaction IDs do not match")
}
if res.Currency != stripe.Currency(Currency) {
t.Errorf("got: %v, want: %v", res.Currency, stripe.Currency(Currency))
}
}