|
1
|
|
|
package flutterwave |
|
2
|
|
|
|
|
3
|
|
|
import "time" |
|
4
|
|
|
|
|
5
|
|
|
// BillsCreatePaymentRequest is data needed to creat a payment |
|
6
|
|
|
type BillsCreatePaymentRequest struct { |
|
7
|
|
|
Country string `json:"country"` |
|
8
|
|
|
Customer string `json:"customer"` |
|
9
|
|
|
Amount int `json:"amount"` |
|
10
|
|
|
Recurrence string `json:"recurrence,omitempty"` |
|
11
|
|
|
Type string `json:"type"` |
|
12
|
|
|
Reference string `json:"reference,omitempty"` |
|
13
|
|
|
BillerName string `json:"biller_name,omitempty"` |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
// BillsCreatePaymentResponse is the data returned after creating a payment |
|
17
|
|
|
type BillsCreatePaymentResponse struct { |
|
18
|
|
|
Status string `json:"status"` |
|
19
|
|
|
Message string `json:"message"` |
|
20
|
|
|
Data struct { |
|
21
|
|
|
PhoneNumber string `json:"phone_number"` |
|
22
|
|
|
Amount int `json:"amount"` |
|
23
|
|
|
Network string `json:"network"` |
|
24
|
|
|
FlwRef string `json:"flw_ref"` |
|
25
|
|
|
TxRef string `json:"tx_ref"` |
|
26
|
|
|
} `json:"data"` |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
// IsSuccessfull determines if the bill payment was successfull |
|
30
|
|
|
func (response BillsCreatePaymentResponse) IsSuccessfull() bool { |
|
31
|
|
|
return response.Status == "success" && response.Data.TxRef != "" |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
// BillsValidateResponse is the response after validating a bill service |
|
35
|
|
|
type BillsValidateResponse struct { |
|
36
|
|
|
Status string `json:"status"` |
|
37
|
|
|
Message string `json:"message"` |
|
38
|
|
|
Data struct { |
|
39
|
|
|
ResponseCode string `json:"response_code"` |
|
40
|
|
|
Address interface{} `json:"address"` |
|
41
|
|
|
ResponseMessage string `json:"response_message"` |
|
42
|
|
|
Name string `json:"name"` |
|
43
|
|
|
BillerCode string `json:"biller_code"` |
|
44
|
|
|
Customer string `json:"customer"` |
|
45
|
|
|
ProductCode string `json:"product_code"` |
|
46
|
|
|
Email interface{} `json:"email"` |
|
47
|
|
|
Fee int `json:"fee"` |
|
48
|
|
|
Maximum int `json:"maximum"` |
|
49
|
|
|
Minimum int `json:"minimum"` |
|
50
|
|
|
} `json:"data"` |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
// IsSuccessfull determines if the bill validation was successfull |
|
54
|
|
|
func (response BillsValidateResponse) IsSuccessfull() bool { |
|
55
|
|
|
return response.Status == "success" && response.Data.Customer != "" |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
// BillsStatusVerboseResponse is the verbose response of a bill payment |
|
59
|
|
|
type BillsStatusVerboseResponse struct { |
|
60
|
|
|
Status string `json:"status"` |
|
61
|
|
|
Message string `json:"message"` |
|
62
|
|
|
Data struct { |
|
63
|
|
|
Currency string `json:"currency"` |
|
64
|
|
|
CustomerID string `json:"customer_id"` |
|
65
|
|
|
Frequency string `json:"frequency"` |
|
66
|
|
|
Amount string `json:"amount"` |
|
67
|
|
|
Product string `json:"product"` |
|
68
|
|
|
ProductName string `json:"product_name"` |
|
69
|
|
|
Commission int `json:"commission"` |
|
70
|
|
|
TransactionDate time.Time `json:"transaction_date"` |
|
71
|
|
|
Country string `json:"country"` |
|
72
|
|
|
TxRef string `json:"tx_ref"` |
|
73
|
|
|
Extra interface{} `json:"extra"` |
|
74
|
|
|
ProductDetails string `json:"product_details"` |
|
75
|
|
|
Status string `json:"status"` |
|
76
|
|
|
} `json:"data"` |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
// IsSuccessfull determines if the transaction was successfull |
|
80
|
|
|
func (response BillsStatusVerboseResponse) IsSuccessfull() bool { |
|
81
|
|
|
return response.Data.Status == "successful" && response.Data.TxRef != "" |
|
82
|
|
|
} |
|
83
|
|
|
|