forked from rpip/paystack-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefund.go
77 lines (72 loc) · 2.74 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
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
package paystack
import (
"time"
)
// RefundService handles operations related to transactions
// For more details see https://developers.paystack.co/v1.0/reference#create-transaction
type RefundService service
// RefundRequest represents a request to start a Refund.
type RefundRequest struct {
Transaction string `json:"transaction,omitempty"`
Currency string `json:"currency,omitempty"`
Amount float32 `json:"amount,omitempty"`
MerchantNote string `json:"merchant_note,omitempty"`
CustomerNote string `json:"customer_note,omitempty"`
}
type RefundResponse struct {
Status bool `json:"status"`
Message string `json:"message"`
Data struct {
Transaction struct {
ID int `json:"id"`
Domain string `json:"domain"`
Reference string `json:"reference"`
Amount int `json:"amount"`
PaidAt time.Time `json:"paid_at"`
Channel string `json:"channel"`
Currency string `json:"currency"`
Authorization struct {
ExpMonth interface{} `json:"exp_month"`
ExpYear interface{} `json:"exp_year"`
AccountName interface{} `json:"account_name"`
} `json:"authorization"`
Customer struct {
InternationalFormatPhone interface{} `json:"international_format_phone"`
} `json:"customer"`
Plan struct {
} `json:"plan"`
Subaccount struct {
Currency interface{} `json:"currency"`
} `json:"subaccount"`
Split struct {
} `json:"split"`
OrderID interface{} `json:"order_id"`
PaidAtt time.Time `json:"paidAt"`
PosTransactionData interface{} `json:"pos_transaction_data"`
Source interface{} `json:"source"`
FeesBreakdown interface{} `json:"fees_breakdown"`
} `json:"transaction"`
Integration int `json:"integration"`
DeductedAmount int `json:"deducted_amount"`
Channel interface{} `json:"channel"`
MerchantNote string `json:"merchant_note"`
CustomerNote string `json:"customer_note"`
Status string `json:"status"`
RefundedBy string `json:"refunded_by"`
ExpectedAt time.Time `json:"expected_at"`
Currency string `json:"currency"`
Domain string `json:"domain"`
Amount int `json:"amount"`
FullyDeducted bool `json:"fully_deducted"`
ID int `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"data"`
}
// Refund is for refunding payments.
// For more details see https://paystack.com/docs/api/refund/
func (s *RefundService) Refund(req *RefundRequest) (*RefundResponse, error) {
rf := &RefundResponse{}
err := s.client.CallSimple("POST", "/refund", req, rf)
return rf, err
}