-
Notifications
You must be signed in to change notification settings - Fork 5
/
refund.go
34 lines (30 loc) · 1.03 KB
/
refund.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 ravepay
// FIXME: Done to enable testing
var rTxnURL = buildURL(refundTxnURL)
// RefundTxnResponse is rave's response for refund txn request
type RefundTxnResponse struct {
Data struct {
AccountID int `json:"AccountId"`
AmountRefunded int `json:"AmountRefunded"`
FlwRef string `json:"FlwRef"`
TransactionID int `json:"TransactionId"`
CreatedAt string `json:"createdAt"`
ID int `json:"id"`
Status string `json:"status"`
UpdatedAt string `json:"updatedAt"`
WalletID int `json:"walletId"`
} `json:"data"`
Message string `json:"message"`
Status string `json:"status"`
}
// Refund makes a refund request for txn with the given ref
// it returns rave's response and any error that occurs
func Refund(ref string) (*RefundTxnResponse, error) {
resp := &RefundTxnResponse{}
payload := struct {
SECKEY string `json:"SECKEY"`
FlwRef string `json:"ref"`
}{SecretKey, ref}
err := sendRequestAndParseResponse("POST", rTxnURL, payload, resp)
return resp, err
}