-
Notifications
You must be signed in to change notification settings - Fork 28
/
notification_handler.go
39 lines (33 loc) · 1.15 KB
/
notification_handler.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
package notification
import (
"encoding/json"
"github.com/adyen/adyen-go-api-library/v2/src/common"
)
// NotificationService used to namespace this util under the client for consistency and for future prooffing if this ever requires api access
type NotificationService common.Service
//Event codes
const (
EventCodeAuthorisation = "AUTHORISATION"
EventCodeCancellation = "CANCELLATION"
EventCodeRefund = "REFUND"
EventCodeCancelOrRefund = "CANCEL_OR_REFUND"
EventCodeCapture = "CAPTURE"
EventCodeCaptureFailed = "CAPTURE_FAILED"
EventCodeRefundFailed = "REFUND_FAILED"
EventCodeRefundedReversed = "REFUNDED_REVERSED"
EventCodePaidoutReversed = "PAIDOUT_REVERSED"
)
//Additional Data
const (
AdditionalDataTotalFraudScore = "totalFraudScore"
AdditionalDataFraudCheckPattern = "fraudCheck-(\\d+)-([A-Za-z0-9]+)"
)
// HandleNotificationRequest creates a Notification object from the given JSON string
func (service *NotificationService) HandleNotificationRequest(req string) (*Notification, error) {
res := Notification{}
err := json.Unmarshal([]byte(req), &res)
if err != nil {
return nil, err
}
return &res, nil
}