-
Notifications
You must be signed in to change notification settings - Fork 21
/
events.go
141 lines (123 loc) · 4.86 KB
/
events.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package abc
import (
"time"
"encoding/json"
"github.com/checkout/checkout-sdk-go/common"
"github.com/checkout/checkout-sdk-go/payments"
"github.com/checkout/checkout-sdk-go/payments/abc"
)
const (
events = "events"
eventTypes = "event-types"
notifications = "notifications"
webhooks = "webhooks"
retry = "retry"
)
type EventDataStatus string
const (
Pending EventDataStatus = "Pending"
Authorized EventDataStatus = "Authorized"
Voided EventDataStatus = "Voided"
PartiallyCaptured EventDataStatus = "Partially Captured"
Captured EventDataStatus = "Captured"
PartiallyRefunded EventDataStatus = "Partially Refunded"
Refunded EventDataStatus = "Refunded"
Declined EventDataStatus = "Declined"
Canceled EventDataStatus = "Canceled"
)
type (
QueryRetrieveAllEventType struct {
Version string `url:"version,omitempty"`
}
EventTypes struct {
Version string `json:"version"`
EventTypes []string `json:"event_types"`
}
EventTypesResponse struct {
HttpResponse common.HttpMetadata
EventTypes []EventTypes
}
)
type (
QueryRetrieveEvents struct {
PaymentId string `url:"payment_id,omitempty"`
ChargeId string `url:"charge_id,omitempty"`
TrackId string `url:"track_id,omitempty"`
Reference string `url:"reference,omitempty"`
Skip int `url:"skip,omitempty"`
Limit int `url:"limit,omitempty"`
}
EventsSummaryResponse struct {
Id string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
CreatedOn string `json:"created_on,omitempty"`
Links map[string]common.Link `json:"_links"`
}
EventsPageResponse struct {
HttpResponse common.HttpMetadata
TotalCount int `json:"total_count,omitempty"`
Limit int `json:"limit,omitempty"`
Skip int `json:"skip,omitempty"`
Data []EventsSummaryResponse `json:"data,omitempty"`
}
)
type (
EventNotificationSummaryResponse struct {
Id string `json:"id,omitempty"`
Url string `json:"url,omitempty"`
Success bool `json:"success,omitempty"`
Links map[string]common.Link `json:"_links"`
}
EventPaymentData struct {
Id string `json:"id,omitempty"`
ActionId string `json:"action_id,omitempty"`
Amount int64 `json:"amount,omitempty"`
Currency common.Currency `json:"currency,omitempty"`
Approved bool `json:"approved,omitempty"`
Status EventDataStatus `json:"status,omitempty"`
AuthCode string `json:"auth_code,omitempty"`
ResponseCode string `json:"response_code,omitempty"`
ResponseSummary string `json:"response_summary,omitempty"`
ThreeDs *payments.ThreeDsEnrollment `json:"3ds,omitempty"`
Source *abc.ResponseCardSource `json:"source,omitempty"`
Customer *common.CustomerResponse `json:"customer,omitempty"`
ProcessedOn *time.Time `json:"processed_on,omitempty"`
Reference string `json:"reference,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
EventResponse struct {
HttpResponse common.HttpMetadata
Id string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Version string `json:"version,omitempty"`
CreatedOn string `json:"created_on,omitempty"`
Data *EventPaymentData `json:"data,omitempty"`
Notifications []EventNotificationSummaryResponse `json:"notifications,omitempty"`
Links map[string]common.Link `json:"_links"`
}
)
type (
AttemptSummary struct {
StatusCode int `json:"status_code,omitempty"`
ResponseBody string `json:"response_body,omitempty"`
SendMode string `json:"send_mode,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
}
EventNotificationResponse struct {
HttpResponse common.HttpMetadata
Id string `json:"id,omitempty"`
Url string `json:"url,omitempty"`
Success bool `json:"success,omitempty"`
ContentType string `json:"content_type,omitempty"`
Attempts []AttemptSummary `json:"attempts,omitempty"`
Links map[string]common.Link `json:"_links"`
}
)
func (e *EventTypesResponse) UnmarshalJSON(data []byte) error {
var eventTypes []EventTypes
if err := json.Unmarshal(data, &eventTypes); err != nil {
return err
}
e.EventTypes = eventTypes
return nil
}