-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtransaction_reporting.go
363 lines (328 loc) · 13.5 KB
/
transaction_reporting.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
package AuthorizeCIM
import (
"encoding/json"
"time"
)
type Range struct {
Start time.Time `"omitempty"`
End time.Time `"omitempty"`
BatchId string `"omitempty"`
Sorting Sorting `"omitempty"`
Paging Paging `"omitempty"`
}
func (r BatchListResponse) List() []BatchList {
return r.BatchList
}
func (r Range) SettledBatch() (*BatchListResponse, error) {
new := GetSettledBatchListRequest{
GetSettledBatchList: GetSettledBatchList{
MerchantAuthentication: GetAuthentication(),
IncludeStatistics: "true",
FirstSettlementDate: r.Start,
LastSettlementDate: r.End,
},
}
jsoned, err := json.Marshal(new)
if err != nil {
return nil, err
}
response, err := SendRequest(jsoned)
var dat BatchListResponse
json.Unmarshal(response, &dat)
return &dat, err
}
func UnSettledBatch() (*UnsettledTransactionListResponse, error) {
new := GetUnsettledBatchTransactionListRequest{
GetUnsettledTransactionList: GetUnsettledTransactionList{
MerchantAuthentication: GetAuthentication(),
},
}
jsoned, err := json.Marshal(new)
if err != nil {
return nil, err
}
response, err := SendRequest(jsoned)
var dat UnsettledTransactionListResponse
err = json.Unmarshal(response, &dat)
return &dat, err
}
func (r UnsettledTransactionListResponse) List() []Transaction {
return r.Transactions
}
func (r *GetTransactionListResponse) List() []Transaction {
return r.GetTransactionList.Transactions.Transaction
}
func (r *GetTransactionListResponse) Count() int {
return r.GetTransactionList.TotalNumInResultSet
}
func (r Range) Transactions() (*GetTransactionListResponse, error) {
new := GetTransactionListRequest{
GetTransactionList: GetTransactionList{
MerchantAuthentication: GetAuthentication(),
BatchID: r.BatchId,
},
}
jsoned, err := json.Marshal(new)
if err != nil {
return nil, err
}
response, err := SendRequest(jsoned)
var dat GetTransactionListResponse
json.Unmarshal(response, &dat)
return &dat, err
}
func (r Range) Statistics() (*Statistics, error) {
new := GetBatchStatisticsRequest{
GetBatchStatistics: GetBatchStatistics{
MerchantAuthentication: GetAuthentication(),
BatchID: r.BatchId,
},
}
jsoned, err := json.Marshal(new)
if err != nil {
return nil, err
}
response, err := SendRequest(jsoned)
var dat BatchStatisticsResponse
err = json.Unmarshal(response, &dat)
return &dat.Batch.Statistics[0], err
}
func GetMerchantDetails() (*MerchantDetailsResponse, error) {
new := GetMerchantDetailsRequest{
GetMerchantDetailsReq: GetMerchantDetailsReq{
MerchantAuthentication: GetAuthentication(),
},
}
jsoned, err := json.Marshal(new)
if err != nil {
return nil, err
}
response, err := SendRequest(jsoned)
var dat MerchantDetailsResponse
err = json.Unmarshal(response, &dat)
return &dat, err
}
func (tranx PreviousTransaction) Info() (*FullTransaction, error) {
new := GetTransactionDetailsRequest{
GetTransactionDetails: GetTransactionDetails{
MerchantAuthentication: GetAuthentication(),
TransID: tranx.RefId,
},
}
jsoned, err := json.Marshal(new)
if err != nil {
return nil, err
}
response, err := SendRequest(jsoned)
var dat TransactionDetailsResponse
err = json.Unmarshal(response, &dat)
return &dat.Transaction, err
}
type GetSettledBatchListRequest struct {
GetSettledBatchList GetSettledBatchList `json:"getSettledBatchListRequest"`
}
type GetSettledBatchList struct {
MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication"`
IncludeStatistics string `json:"includeStatistics"`
FirstSettlementDate time.Time `json:"firstSettlementDate"`
LastSettlementDate time.Time `json:"lastSettlementDate"`
}
type BatchListResponse struct {
MessagesResponse
BatchList []BatchList `json:"batchList,omitempty"`
}
type BatchList struct {
BatchID string `json:"batchId"`
SettlementTimeUTC time.Time `json:"settlementTimeUTC"`
SettlementTimeUTCSpecified bool `json:"settlementTimeUTCSpecified"`
SettlementTimeLocal string `json:"settlementTimeLocal"`
SettlementTimeLocalSpecified bool `json:"settlementTimeLocalSpecified"`
SettlementState string `json:"settlementState"`
PaymentMethod string `json:"paymentMethod"`
}
type GetTransactionListRequest struct {
GetTransactionList GetTransactionList `json:"getTransactionListRequest"`
}
type GetTransactionList struct {
MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication"`
BatchID string `json:"batchId,omitempty"`
Sorting *Sorting `json:"sorting,omitempty"`
Paging *Paging `json:"paging,omitempty"`
}
type GetTransactionListResponse struct {
GetTransactionList struct {
MessagesResponse
Transactions Transactions `json:"transactions"`
TotalNumInResultSet int `json:"totalNumInResultSet"`
} `json:"getTransactionListResponse"`
}
type Transactions struct {
Transaction []Transaction `json:"transaction"`
}
type Transaction struct {
TransID string `json:"transId"`
SubmitTimeUTC string `json:"submitTimeUTC"`
SubmitTimeLocal string `json:"submitTimeLocal"`
TransactionStatus string `json:"transactionStatus"`
Invoice string `json:"invoice,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Amount string `json:"amount,omitempty"`
AccountType string `json:"accountType,omitempty"`
AccountNumber string `json:"accountNumber,omitempty"`
SettleAmount float64 `json:"settleAmount,omitempty"`
Subscription struct {
ID int `json:"id"`
PayNum int `json:"payNum,omitempty"`
} `json:"subscription,omitempty"`
MarketType string `json:"marketType,omitempty"`
Product string `json:"product,omitempty"`
MobileDeviceID string `json:"mobileDeviceId,omitempty"`
}
type GetTransactionDetailsRequest struct {
GetTransactionDetails GetTransactionDetails `json:"getTransactionDetailsRequest"`
}
type GetTransactionDetails struct {
MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication"`
TransID string `json:"transId"`
}
type TransactionDetailsResponse struct {
Transaction FullTransaction `json:"transaction"`
MessagesResponse
}
type FullTransaction struct {
TransID string `json:"transId"`
SubmitTimeUTC time.Time `json:"submitTimeUTC"`
SubmitTimeLocal string `json:"submitTimeLocal"`
TransactionType string `json:"transactionType"`
TransactionStatus string `json:"transactionStatus"`
ResponseCode int `json:"responseCode"`
ResponseReasonCode int `json:"responseReasonCode"`
ResponseReasonDescription string `json:"responseReasonDescription"`
AVSResponse string `json:"AVSResponse"`
Batch struct {
BatchID string `json:"batchId"`
SettlementTimeUTC time.Time `json:"settlementTimeUTC"`
SettlementTimeUTCSpecified bool `json:"settlementTimeUTCSpecified"`
SettlementTimeLocal string `json:"settlementTimeLocal"`
SettlementTimeLocalSpecified bool `json:"settlementTimeLocalSpecified"`
SettlementState string `json:"settlementState"`
} `json:"batch"`
Order struct {
InvoiceNumber string `json:"invoiceNumber"`
} `json:"order"`
RequestedAmountSpecified bool `json:"requestedAmountSpecified"`
AuthAmount float64 `json:"authAmount"`
SettleAmount float64 `json:"settleAmount"`
PrepaidBalanceRemainingSpecified bool `json:"prepaidBalanceRemainingSpecified"`
TaxExempt bool `json:"taxExempt"`
TaxExemptSpecified bool `json:"taxExemptSpecified"`
Payment struct {
BankAccount struct {
AccountType int `json:"accountType"`
AccountTypeSpecified bool `json:"accountTypeSpecified"`
RoutingNumber string `json:"routingNumber"`
AccountNumber string `json:"accountNumber"`
NameOnAccount string `json:"nameOnAccount"`
EcheckType int `json:"echeckType"`
EcheckTypeSpecified bool `json:"echeckTypeSpecified"`
BankName interface{} `json:"bankName"`
} `json:"bankAccount"`
} `json:"payment"`
RecurringBilling bool `json:"recurringBilling"`
RecurringBillingSpecified bool `json:"recurringBillingSpecified"`
ReturnedItems []struct {
ID string `json:"id"`
DateUTC time.Time `json:"dateUTC"`
DateLocal string `json:"dateLocal"`
Code string `json:"code"`
Description string `json:"description"`
} `json:"returnedItems"`
}
type GetUnsettledBatchTransactionListRequest struct {
GetUnsettledTransactionList GetUnsettledTransactionList `json:"getUnsettledTransactionListRequest"`
}
type GetUnsettledTransactionList struct {
MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication"`
Sorting *Sorting `json:"sorting,omitempty"`
Paging *Paging `json:"paging,omitempty"`
}
type UnsettledTransactionListResponse struct {
Transactions []Transaction `json:"transactions"`
MessagesResponse
}
type GetBatchStatisticsRequest struct {
GetBatchStatistics GetBatchStatistics `json:"getBatchStatisticsRequest"`
}
type GetBatchStatistics struct {
MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication"`
BatchID string `json:"batchId"`
}
type BatchStatisticsResponse struct {
Batch struct {
BatchID string `json:"batchId"`
SettlementTimeUTC time.Time `json:"settlementTimeUTC"`
SettlementTimeUTCSpecified bool `json:"settlementTimeUTCSpecified"`
SettlementTimeLocal string `json:"settlementTimeLocal"`
SettlementTimeLocalSpecified bool `json:"settlementTimeLocalSpecified"`
SettlementState string `json:"settlementState"`
PaymentMethod string `json:"paymentMethod"`
Statistics []Statistics `json:"statistics"`
} `json:"batch"`
MessagesResponse
}
type Statistics struct {
AccountType string `json:"accountType"`
ChargeAmount float64 `json:"chargeAmount"`
ChargeCount int `json:"chargeCount"`
RefundAmount float64 `json:"refundAmount"`
RefundCount int `json:"refundCount"`
VoidCount int `json:"voidCount"`
DeclineCount int `json:"declineCount"`
ErrorCount int `json:"errorCount"`
ReturnedItemAmount int `json:"returnedItemAmount"`
ReturnedItemAmountSpecified bool `json:"returnedItemAmountSpecified"`
ReturnedItemCount int `json:"returnedItemCount"`
ReturnedItemCountSpecified bool `json:"returnedItemCountSpecified"`
ChargebackAmount int `json:"chargebackAmount"`
ChargebackAmountSpecified bool `json:"chargebackAmountSpecified"`
ChargebackCount int `json:"chargebackCount"`
ChargebackCountSpecified bool `json:"chargebackCountSpecified"`
CorrectionNoticeCount int `json:"correctionNoticeCount"`
CorrectionNoticeCountSpecified bool `json:"correctionNoticeCountSpecified"`
ChargeChargeBackAmount int `json:"chargeChargeBackAmount"`
ChargeChargeBackAmountSpecified bool `json:"chargeChargeBackAmountSpecified"`
ChargeChargeBackCount int `json:"chargeChargeBackCount"`
ChargeChargeBackCountSpecified bool `json:"chargeChargeBackCountSpecified"`
RefundChargeBackAmount int `json:"refundChargeBackAmount"`
RefundChargeBackAmountSpecified bool `json:"refundChargeBackAmountSpecified"`
RefundChargeBackCount int `json:"refundChargeBackCount"`
RefundChargeBackCountSpecified bool `json:"refundChargeBackCountSpecified"`
ChargeReturnedItemsAmount float64 `json:"chargeReturnedItemsAmount"`
ChargeReturnedItemsAmountSpecified bool `json:"chargeReturnedItemsAmountSpecified"`
ChargeReturnedItemsCount int `json:"chargeReturnedItemsCount"`
ChargeReturnedItemsCountSpecified bool `json:"chargeReturnedItemsCountSpecified"`
RefundReturnedItemsAmount int `json:"refundReturnedItemsAmount"`
RefundReturnedItemsAmountSpecified bool `json:"refundReturnedItemsAmountSpecified"`
RefundReturnedItemsCount int `json:"refundReturnedItemsCount"`
RefundReturnedItemsCountSpecified bool `json:"refundReturnedItemsCountSpecified"`
}
type GetMerchantDetailsRequest struct {
GetMerchantDetailsReq GetMerchantDetailsReq `json:"getMerchantDetailsRequest"`
}
type GetMerchantDetailsReq struct {
MerchantAuthentication MerchantAuthentication `json:"merchantAuthentication"`
}
type MerchantDetailsResponse struct {
IsTestMode bool `json:"isTestMode"`
Processors []struct {
Name string `json:"name"`
} `json:"processors"`
MerchantName string `json:"merchantName"`
GatewayID string `json:"gatewayId"`
MarketTypes []string `json:"marketTypes"`
ProductCodes []string `json:"productCodes"`
PaymentMethods []string `json:"paymentMethods"`
Currencies []string `json:"currencies"`
MessagesResponse
}