-
Notifications
You must be signed in to change notification settings - Fork 28
/
notification_handler.go
57 lines (51 loc) · 2.23 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package notification
import (
"encoding/json"
"github.com/adyen/adyen-go-api-library/v5/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"
EventCodeAuthorisationAdjustment = "AUTHORISATION_ADJUSTMENT"
EventCodeCancellation = "CANCELLATION"
EventCodeCancelOrRefund = "CANCEL_OR_REFUND"
EventCodeCapture = "CAPTURE"
EventCodeCaptureFailed = "CAPTURE_FAILED"
EventCodeHandledExternally = "HANDLED_EXTERNALLY"
EventOrderOpened = "ORDER_OPENED"
EventOrderClosed = "ORDER_CLOSED"
EventCodeRefund = "REFUND"
EventCodeRefundFailed = "REFUND_FAILED"
EventCodeRefundedReversed = "REFUNDED_REVERSED"
EventCodeRefundWithData = "REFUND_WITH_DATA"
EventCodeReportAvailable = "REPORT_AVAILABLE"
EventCodeVoidPendingRefund = "VOID_PENDING_REFUND"
EventCodeChargeback = "CHARGEBACK"
EventCodeChargebackReversed = "CHARGEBACK_REVERSED"
EventCodeNotificationOfChargeback = "NOTIFICATION_OF_CHARGEBACK"
EventCodeNotificationOfFraud = "NOTIFICATION_OF_FRAUD"
EventCodePrearbitrationLost = "PREARBITRATION_LOST"
EventCodePrearbitrationWon = "PREARBITRATION_WON"
EventCodeRequestForInformation = "REQUEST_FOR_INFORMATION"
EvenctCodeSecondChargeback = "SECOND_CHARGEBACK"
EventCodePayoutExpire = "PAYOUT_EXPIRE"
EventCodePayoutDecline = "PAYOUT_DECLINE"
EventCodePayoutThirdparty = "PAYOUT_THIRDPARTY"
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
}