-
Notifications
You must be signed in to change notification settings - Fork 58
/
virtualaccount.go
89 lines (71 loc) · 2.69 KB
/
virtualaccount.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
package virtualaccount
import (
"context"
"github.com/xendit/xendit-go"
)
// CreateFixedVA creates new fixed virtual account
func CreateFixedVA(data *CreateFixedVAParams) (*xendit.VirtualAccount, *xendit.Error) {
return CreateFixedVAWithContext(context.Background(), data)
}
// CreateFixedVAWithContext creates new fixed virtual account with context
func CreateFixedVAWithContext(ctx context.Context, data *CreateFixedVAParams) (*xendit.VirtualAccount, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.CreateFixedVAWithContext(ctx, data)
}
// GetFixedVA gets a fixed virtual account
func GetFixedVA(data *GetFixedVAParams) (*xendit.VirtualAccount, *xendit.Error) {
return GetFixedVAWithContext(context.Background(), data)
}
// GetFixedVAWithContext gets a fixed virtual account with context
func GetFixedVAWithContext(ctx context.Context, data *GetFixedVAParams) (*xendit.VirtualAccount, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.GetFixedVAWithContext(ctx, data)
}
// UpdateFixedVA updates a fixed virtual account
func UpdateFixedVA(data *UpdateFixedVAParams) (*xendit.VirtualAccount, *xendit.Error) {
return UpdateFixedVAWithContext(context.Background(), data)
}
// UpdateFixedVAWithContext updates a fixed virtual account with context
func UpdateFixedVAWithContext(ctx context.Context, data *UpdateFixedVAParams) (*xendit.VirtualAccount, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.UpdateFixedWithContext(ctx, data)
}
// GetAvailableBanks gets available virtual account banks
func GetAvailableBanks() ([]xendit.VirtualAccountBank, *xendit.Error) {
return GetAvailableBanksWithContext(context.Background())
}
// GetAvailableBanksWithContext gets available virtual account banks with context
func GetAvailableBanksWithContext(ctx context.Context) ([]xendit.VirtualAccountBank, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.GetAvailableBanksWithContext(ctx)
}
// GetPayment gets one fixed virtual account payment
func GetPayment(data *GetPaymentParams) (*xendit.VirtualAccountPayment, *xendit.Error) {
return GetPaymentWithContext(context.Background(), data)
}
// GetPaymentWithContext gets one fixed virtual account payment with context
func GetPaymentWithContext(ctx context.Context, data *GetPaymentParams) (*xendit.VirtualAccountPayment, *xendit.Error) {
client, err := getClient()
if err != nil {
return nil, err
}
return client.GetPaymentWithContext(ctx, data)
}
func getClient() (*Client, *xendit.Error) {
return &Client{
Opt: &xendit.Opt,
APIRequester: xendit.GetAPIRequester(),
}, nil
}