-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplan_example.go
More file actions
59 lines (53 loc) · 1.24 KB
/
plan_example.go
File metadata and controls
59 lines (53 loc) · 1.24 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
package main
import (
"context"
"log"
"github.com/rammyblog/go-paystack"
"github.com/rammyblog/go-paystack/plans"
)
func createPlan(ctx context.Context, c *paystack.Client) {
// Create a plan
resp, err := c.Plan.Create(ctx, &plans.CreatePlanRequest{
Name: "Monthly retainer",
Amount: 500000,
Interval: "monthly",
Description: "Monthly retainer",
})
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n Create Plan \n-%+v\n", resp)
}
func listPlans(ctx context.Context, c *paystack.Client) {
// List plans
resp, err := c.Plan.List(ctx)
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n List Plans \n-%+v\n", resp)
}
func fetchPlan(ctx context.Context, c *paystack.Client) {
// Fetch a plan
resp, err := c.Plan.Fetch(ctx, "PLN_48mmlpyngprj1fk")
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n Fetch Plan \n-%+v\n", resp)
}
func updatePlan(ctx context.Context, c *paystack.Client) {
// Update a plan
resp, err := c.Plan.Update(ctx, "PLN_48mmlpyngprj1fk", &plans.CreatePlanRequest{
Name: "Annual retainer",
Amount: 60000,
Interval: "annually",
Description: "Annual retainer",
})
if err != nil {
log.Fatal(err)
return
}
log.Printf("\n Update Plan \n-%+v\n", resp)
}