-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransaction_split_example.go
More file actions
88 lines (73 loc) · 2.21 KB
/
transaction_split_example.go
File metadata and controls
88 lines (73 loc) · 2.21 KB
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
package main
import (
"context"
"log"
"github.com/rammyblog/go-paystack"
transaction_splits "github.com/rammyblog/go-paystack/transaction-splits"
)
func createTransactionSplit(ctx context.Context, c *paystack.Client) {
subaccountArray := []transaction_splits.TransactionSplitSubAccount{
{Subaccount: "ACCT_jo822mgh7xbjzqk", Share: 60},
}
resp, err := c.TransactionSplit.Create(ctx, &transaction_splits.TransactionSplitRequest{
Name: "Percentage Split",
Type: "percentage",
Currency: "NGN",
Subaccounts: subaccountArray,
BearerType: "subaccount",
BearerSubaccount: "ACCT_jo822mgh7xbjzqk",
})
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n Initialize transaction split \n-%+v\n", resp)
}
func listTransactionSplits(ctx context.Context, c *paystack.Client) {
resp, err := c.TransactionSplit.List(ctx)
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n transaction splits \n-%+v\n", resp)
}
func fetchTransactionSplit(ctx context.Context, c *paystack.Client) {
resp, err := c.TransactionSplit.Fetch(ctx, "1499896")
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n transaction splits \n-%+v\n", resp)
}
func updateTransactionSplit(ctx context.Context, c *paystack.Client) {
resp, err := c.TransactionSplit.Update(ctx, "1499896", &transaction_splits.TransactionSplitRequest{
Name: "Updated name",
Active: false,
})
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n updated transaction split \n-%+v\n", resp)
}
func addSubaccountToTransactionSplit(ctx context.Context, c *paystack.Client) {
resp, err := c.TransactionSplit.AddSubaccount(ctx, "1499896", &transaction_splits.TransactionSplitSubAccount{
Subaccount: "ACCT_ch9drs2a9pka9fb",
Share: 10,
})
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n updated transaction split \n-%+v\n", resp)
}
func removeSubaccountToTransactionSplit(ctx context.Context, c *paystack.Client) {
resp, err := c.TransactionSplit.RemoveSubaccount(ctx, "1499896", &transaction_splits.TransactionSplitSubAccount{
Subaccount: "ACCT_ch9drs2a9pka9fb",
})
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n remove subaccount transaction split \n-%+v\n", resp)
}