forked from Fellow3-1/mpesa-api-go
-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.go
40 lines (33 loc) · 842 Bytes
/
main.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
package main
import (
"log"
"github.com/AndroidStudyOpenSource/mpesa-api-go"
)
const (
appKey = "GvzjNnYgNJtwgwfLBkZh65VPwfuKvs0V" // sandbox --> change to yours
appSecret = "oOpJICRVlyrGSAkM" // sandbox --> change to yours
)
func main() {
// These examples are taken from the mpesa-java-sdk examples
// at https://github.com/safaricom/mpesa-java-sdk
svc, err := mpesa.New(appKey, appSecret, mpesa.PRODUCTION)
if err != nil {
panic(err)
}
res, err := svc.B2BRequest(mpesa.B2B{})
if err != nil {
log.Println(err)
}
log.Println(res)
c2b := mpesa.C2B{
ShortCode: "600576",
CommandID: "CustomerPayBillOnline",
Amount: "2",
Msisdn: "254708374149",
BillRefNumber: "hkjhjkhjkh"}
res, err = svc.C2BSimulation(c2b)
if err != nil {
log.Println(err)
}
log.Println(res)
}