-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
286 lines (249 loc) · 8.56 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
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
package veritrans
// EnvVariables is a list of the environment variables
var EnvVariables = []string{
"MDK_API_TOKEN",
"MDK_API_URL",
"MERCHANT_CCID",
"MERCHANT_PASSWORD",
"DUMMY_REQUEST",
"TXN_VERSION",
"ACCOUNT_API_URL",
"PAYMENT_API_URL",
"SEARCH_API_URL",
}
// ConnectionConfig is a configuration of veritrans connection
// AccountAPIURL is the account management api endpoint (https://api.veritrans.co.jp:443/paynowid/v1/)
// PaymentAPIURL is the payment api endpoint (https://api.veritrans.co.jp:443/paynow/v2)
// TxnVersion is the version of the veritrans api (2.0.0)
// DummyRequest is the flag indicating whether the request is dummy or live
type ConnectionConfig struct {
MerchantCCID string
MerchantPassword string
AccountAPIURL string
PaymentAPIURL string
SearchAPIURL string
TxnVersion string
DummyRequest string
}
// Default interface fills default values
type Default interface {
Default()
}
// AccountBasicParam represents the "accountBasicParam" of the request.
type AccountBasicParam struct {
CreateDate string `json:"createDate,omitempty"`
DeleteDate string `json:"deleteDate,omitempty"`
ForceDeleteDate string `json:"forceDeleteDate"`
}
// CardParam is represents the "cardParam" of the request.
type CardParam struct {
CardID string `json:"cardId,omitempty"`
DefaultCard string `json:"defaultCard,omitempty"`
DefaultCardID string `json:"defaultCardId,omitempty"`
CardNumber string `json:"cardNumber,omitempty"`
CardExpire string `json:"cardExpire,omitempty"`
Token string `json:"token,omitempty"`
}
// RecurringChargeParam represents the "recurringChargeParam" of the request.
type RecurringChargeParam struct {
GroupID string `json:"groupId"`
StartDate string `json:"startDate,omitempty"`
EndDate string `json:"endDate,omitempty"`
FinalCharge string `json:"finalCharge,omitempty"`
OneTimeAmount string `json:"oneTimeAmount"`
Amount string `json:"amount"`
}
// AccountParam represents the "accountParam" of the request.
type AccountParam struct {
AccountID string `json:"accountId"`
AccountBasicParam *AccountBasicParam `json:"accountBasicParam,omitempty"`
CardParam *CardParam `json:"cardParam,omitempty"`
RecurringChargeParam *RecurringChargeParam `json:"recurringChargeParam,omitempty"`
}
// PayNowIDParam represents the "payNowIDParam" of the request.
type PayNowIDParam struct {
Token string `json:"token,omitempty"`
AccountParam *AccountParam `json:"accountParam,omitempty"`
Memo string `json:"memo1,omitempty"`
FreeKey string `json:"freeKey,omitempty"`
}
// OrderParam struct
type OrderParam struct {
OrderID string `json:"orderId"`
}
// SearchParam represents the "searchParameters" of the request.
type SearchParam struct {
Common OrderParam `json:"common"`
}
// Params represents the "params" of the request.
type Params struct {
OrderID string `json:"orderId,omitempty"`
Amount string `json:"amount,omitempty"`
JPO string `json:"jpo,omitempty"`
WithCapture string `json:"withCapture,omitempty"`
PayNowIDParam *PayNowIDParam `json:"payNowIdParam,omitempty"`
ContainDummyFlag string `json:"containDummyFlag,omitempty"`
ServiceTypeCd []string `json:"serviceTypeCd,omitempty"`
NewerFlag string `json:"newerFlag,omitempty"`
SearchParam *SearchParam `json:"searchParameters,omitempty"`
TxnVersion string `json:"txnVersion"`
DummyRequest string `json:"dummyRequest"`
MerchantCCID string `json:"merchantCcid"`
}
// ConnectionParam represents the request parameter.
type ConnectionParam struct {
Params Params `json:"params"`
AuthHash string `json:"authHash"`
}
// AccountManagementMode is the enum type for the account management mode
type AccountManagementMode int32
const (
// MethodAdd indicates a Add method
MethodAdd AccountManagementMode = iota
// MethodUpdate indicates a Update method
MethodUpdate
// MethodDelete indicates a Delete method
MethodDelete
// MethodRestore indicates a Restore method
MethodRestore
// MethodGet indicates a Get method
MethodGet
)
// AccountManagementModes list
var AccountManagementModes = []string{"Add", "Update", "Delete", "Restore", "Get"}
// AccountServiceType is the enum type of provided services
type AccountServiceType int32
const (
// AccountType represents the account service
AccountType AccountServiceType = iota
// CardType represents the card service
CardType
)
// AccountServiceTypes is list of services
var AccountServiceTypes = []string{"account", "cardinfo"}
// PaymentManagementMode is the enum type for the payment mode
type PaymentManagementMode int32
const (
// MethodAuthorize indicates a Authorize
MethodAuthorize PaymentManagementMode = iota
// MethodCapture indicates a Capture
MethodCapture
// MethodCancel indicates a Cancel
MethodCancel
// MethodSearch indicates a Search
MethodSearch
)
// PaymentManagementModes a list of methods
var PaymentManagementModes = []string{"Authorize", "Capture", "Cancel", "Search"}
// PaymentServiceType represents the payment service
type PaymentServiceType int32
const (
// PayCard indicates the "card"
PayCard PaymentServiceType = iota
// MPI indicates the "mpi"
MPI
// CVS indicates the "cvs"
CVS
// EM indicates the "em"
EM
// Bank indicates the "bank"
Bank
// UPop indicates the "upop"
UPop
// Paypal indicates the "paypal"
Paypal
// Saison indicates the "saison"
Saison
// Alipay indicates the "alipay"
Alipay
// Carrier indicates the "carrier"
Carrier
// Search indicates the "search"
Search
)
// PaymentServiceTypes is a list of services
var PaymentServiceTypes = []string{"card", "mpi", "cvs", "em", "bank", "upop", "paypal", "saison", "alipay", "carrier", "search"}
// Default function for the PayNowIDParam
func (payParam *PayNowIDParam) Default() {
if payParam.Memo == "" {
payParam.Memo = "memo"
}
if payParam.FreeKey == "" {
payParam.FreeKey = "freekey"
}
}
// Default function for the AccountBasicParam
func (accountBasicParam *AccountBasicParam) Default() {
if accountBasicParam.ForceDeleteDate == "" {
accountBasicParam.ForceDeleteDate = "0"
}
}
// Default function for the RecurringChargeParam
func (recurringChargeParam *RecurringChargeParam) Default() {
if recurringChargeParam.FinalCharge == "" {
recurringChargeParam.FinalCharge = "0"
}
}
// Result indicates the response of api
type Result struct {
VResultCode string `json:"vResultCode"`
MStatus string `json:"mstatus"`
MErrorMsg string `json:"merrMsg"`
OrderInfos *OrderInfos `json:"orderInfos"`
}
// ProperTransactionInfo struct
type ProperTransactionInfo struct {
CardTransactionType string `json:"cardTransactionType"`
ReqWithCapture string `json:"reqWithCapture"`
ReqJPOInformation string `json:"reqJpoInformation"`
}
// TransactionInfo struct
type TransactionInfo struct {
Amount string `json:"amount"`
Command string `json:"command"`
MStatus string `json:"mstatus"`
ProperInfo ProperTransactionInfo `json:"properTransactionInfo"`
TxnDateTime string `json:"txnDatetime"`
TxnID string `json:"txnId"`
VResultCode string `json:"vResultCode"`
}
// TransactionInfos struct
type TransactionInfos struct {
TransactionInfo []TransactionInfo `json:"transactionInfo"`
}
// OrderInfo struct
type OrderInfo struct {
AccountID string `json:"accountId"`
Index int `json:"index"`
OrderID string `json:"orderId"`
ServiceTypeCd string `json:"serviceTypeCd"`
LastSuccessTxnType string `json:"lastSuccessTxnType"`
TransactionInfos *TransactionInfos `json:"transactionInfos"`
}
// OrderInfos struct
type OrderInfos struct {
OrderInfo []OrderInfo `json:"orderInfo"`
}
// CardInfo struct
type CardInfo struct {
CardExpire string `json:"cardExpire"`
CardID string `json:"cardId"`
CardNumber string `json:"cardNumber"`
DefaultCard string `json:"defaultCard"`
}
// Account struct
type Account struct {
AccountID string `json:"accountId"`
CardInfo []CardInfo `json:"cardInfo"`
}
// PayNowIDResponse struct
type PayNowIDResponse struct {
Account Account `json:"account"`
Message string `json:"message"`
Status string `json:"status"`
}
// ConnectionResponse struct
type ConnectionResponse struct {
PayNowIDResponse *PayNowIDResponse `json:"payNowIdResponse,omitempty"`
Result Result `json:"result"`
}