-
Notifications
You must be signed in to change notification settings - Fork 12
/
modification_gateway.go
60 lines (45 loc) · 1.27 KB
/
modification_gateway.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
package adyen
import "encoding/json"
/*
Adyen Modification actions
*/
const (
CaptureType = "capture"
CancelType = "cancel"
CancelOrRefund = "cancelOrRefund"
)
// ModificationGateway - Adyen modification transaction logic, capture, cancel, refunds and e.t.c
type ModificationGateway struct {
*Adyen
}
// Capture - Perform capture payment in Adyen
func (a *ModificationGateway) Capture(req *Capture) (*CaptureResponse, error) {
resp, err := a.execute(CaptureType, req)
if err != nil {
return nil, err
}
var val CaptureResponse
json.NewDecoder(resp.Body).Decode(&val)
return &val, nil
}
// Cancel - Perform cancellation of the authorised transaction
func (a *ModificationGateway) Cancel(req *Cancel) (*CancelResponse, error) {
resp, err := a.execute(CancelType, req)
if err != nil {
return nil, err
}
var val CancelResponse
json.NewDecoder(resp.Body).Decode(&val)
return &val, nil
}
// CancelOrRefund - Perform cancellation for not captured transaction
// otherwise perform refund action
func (a *ModificationGateway) CancelOrRefund(req *Cancel) (*CancelOrRefundResponse, error) {
resp, err := a.execute(CancelOrRefund, req)
if err != nil {
return nil, err
}
var val CancelOrRefundResponse
json.NewDecoder(resp.Body).Decode(&val)
return &val, nil
}