-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfees.go
41 lines (34 loc) · 1.17 KB
/
fees.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
package ravepay
// FIXME: Done to enable testing
var feeURL = buildURL(getFeeURL)
// GetFeeRequest encapsulates the params need for requesting fee amount from the rave api
// https://flutterwavedevelopers.readme.io/v2.0/reference#get-fees
type GetFeeRequest struct {
Amount string `json:"amount"`
PBFPubKey string `json:"PBFPubKey"`
Currency string `json:"currency"`
PType string `json:"ptype,omitempty"`
Card6 string `json:"card6,omitempty"`
}
// GetFeeResponse is a type of rave's response to a get fee request
type GetFeeResponse struct {
Data struct {
ChargeAmount string `json:"charge_amount"`
Fee float64 `json:"fee"`
Merchantfee string `json:"merchantfee"`
Ravefee string `json:"ravefee"`
} `json:"data"`
Message string `json:"message"`
Status string `json:"status"`
}
// GetFee returns rave's fee response for the given get fee request
// it returns any error that occures
func GetFee(p *GetFeeRequest) (*GetFeeResponse, error) {
// TODO: add request params validation
if p.PBFPubKey == "" {
p.PBFPubKey = PublicKey
}
resp := &GetFeeResponse{}
err := sendRequestAndParseResponse("POST", feeURL, p, resp)
return resp, err
}