forked from veritrans/go-midtrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.go
218 lines (189 loc) · 7.92 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
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,omitempty"`
Phone string `json:"phone"`
Address string `json:"address,omitempty"`
City string `json:"city,omitempty"`
Postcode string `json:"postal_code,omitempty"`
CountryCode string `json:"country_code"`
}
// CustDetail : Represent the customer detail
type CustDetail struct {
// first name
FName string `json:"first_name"`
// last name
LName string `json:"last_name,omitempty"`
Email string `json:"email"`
Phone string `json:"phone"`
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"`
}
// 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"`
}
// 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,omitempty"`
AlfamartFreeText1 string `json:"alfamart_free_text_1,omitempty"`
AlfamartFreeText2 string `json:"alfamart_free_text_2,omitempty"`
AlfamartFreeText3 string `json:"alfamart_free_text_3,omitempty"`
}
type GopayDetail struct {
EnableCallback bool `json:"enable_callback"`
CallbackURL string `json:"callback_url"`
}
// CustomExpiry : Represent Set Custom Expiry Charge Feature
type CustomExpiry struct {
OrderTime string `json:"order_time"`
ExpiryDuration int16 `json:"expiry_duration"`
Unit string `json:"unit"`
}
// 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"`
CustomExpiry *CustomExpiry `json:"custom_expiry,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"`
CreditCard *CreditCardDetail `json:"credit_card,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"`
}