-
Notifications
You must be signed in to change notification settings - Fork 12
/
modification_gateway.go
42 lines (30 loc) · 963 Bytes
/
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
package adyen
import "encoding/json"
// CaptureType - capture type request, @TODO: move to enums
const CaptureType = "capture"
// CancelType - cancel type request, @TODO: move to enums
const CancelType = "cancel"
// 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
}