-
Notifications
You must be signed in to change notification settings - Fork 1
/
model.go
65 lines (58 loc) · 1.96 KB
/
model.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
package darajago
import (
"encoding/json"
"fmt"
)
type ErrorResponse struct {
RequestID string `json:"requestId"`
ErrorCode string `json:"errorCode"`
ErrorMessage string `json:"errorMessage"`
error error `json:"-"`
Raw []byte `json:"-"`
}
func (e ErrorResponse) Error() string {
if e.error != nil {
return fmt.Sprintf("%v", e.error)
}
if e.ErrorMessage == "" && len(e.Raw) != 0 {
return string(e.Raw)
}
bytes, _ := json.Marshal(e)
return string(bytes)
}
type RegisterURLConfig struct {
ShortCode string `json:"ShortCode"`
ResponseType string `json:"ResponseType"`
ConfirmationURL string `json:"ConfirmationURL"`
ValidationURL string `json:"ValidationURL"`
}
type TransactionStatus struct {
Initiator string `json:"Initiator"`
SecurityCredential string `json:"SecurityCredential"`
CommandID string `json:"CommandID"`
TransactionID string `json:"TransactionID"`
PartyA string `json:"PartyA"`
IdentifierType string `json:"IdentifierType"`
ResultURL string `json:"ResultURL"`
QueueTimeOutURL string `json:"QueueTimeOutURL"`
Remarks string `json:"Remarks"`
Occasion string `json:"Occasion"`
}
// BalanceQuery is used to query the balance of an M-Pesa account
type BalanceQuery struct {
Initiator string `json:"Initiator"`
SecurityCredential string `json:"SecurityCredential"`
CommandID string `json:"CommandID"`
PartyA string `json:"PartyA"`
IdentifierType string `json:"IdentifierType"`
Remarks string `json:"Remarks"`
QueueTimeOutURL string `json:"QueueTimeOutURL"`
ResultURL string `json:"ResultURL"`
}
// C2BURLRegistration is used to register the confirmation and validation URLs
type C2BURLRegistration struct {
ShortCode string `json:"ShortCode"`
ResponseType string `json:"ResponseType"`
ConfirmationURL string `json:"ConfirmationURL"`
ValidationURL string `json:"ValidationURL"`
}