-
Notifications
You must be signed in to change notification settings - Fork 0
/
qrcodegen.go
34 lines (29 loc) · 1.2 KB
/
qrcodegen.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
package darajaAuth
type TransactionType string
const (
TransactionTypeBuyGoods TransactionType = "BG"
TransactionTypePayBill TransactionType = "PB"
TransactionTypeWithdraw TransactionType = "WA" // Withdraw Cash at Agent Till.
TransactionTypeSendMoney TransactionType = "SM" // Send Money to a Phone Number.
TransactionTypeSendtoBusiness TransactionType = "SB" // Send Money to a Business.
)
type QrPayload struct {
MerchantName string `json:"MerchantName"`
RefNo string `json:"RefNo"`
Amount string `json:"Amount"`
TransactionType TransactionType `json:"TransactionType"`
CreditPartyIdentifier string `json:"CreditPartyIdentifier"`
}
type QrResponse struct {
ResponseCode string `json:"ResponseCode"`
RequestID string `json:"RequestID"`
ResponseDescription string `json:"ResponseDescription"`
QrCode string `json:"QrCode"`
}
func (d *Daraja) MakeQRCodeRequest(payload QrPayload) (*QrResponse, *ErrorResponse) {
secureResponse, err := performSecurePostRequest[*QrResponse](payload, endpointQrCode, d)
if err != nil {
return nil, err
}
return secureResponse.Body, nil
}