-
Notifications
You must be signed in to change notification settings - Fork 12
/
modification_gateway.go
61 lines (47 loc) · 1.34 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
61
package adyen
/*
Adyen Modification actions
*/
const (
captureType = "capture"
cancelType = "cancel"
cancelOrRefundType = "cancelOrRefund"
refundType = "refund"
)
// 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
}
return resp.capture()
}
// 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
}
return resp.cancel()
}
// CancelOrRefund - Perform cancellation for not captured transaction
// otherwise perform refund action
func (a *ModificationGateway) CancelOrRefund(req *Cancel) (*CancelOrRefundResponse, error) {
resp, err := a.execute(cancelOrRefundType, req)
if err != nil {
return nil, err
}
return resp.cancelOrRefund()
}
// Refund - perform refund for already captured request
func (a *ModificationGateway) Refund(req *Refund) (*RefundResponse, error) {
resp, err := a.execute(refundType, req)
if err != nil {
return nil, err
}
return resp.refund()
}