-
Notifications
You must be signed in to change notification settings - Fork 2
/
bills.go
82 lines (74 loc) · 2.98 KB
/
bills.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package flutterwave
import "time"
// BillsCreatePaymentRequest is data needed to creat a payment
type BillsCreatePaymentRequest struct {
Country string `json:"country"`
Customer string `json:"customer"`
Amount int `json:"amount"`
Recurrence string `json:"recurrence,omitempty"`
Type string `json:"type"`
Reference string `json:"reference,omitempty"`
BillerName string `json:"biller_name,omitempty"`
}
// BillsCreatePaymentResponse is the data returned after creating a payment
type BillsCreatePaymentResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data struct {
PhoneNumber string `json:"phone_number"`
Amount int `json:"amount"`
Network string `json:"network"`
FlwRef string `json:"flw_ref"`
TxRef string `json:"tx_ref"`
} `json:"data"`
}
// IsSuccessfull determines if the bill payment was successfull
func (response BillsCreatePaymentResponse) IsSuccessfull() bool {
return response.Status == "success" && response.Data.FlwRef != ""
}
// BillsValidateResponse is the response after validating a bill service
type BillsValidateResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data struct {
ResponseCode string `json:"response_code"`
Address interface{} `json:"address"`
ResponseMessage string `json:"response_message"`
Name string `json:"name"`
BillerCode string `json:"biller_code"`
Customer string `json:"customer"`
ProductCode string `json:"product_code"`
Email interface{} `json:"email"`
Fee int `json:"fee"`
Maximum int `json:"maximum"`
Minimum int `json:"minimum"`
} `json:"data"`
}
// IsSuccessfull determines if the bill validation was successfull
func (response BillsValidateResponse) IsSuccessfull() bool {
return response.Status == "success" && response.Data.Customer != ""
}
// BillsStatusVerboseResponse is the verbose response of a bill payment
type BillsStatusVerboseResponse struct {
Status string `json:"status"`
Message string `json:"message"`
Data struct {
Currency string `json:"currency"`
CustomerID string `json:"customer_id"`
Frequency string `json:"frequency"`
Amount string `json:"amount"`
Product string `json:"product"`
ProductName string `json:"product_name"`
Commission int `json:"commission"`
TransactionDate time.Time `json:"transaction_date"`
Country string `json:"country"`
TxRef string `json:"tx_ref"`
Extra interface{} `json:"extra"`
ProductDetails string `json:"product_details"`
Status string `json:"status"`
} `json:"data"`
}
// IsSuccessfull determines if the transaction was successfull
func (response BillsStatusVerboseResponse) IsSuccessfull() bool {
return response.Data.Status == "successful" && response.Data.TxRef != ""
}