This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
types.go
194 lines (173 loc) · 7.65 KB
/
types.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
package sleet
import "time"
// Client defines the Sleet interface which takes in a generic request and returns a generic response
// The translations for each specific PsP takes place in the corresponding gateways/<PsP> folders
// The four supported methods are Auth, Capture, Void, Refund
type Client interface {
Authorize(request *AuthorizationRequest) (*AuthorizationResponse, error)
Capture(request *CaptureRequest) (*CaptureResponse, error)
Void(request *VoidRequest) (*VoidResponse, error)
Refund(request *RefundRequest) (*RefundResponse, error)
}
// Amount specifies both quantity and currency
type Amount struct {
Amount int64
Currency string
}
// BillingAddress used for AVS checks for auth calls
type BillingAddress struct {
StreetAddress1 *string
StreetAddress2 *string
Locality *string
RegionCode *string
PostalCode *string
CountryCode *string // ISO 2-digit code
Company *string
Email *string
}
// CreditCard represents raw credit card information
type CreditCard struct {
FirstName string
LastName string
Number string
ExpirationMonth int
ExpirationYear int
CVV string
Network CreditCardNetwork
Save bool // indicates if customer wants to save their credit card details
}
// LineItem is used for Level3 Processing if enabled (not default). Specifies information per item in the order
type LineItem struct {
Description string
ProductCode string
UnitPrice Amount
Quantity int64
TotalAmount Amount
ItemTaxAmount Amount
ItemDiscountAmount Amount
UnitOfMeasure string
CommodityCode string
}
// Level3Data contains all of the information needed for Level3 processing including LineItems
type Level3Data struct {
CustomerReference string
TaxAmount Amount
DiscountAmount Amount
ShippingAmount Amount
DutyAmount Amount
DestinationPostalCode string
DestinationCountryCode string
DestinationAdminArea string
LineItems []LineItem
}
// AuthorizationRequest specifies needed information for request to authorize by PsPs
// Note: Only credit cards are supported
// Note: Options is a generic key-value pair that can be used to provide additional information to PsP
type AuthorizationRequest struct {
Amount Amount
CreditCard *CreditCard
BillingAddress *BillingAddress
Level3Data *Level3Data
ClientTransactionReference *string // Custom transaction reference metadata that will be associated with this request
Channel string // for Psps that track the sales channel
Cryptogram string // for Network Tokenization methods
ECI string // E-Commerce Indicator (can be used for Network Tokenization as well)
MerchantOrderReference string // Similar to ClientTransactionReference but specifically if we want to store the shopping cart order id
// For Card on File transactions we want to store the various different types (initial cof, initial recurring, etc)
// If we are in a recurring situation, then we can use the PreviousExternalTransactionID as part of the auth request
ProcessingInitiator *ProcessingInitiatorType
PreviousExternalTransactionID *string
Options map[string]interface{}
ShopperReference string // shopperReference used to get adyen recurring info
ThreeDS *ThreeDS
}
// AuthorizationResponse is a generic response returned back to client after data massaging from PsP Response
// The raw AVS and CVV are included if applicable
// Success is true if Auth went through successfully
type AuthorizationResponse struct {
// Raw fields contain the untranslated responses from processors, while
// the non-raw fields are the best parsings to a single standard, with
// loss of granularity minimized. The latter should be preferred when
// treating Sleet as a black box.
Success bool
TransactionReference string
ExternalTransactionID string
AvsResult AVSResponse
CvvResult CVVResponse
Response string
ErrorCode string
AvsResultRaw string
CvvResultRaw string
RTAUResult *RTAUResponse
AdyenAdditionalData map[string]string // store additional Adyen recurring info
}
// CaptureRequest specifies the authorized transaction to capture and also an amount for partial capture use cases
type CaptureRequest struct {
Amount *Amount
TransactionReference string
ClientTransactionReference *string // Custom transaction reference metadata that will be associated with this request
}
// CaptureResponse will have Success be true if transaction is captured and also a reference to be used for subsequent operations
type CaptureResponse struct {
Success bool
TransactionReference string
ErrorCode *string
}
// VoidRequest cancels an authorized transaction
type VoidRequest struct {
TransactionReference string
ClientTransactionReference *string // Custom transaction reference metadata that will be associated with this request
}
// VoidResponse also specifies a transaction reference if PsP uses different transaction references for different states
type VoidResponse struct {
Success bool
TransactionReference string
ErrorCode *string
}
// RefundRequest for refunding a captured transaction with generic Options and amount to be refunded
type RefundRequest struct {
Amount *Amount
TransactionReference string
ClientTransactionReference *string // Custom transaction reference metadata that will be associated with this request
Last4 string
Options map[string]interface{}
}
// RefundResponse indicating if request went through successfully
type RefundResponse struct {
Success bool
TransactionReference string
ErrorCode *string
}
// Currency maps to the CURRENCIES list in currency.go specifying the symbol and precision for the currency
type Currency struct {
Precision int
Symbol string
}
// RTAUStatus represents the Real Time Account Updater response from a processor, if applicable
type RTAUStatus string
const (
RTAUStatusUnknown RTAUStatus = "Unknown" // when a processor has RTAU capability, but returns an unexpected status
RTAUStatusNoResponse RTAUStatus = "NoResponse" // when a processor has RTAU capability, but doesn't return any additional info
RTAUStatusCardChanged RTAUStatus = "CardChanged"
RTAUStatusCardExpired RTAUStatus = "CardExpiryChanged"
RTAUStatusContactCardAccountHolder RTAUStatus = "ContactCardAccountHolder"
RTAUStatusCloseAccount RTAUStatus = "CloseAccount"
)
type RTAUResponse struct {
RealTimeAccountUpdateStatus RTAUStatus
UpdatedExpiry *time.Time
UpdatedBIN string
UpdatedLast4 string
}
// ThreeDS holds results from a 3DS verification challenge.
type ThreeDS struct {
Frictionless bool // Whether the 3DS flow for this transaction was frictionless
ACSTransactionID string // Transaction ID assigned by ACS
CAVV string // Cardholder Authentication Value
CAVVAlgorithm string // Algorithm used to calculate CAVV
DSTransactionID string // Directory Server (DS) Transaction ID (for 3DS2)
PAResStatus string // Transaction status result
UCAFIndicator string // Universal Cardholder Authentication Field Indicator value provided by issuer
Version string // 3DS Version
XID string // Transaction ID from authentication processing (for 3DS1)
}