forked from veritrans/go-midtrans
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrequest.go
249 lines (215 loc) · 8.7 KB
/
request.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
package midtrans
// ItemDetail : Represent the transaction details
type ItemDetail struct {
ID string `json:"id"`
Name string `json:"name"`
Price int64 `json:"price"`
Qty int32 `json:"quantity"`
Brand string `json:"brand,omitempty"`
Category string `json:"category,omitempty"`
MerchantName string `json:"merchant_name,omitempty"`
}
// CustAddress : Represent the customer address
type CustAddress struct {
FName string `json:"first_name"`
LName string `json:"last_name"`
Phone string `json:"phone"`
Address string `json:"address"`
City string `json:"city"`
Postcode string `json:"postal_code"`
CountryCode string `json:"country_code"`
}
// CustDetail : Represent the customer detail
type CustDetail struct {
// first name
FName string `json:"first_name,omitempty"`
// last name
LName string `json:"last_name,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
BillAddr *CustAddress `json:"billing_address,omitempty"`
ShipAddr *CustAddress `json:"customer_address,omitempty"`
}
// TransactionDetails : Represent transaction details
type TransactionDetails struct {
OrderID string `json:"order_id"`
GrossAmt int64 `json:"gross_amount"`
}
// ExpiryDetail : Represent SNAP expiry details
type ExpiryDetail struct {
StartTime string `json:"start_time,omitempty"`
Unit string `json:"unit"`
Duration int64 `json:"duration"`
}
// CreditCardDetail : Represent credit card detail
type CreditCardDetail struct {
Secure bool `json:"secure,omitempty"`
TokenID string `json:"token_id"`
Bank string `json:"bank,omitempty"`
Bins []string `json:"bins,omitempty"`
InstallmentTerm int8 `json:"installment_term,omitempty"`
Type string `json:"type,omitempty"`
// indicate if generated token should be saved for next charge
SaveTokenID bool `json:"save_token_id,omitempty"`
SavedTokenIDExpireAt string `json:"saved_token_id_expired_at,omitempty"`
Authentication bool `json:"authentication,omitempty"`
}
// PermataBankTransferDetail : Represent Permata bank_transfer detail
type PermataBankTransferDetail struct {
Bank Bank `json:"bank"`
}
// BCABankTransferLangDetail : Represent BCA bank_transfer lang detail
type BCABankTransferLangDetail struct {
LangID string `json:"id,omitempty"`
LangEN string `json:"en,omitempty"`
}
/*
Example of usage syntax:
midtrans.BCABankTransferDetail{
FreeText: {
Inquiry: []midtrans.BCABankTransferLangDetail{
{
LangEN: "Test",
LangID: "Coba",
},
},
},
}
*/
// BCABankTransferDetailFreeText : Represent BCA bank_transfer detail free_text
type BCABankTransferDetailFreeText struct {
Inquiry []BCABankTransferLangDetail `json:"inquiry,omitempty"`
Payment []BCABankTransferLangDetail `json:"payment,omitempty"`
}
// BCABankTransferDetail : Represent BCA bank_transfer detail
type BCABankTransferDetail struct {
Bank Bank `json:"bank"`
VaNumber string `json:"va_number"`
FreeText BCABankTransferDetailFreeText `json:"free_text"`
}
// MandiriBillBankTransferDetail : Represent Mandiri Bill bank_transfer detail
type MandiriBillBankTransferDetail struct {
BillInfo1 string `json:"bill_info1,omitempty"`
BillInfo2 string `json:"bill_info2,omitempty"`
}
// BankTransferDetail : Represent bank_transfer detail
type BankTransferDetail struct {
Bank Bank `json:"bank,omitempty"`
VaNumber string `json:"va_number,omitempty"`
FreeText *BCABankTransferDetailFreeText `json:"free_text,omitempty"`
*MandiriBillBankTransferDetail
}
// BCAKlikPayDetail : Represent Internet Banking for BCA KlikPay
type BCAKlikPayDetail struct {
// 1 = normal, 2 = installment, 3 = normal + installment
Type string `json:"type"`
Desc string `json:"description"`
MiscFee int64 `json:"misc_fee,omitempty"`
}
// BCAKlikBCADetail : Represent BCA KlikBCA detail
type BCAKlikBCADetail struct {
Desc string `json:"description"`
UserID string `json:"user_id"`
}
// MandiriClickPayDetail : Represent Mandiri ClickPay detail
type MandiriClickPayDetail struct {
CardNumber string `json:"card_number"`
Input1 string `json:"input1"`
Input2 string `json:"input2"`
Input3 string `json:"input3"`
Token string `json:"token"`
}
// CIMBClicksDetail : Represent CIMB Clicks detail
type CIMBClicksDetail struct {
Desc string `json:"description"`
}
// TelkomselCashDetail : Represent Telkomsel Cash detail
type TelkomselCashDetail struct {
Promo bool `json:"promo"`
IsReversal int8 `json:"is_reversal"`
Customer string `json:"customer"`
}
// IndosatDompetkuDetail : Represent Indosat Dompetku detail
type IndosatDompetkuDetail struct {
MSISDN string `json:"msisdn"`
}
// MandiriEcashDetail : Represent Mandiri e-Cash detail
type MandiriEcashDetail struct {
Desc string `json:"description"`
}
// ConvStoreDetail : Represent cstore detail
type ConvStoreDetail struct {
Store string `json:"store"`
Message string `json:"message"`
}
// GopayDetail: Represent gopay detail
type GopayDetail struct {
EnableCallback bool `json:"enable_callback"`
CallbackUrl string `json:"callback_url"`
}
// ChargeReq : Represent Charge request payload
type ChargeReq struct {
PaymentType PaymentType `json:"payment_type"`
TransactionDetails TransactionDetails `json:"transaction_details"`
CreditCard *CreditCardDetail `json:"credit_card,omitempty"`
BankTransfer *BankTransferDetail `json:"bank_transfer,omitempty"`
MandiriBillBankTransferDetail *MandiriBillBankTransferDetail `json:"echannel,omitempty"`
BCAKlikPay *BCAKlikPayDetail `json:"bca_klikpay,omitempty"`
BCAKlikBCA *BCAKlikBCADetail `json:"bca_klikbca,omitempty"`
MandiriClickPay *MandiriClickPayDetail `json:"mandiri_clickpay,omitempty"`
MandiriEcash *MandiriEcashDetail `json:"mandiri_ecash,omitempty"`
CIMBClicks *CIMBClicksDetail `json:"cimb_clicks,omitempty"`
TelkomselCash *TelkomselCashDetail `json:"telkomsel_cash,omitempty"`
IndosatDompetku *IndosatDompetkuDetail `json:"indosat_dompetku,omitempty"`
CustomerDetail *CustDetail `json:"customer_details,omitempty"`
ConvStore *ConvStoreDetail `json:"cstore,omitempty"`
Gopay *GopayDetail `json:"gopay,omitempty"`
Items *[]ItemDetail `json:"item_details,omitempty"`
CustField1 string `json:"custom_field1,omitempty"`
CustField2 string `json:"custom_field2,omitempty"`
CustField3 string `json:"custom_field3,omitempty"`
}
// SnapReq : Represent SNAP API request payload
type SnapReq struct {
TransactionDetails TransactionDetails `json:"transaction_details"`
EnabledPayments []PaymentType `json:"enabled_payments"`
Items *[]ItemDetail `json:"item_details,omitempty"`
CustomerDetail *CustDetail `json:"customer_details,omitempty"`
Expiry *ExpiryDetail `json:"expiry,omitempty"`
CreditCard *CreditCardDetail `json:"credit_card,omitempty"`
Gopay *GopayDetail `json:"gopay,omitempty"`
CustomField1 string `json:"custom_field1"`
CustomField2 string `json:"custom_field2"`
CustomField3 string `json:"custom_field3"`
}
// CaptureReq : Represent Capture request payload
type CaptureReq struct {
TransactionID string `json:"transaction_id"`
GrossAmt float64 `json:"gross_amount"`
}
// IrisCreatePayoutReq : Represent Create Payout request payload
type IrisCreatePayoutReq struct {
Payouts []IrisCreatePayoutDetailReq `json:"payouts"`
}
type IrisCreatePayoutDetailReq struct {
BeneficiaryName string `json:"beneficiary_name"`
BeneficiaryAccount string `json:"beneficiary_account"`
BeneficiaryBank string `json:"beneficiary_bank"`
BeneficiaryEmail string `json:"beneficiary_email"`
Amount string `json:"amount"`
Notes string `json:"notes"`
}
type IrisApprovePayoutReq struct {
ReferenceNo []string `json:"reference_nos"`
OTP string `json:"otp"`
}
type IrisRejectPayoutReq struct {
ReferenceNo []string `json:"reference_nos"`
RejectReason string `json:"reject_reason"`
}
// RefundReq : Represent Refund request payload
type RefundReq struct {
RefundKey string `json:"refund_key"`
Amount int64 `json:"amount"`
Reason string `json:"reason"`
}