-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrefunds.go
80 lines (74 loc) · 2.19 KB
/
refunds.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
package razorpay
import (
"encoding/json"
"strconv"
"time"
)
//Refund issue refund
func (r *RazorPay) CreateRefund(id string) (*Refund, error) {
refundresp := new(Refund)
resp, err := r.call("CreateRefund", nil, id+ "/refund", nil)
err = json.Unmarshal(resp, refundresp)
if err != nil {
return nil, err
}
return refundresp, err
}
//GetRefundsByPaymentID Fetch Multiple Refunds for a Payment
func (r *RazorPay) GetRefundsByPaymentID(id string, from time.Time, to time.Time, count int, skip int) (*[]Refunds, error) {
refundresp := new([]Refunds)
queryparams := make(map[string]string)
queryparams["id"]= id
queryparams["from"]= strconv.Itoa(int(from.Unix()))
queryparams["to"]= strconv.Itoa(int(to.Unix()))
queryparams["count"]= strconv.Itoa(count)
queryparams["skip"]= strconv.Itoa(skip)
resp, err := r.call("GetRefundsByPaymentID", nil, id+ "/refunds", queryparams)
if err != nil{
return nil, err
}
err = json.Unmarshal(resp, refundresp)
if err != nil{
return nil, err
}
return refundresp, nil
}
//func (r *RazorPay) GetRefundByPaymentID(id string) (*Refund, error) {
// refundresp := new(Refund)
// refundreq := refund
// createreqjson, err := json.Marshal(&refundreq)
// resp, err := r.call("CreateRefund", createreqjson, nil)
// json.Unmarshal(resp, refundresp)
// return refundresp, nil
//}
//GetRefunds Fetch Multiple Refunds
func (r *RazorPay) GetRefunds(from time.Time, to time.Time, count int, skip int) (*[]Refunds, error) {
refundresp := new([]Refunds)
queryparams := make(map[string]string)
queryparams["from"]= strconv.Itoa(int(from.Unix()))
queryparams["to"]= strconv.Itoa(int(to.Unix()))
queryparams["count"]= strconv.Itoa(count)
queryparams["skip"]= strconv.Itoa(skip)
resp, err := r.call("GetRefunds", nil, "", queryparams)
if err != nil{
return nil, err
}
err = json.Unmarshal(resp, refundresp)
if err != nil{
return nil, err
}
return refundresp, err
}
//GetRefundByID Fetch Refund by ID
func (r *RazorPay) GetRefundByID(id string) (*Refund, error) {
refundresp := new(Refund)
resp, err := r.call("GetRefundByID", nil, id, nil)
if err != nil{
return nil, err
}
err = json.Unmarshal(resp, refundresp)
if err != nil{
return nil, err
}
return refundresp, err
}