-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransfer_test.go
62 lines (52 loc) · 1.53 KB
/
transfer_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
package stripego_test
import (
"encoding/json"
"os"
"strings"
"testing"
"github.com/pilinux/stripego"
"github.com/stripe/stripe-go/v74"
)
var Destination string
var TransferObject string
var TransferAmount int64
func TestTransferBalance(t *testing.T) {
StripeSK = strings.TrimSpace(os.Getenv("STRIPE_SK"))
Currency = strings.TrimSpace(os.Getenv("CURRENCY"))
Destination = strings.TrimSpace(os.Getenv("DESTINATION"))
TransferObject = "transfer"
TransferAmount = 1
tp := &stripe.TransferParams{
Amount: stripe.Int64(TransferAmount),
Currency: stripe.String(Currency),
Destination: stripe.String(Destination),
// SourceTransaction: stripe.String(Source),
}
tRes, err := stripego.TransferBalance(StripeSK, tp)
if err != nil {
t.Errorf("got error when initiating balance transfer: %v", err)
return
}
res := &stripe.Transfer{}
err = json.Unmarshal(tRes.LastResponse.RawJSON, &res)
if err != nil {
t.Errorf("got error when unmarshalling transfer response: %v", err)
return
}
expected := &stripe.Transfer{}
expected.Object = TransferObject
expected.Amount = TransferAmount
expected.Currency = stripe.Currency(Currency)
if res.Object != expected.Object {
t.Errorf("got: %v, want: %v", res.Object, expected.Object)
}
if res.Amount != expected.Amount {
t.Errorf("got: %v, want: %v", res.Amount, expected.Amount)
}
if res.Currency != expected.Currency {
t.Errorf("got: %v, want: %v", res.Currency, expected.Currency)
}
if res.Destination.ID != Destination {
t.Errorf("destination IDs do not match")
}
}