| 121 |
ashish |
1 |
namespace java in.shop2020.payments
|
| 420 |
ashish |
2 |
namespace py shop2020.thriftpy.payments
|
| 121 |
ashish |
3 |
|
| 3374 |
rajveer |
4 |
include "GenericService.thrift"
|
|
|
5 |
|
| 121 |
ashish |
6 |
/**
|
|
|
7 |
Various structures
|
|
|
8 |
**/
|
|
|
9 |
enum PaymentGatewayStatus{
|
|
|
10 |
AVAILABLE,
|
|
|
11 |
BLOCKED
|
|
|
12 |
}
|
|
|
13 |
|
|
|
14 |
enum PaymentStatus{
|
|
|
15 |
INIT,
|
|
|
16 |
PENDING,
|
| 1854 |
chandransh |
17 |
SUCCESS, // HDFC Status: CAPTURED; EBS Status: Captured
|
|
|
18 |
FAILED, // HDFC status: NOT CAPTURED, DENIED BY RISK, HOST TIMEOUT, CANCELLED
|
| 3956 |
chandransh |
19 |
AUTHORIZED, // EBS Status: Pending, HDFC Status: APPROVED
|
| 4421 |
mandeep.dh |
20 |
PARTIALLY_CAPTURED, //In case of COD
|
|
|
21 |
CAPTURE_IN_PROCESS, // In case first few attempts to capture failed due to transient connections issues
|
| 6482 |
rajveer |
22 |
PROVISIONALLY_CAPTURED, // In case payment is not getting
|
|
|
23 |
REFUNDED
|
| 121 |
ashish |
24 |
}
|
|
|
25 |
|
| 3270 |
vikas |
26 |
// If new paymethod is added here, sales database for pentaho must also be updated.
|
| 2303 |
ankur.sing |
27 |
const map<string,string> PAYMENT_METHOD = {
|
|
|
28 |
'1001' : 'EBS-TEST Payment'
|
|
|
29 |
'1004' : 'EBS-AXIS Bank Account'
|
|
|
30 |
'1007' : 'EBS-HDFC Bank Account'
|
|
|
31 |
'1008' : 'EBS-VISA'
|
|
|
32 |
'1009' : 'EBS-Citi Bank Debit Card'
|
|
|
33 |
'1010' : 'EBS-Diners Club'
|
|
|
34 |
'1012' : 'EBS-ItzCash'
|
|
|
35 |
'1015' : 'EBS-JK Bank Account'
|
|
|
36 |
'1016' : 'EBS-ICICI Bank Account'
|
|
|
37 |
'1017' : 'EBS-MasterCard'
|
|
|
38 |
'1029' : 'EBS-Federal Bank Account'
|
|
|
39 |
'1032' : 'EBS-State Bank of India Netbanking'
|
|
|
40 |
'1033' : 'EBS-State Bank of Bikaner and Jaipur Netbanking'
|
|
|
41 |
'1034' : 'EBS-State Bank of Hyderabad Netbanking'
|
|
|
42 |
'1035' : 'EBS-State Bank of Patiala Netbanking'
|
|
|
43 |
'1036' : 'EBS-State Bank of Shaurashtra Netbanking'
|
|
|
44 |
'1037' : 'EBS-State Bank of Indore Netbanking'
|
|
|
45 |
'1038' : 'EBS-State Bank of Mysore Netbanking'
|
|
|
46 |
'1039' : 'EBS-State Bank of Travancore Netbanking'
|
| 8274 |
amit.gupta |
47 |
'1040' : 'EBS-Citi Bank Reward Point',
|
|
|
48 |
'1154' : 'EBS-ORIENTAL BANK OF COMMERCE Netbanking',
|
|
|
49 |
'1210' : 'ING VYSYA BANK Netbanking',
|
|
|
50 |
'1224' : 'CANARA BANK Netbanking'
|
| 2303 |
ankur.sing |
51 |
'1127' : 'EBS-Citi Bank Account'
|
|
|
52 |
'1132' : 'EBS-Done Card'
|
| 2574 |
chandransh |
53 |
'1133' : 'EBS-Karnataka Bank Account'
|
|
|
54 |
'1134' : 'EBS-ICash'
|
|
|
55 |
'1135' : 'EBS-Corporation Bank Account'
|
| 7781 |
amit.gupta |
56 |
'1212' : 'United Bank of India'
|
|
|
57 |
'1213' : 'Indian Overseas Bank'
|
|
|
58 |
'1214' : 'Bank of India'
|
|
|
59 |
'1215' : 'Citi Union Bank'
|
|
|
60 |
'1216' : 'Union Bank of India'
|
| 10040 |
amit.gupta |
61 |
'1273' : 'Dhanalaxmi Bank'
|
| 2574 |
chandransh |
62 |
'2000' : 'HDFC-VISA/VISA Electron Debit Card'
|
| 2461 |
chandransh |
63 |
'2008' : 'HDFC-VISA'
|
| 5538 |
anupam.sin |
64 |
'2017' : 'HDFC-MasterCard Credit Card'
|
|
|
65 |
'2018' : 'HDFC-MasterCard Debit Card'
|
| 3164 |
chandransh |
66 |
'3000' : 'COD'
|
| 8907 |
rajveer |
67 |
'3001' : 'Coupon'
|
| 3270 |
vikas |
68 |
'2001' : 'Cheque'
|
| 3274 |
vikas |
69 |
'1026' : 'EBS-ICICI Bank Debit Card'
|
|
|
70 |
'1027' : 'EBS-SBI Debit Card'
|
| 3709 |
chandransh |
71 |
'2020' : 'HDFC Credit Card 3-month EMI'
|
| 6459 |
rajveer |
72 |
'5001' : 'HDFC Credit Card 3-month EMI'
|
|
|
73 |
'5002' : 'HDFC Credit Card 6-month EMI'
|
|
|
74 |
'5003' : 'HDFC Credit Card 9-month EMI'
|
|
|
75 |
'5004' : 'HDFC Credit Card 12-month EMI'
|
| 7330 |
amit.gupta |
76 |
'5005' : 'HDFC Credit Card 18-month EMI'
|
| 6978 |
amit.gupta |
77 |
'1139' : 'Citi EBS-VISA Credit Card 3-months EMI'
|
|
|
78 |
'1140' : 'Citi EBS-MasterCard Credit Card 3-months EMI'
|
|
|
79 |
'1141' : 'Citi EBS-VISA Credit Card 6-months EMI'
|
|
|
80 |
'1142' : 'Citi EBS-MasterCard Credit Card 6-months EMI'
|
| 5102 |
phani.kuma |
81 |
'1143' : 'EBS-Indian Bank Netbanking'
|
|
|
82 |
'1164' : 'EBS-Maestro Debit Card'
|
| 6978 |
amit.gupta |
83 |
'4000' : 'BULK',
|
| 13421 |
amit.gupta |
84 |
'4001' : 'PAYU MONEY',
|
| 6978 |
amit.gupta |
85 |
'210000':'Axis Bank Innoviti 3 Months EMI',
|
|
|
86 |
'220000':'Axis Bank Innoviti 6 Months EMI',
|
|
|
87 |
'230000':'Axis Bank Innoviti 9 Months EMI',
|
|
|
88 |
'240000':'Axis Bank Innoviti 12 Months EMI',
|
|
|
89 |
'250000':'Axis Bank Innoviti 18 Months EMI',
|
|
|
90 |
'310000':'ICICI Bank Innoviti 3 Months EMI',
|
|
|
91 |
'320000':'ICICI Bank Innoviti 6 Months EMI',
|
|
|
92 |
'330000':'ICICI Bank Innoviti 9 Months EMI',
|
|
|
93 |
'340000':'ICICI Bank Innoviti 12 Months EMI',
|
|
|
94 |
'350000':'ICICI Bank Innoviti 18 Months EMI',
|
|
|
95 |
'410000':'InsdusInd Bank Innoviti 3 Months EMI',
|
|
|
96 |
'420000':'InsdusInd Bank Innoviti 6 Months EMI',
|
|
|
97 |
'430000':'InsdusInd Bank Innoviti 9 Months EMI',
|
|
|
98 |
'440000':'InsdusInd Bank Innoviti 12 Months EMI',
|
| 9506 |
amit.gupta |
99 |
'510000':'Citi Bank Innoviti 3 Months EMI',
|
|
|
100 |
'520000':'Citi Bank Innoviti 6 Months EMI',
|
|
|
101 |
'530000':'Citi Bank Innoviti 9 Months EMI',
|
|
|
102 |
'540000':'Citi Bank Innoviti 12 Months EMI',
|
| 6978 |
amit.gupta |
103 |
'610000':'Standard Chartered Bank Innoviti 3 Months EMI',
|
|
|
104 |
'620000':'Standard Chartered Bank Innoviti 6 Months EMI',
|
|
|
105 |
'630000':'Standard Chartered Bank Innoviti 9 Months EMI',
|
|
|
106 |
'640000':'Standard Chartered Bank Innoviti 12 Months EMI',
|
|
|
107 |
'710000':'HSBC Bank Innoviti 3 Months EMI',
|
|
|
108 |
'720000':'HSBC Bank Innoviti 6 Months EMI',
|
| 7948 |
amit.gupta |
109 |
'730000':'HSBC Bank Innoviti 6 Months EMI',
|
|
|
110 |
'740000':'HSBC Bank Innoviti 6 Months EMI',
|
| 6978 |
amit.gupta |
111 |
'810000':'Kotak Mahindra Bank Innoviti 3 Months EMI',
|
|
|
112 |
'820000':'Kotak Mahindra Bank Innoviti 6 Months EMI',
|
|
|
113 |
'830000':'Kotak Mahindra Bank Innoviti 9 Months EMI',
|
|
|
114 |
'840000':'Kotak Mahindra Bank Innoviti 12 Months EMI',
|
|
|
115 |
'910000':'SBI Bank Innoviti 3 Months EMI',
|
|
|
116 |
'920000':'SBI Bank Innoviti 6 Months EMI',
|
|
|
117 |
'930000':'SBI Bank Innoviti 9 Months EMI',
|
|
|
118 |
'940000':'SBI Bank Innoviti 12 Months EMI',
|
|
|
119 |
'950000':'SBI Bank Innoviti 18 Months EMI'
|
| 3274 |
vikas |
120 |
}
|
| 2303 |
ankur.sing |
121 |
|
| 680 |
rajveer |
122 |
struct Attribute{
|
|
|
123 |
1:string name,
|
|
|
124 |
2:string value
|
| 121 |
ashish |
125 |
}
|
|
|
126 |
|
| 420 |
ashish |
127 |
struct PaymentGateway{
|
| 121 |
ashish |
128 |
1:i64 id,
|
| 680 |
rajveer |
129 |
2:string name,
|
|
|
130 |
3:string url,
|
|
|
131 |
4:i64 addedOn,
|
|
|
132 |
5:string aliasName,
|
|
|
133 |
6:string responseUrl,
|
|
|
134 |
7:string errorUrl,
|
|
|
135 |
8:PaymentGatewayStatus status
|
|
|
136 |
9:list<Attribute> attributes // list of all attributes for PG
|
| 121 |
ashish |
137 |
}
|
|
|
138 |
|
|
|
139 |
struct Payment{
|
| 680 |
rajveer |
140 |
1:i64 paymentId, // trackId for bank, paymentid for us and id for table.
|
|
|
141 |
2:i64 gatewayId, //payment gateway used
|
|
|
142 |
3:string gatewayPaymentId
|
| 704 |
chandransh |
143 |
4:i64 merchantTxnId, //merchant transaction id. This will be propagated further to order processing
|
| 680 |
rajveer |
144 |
5:string gatewayTxnId, //bank trnasaction id
|
|
|
145 |
6:double amount,
|
|
|
146 |
7:string gatewayTxnStatus, // bank status will be stored here
|
|
|
147 |
8:PaymentStatus status,
|
|
|
148 |
9:i64 userId, //The user for which payment has to be processed.This is here to speed up querying.
|
|
|
149 |
10:string errorCode,
|
|
|
150 |
11:string description,
|
|
|
151 |
12:string authCode,
|
|
|
152 |
13:string referenceCode, // given by gateway
|
|
|
153 |
14:string sessionId, // received from PG
|
|
|
154 |
15:string gatewayTxnDate,
|
|
|
155 |
16:list<Attribute> attributes, // list of all attributes received from PG
|
|
|
156 |
17:i64 initTimestamp, //statring the payment processing timestamp
|
|
|
157 |
18:i64 successTimestamp, //timestamp when payment is captured
|
|
|
158 |
19:i64 errorTimestamp, // in case, error is received from PG
|
| 6050 |
anupam.sin |
159 |
20:i64 provisionalCaptureTimestamp, // in case, error is received from PG
|
| 6503 |
rajveer |
160 |
21:bool isDigital,
|
|
|
161 |
22:double refundAmount
|
| 121 |
ashish |
162 |
}
|
|
|
163 |
|
| 2747 |
chandransh |
164 |
struct Refund{
|
|
|
165 |
1:i64 id,
|
|
|
166 |
2:i64 paymentId,
|
|
|
167 |
3:i64 gatewayId,
|
|
|
168 |
4:i64 orderId,
|
|
|
169 |
5:double amount,
|
|
|
170 |
6:string gatewayTxnId,
|
|
|
171 |
7:i32 attempts,
|
|
|
172 |
8:i64 createdAt,
|
|
|
173 |
9:i64 processedAt,
|
|
|
174 |
10:list<Attribute> attributes
|
|
|
175 |
}
|
| 121 |
ashish |
176 |
|
|
|
177 |
exception PaymentException{
|
|
|
178 |
1:i64 error_code,
|
|
|
179 |
2:string message
|
|
|
180 |
}
|
|
|
181 |
|
| 4008 |
mandeep.dh |
182 |
enum ExtraPaymentProcessingType {
|
| 4421 |
mandeep.dh |
183 |
FAILED_PAYMENTS,
|
|
|
184 |
PENDING_CAPTURE
|
| 4008 |
mandeep.dh |
185 |
}
|
|
|
186 |
|
| 3374 |
rajveer |
187 |
service PaymentService extends GenericService.GenericService{
|
| 680 |
rajveer |
188 |
/**
|
| 4141 |
chandransh |
189 |
create a new payment and return payment id, throws an exception if gateway is not active
|
|
|
190 |
*/
|
| 6050 |
anupam.sin |
191 |
i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId, 5:bool isDigital) throws (1:PaymentException pe),
|
| 121 |
ashish |
192 |
|
| 680 |
rajveer |
193 |
/**
|
| 4141 |
chandransh |
194 |
Get all payments for user. If status and gateway are null, they are ignored. Same for times as well.
|
|
|
195 |
*/
|
| 680 |
rajveer |
196 |
list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
197 |
|
| 680 |
rajveer |
198 |
/**
|
| 4141 |
chandransh |
199 |
Get all payments in the given status for the given gateway. If gatewayId is 0, then it is ignored.
|
|
|
200 |
*/
|
| 680 |
rajveer |
201 |
list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
202 |
|
| 4141 |
chandransh |
203 |
/**
|
|
|
204 |
Get all payments for the given gateway which were captured between the given dates. If the gatewayId is 0, it's ignored.
|
|
|
205 |
*/
|
|
|
206 |
list<Payment> getPaymentsByCapturedDate(1:i64 fromTime, 2:i64 toTime, 3:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
207 |
|
| 680 |
rajveer |
208 |
/**
|
| 4141 |
chandransh |
209 |
Get the gateway for the given id.
|
|
|
210 |
*/
|
| 680 |
rajveer |
211 |
PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
|
| 4600 |
varun.gupt |
212 |
|
|
|
213 |
/**
|
|
|
214 |
*Get all active Payment Gateways
|
|
|
215 |
**/
|
|
|
216 |
list<PaymentGateway> getActivePaymentGateways() throws (1:PaymentException pe),
|
|
|
217 |
|
| 680 |
rajveer |
218 |
/**
|
|
|
219 |
* Get a particular payment info
|
|
|
220 |
**/
|
| 420 |
ashish |
221 |
Payment getPayment(1:i64 id) throws (1:PaymentException pe),
|
| 680 |
rajveer |
222 |
|
|
|
223 |
|
|
|
224 |
/**
|
| 4600 |
varun.gupt |
225 |
* Get payments for a transaction. Will raise exception.
|
| 680 |
rajveer |
226 |
**/
|
|
|
227 |
list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
| 121 |
ashish |
228 |
|
| 4600 |
varun.gupt |
229 |
/**
|
| 7049 |
anupam.sin |
230 |
* Get payments for a recharge transaction id. Will raise exception.
|
|
|
231 |
**/
|
|
|
232 |
list<Payment> getPaymentForRechargeTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
|
|
233 |
|
|
|
234 |
/**
|
| 4600 |
varun.gupt |
235 |
* Get successful payment for a transaction. Will raise exception.
|
|
|
236 |
**/
|
|
|
237 |
Payment getSuccessfulPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
|
|
238 |
|
| 680 |
rajveer |
239 |
/**
|
|
|
240 |
* mark payment successful and store parameters
|
|
|
241 |
**/
|
| 1118 |
rajveer |
242 |
bool updatePaymentDetails(1:i64 id, 2:string gatewayPaymentId, 3:string sessionId, 4:string gatewayTxnStatus, 5:string description, 6:string gatewayTxnId, 7:string authCode, 8:string referenceCode, 9:string errorCode, 10:PaymentStatus status, 11:string gatewayTxnDate, 12:list<Attribute> attributes) throws (1:PaymentException pe),
|
| 420 |
ashish |
243 |
|
| 680 |
rajveer |
244 |
/**
|
|
|
245 |
* mark payment failed and store parameters
|
| 694 |
rajveer |
246 |
|
| 680 |
rajveer |
247 |
bool markPaymentFailed(1:i64 id, 2:string gatewayPaymentId, 3:string sessionId, 4:string gatewayTxnStatus, 5:string description, 6:string errorCode, 7:list<Attribute> attributes ) throws (1:PaymentException pe)
|
| 694 |
rajveer |
248 |
*/
|
| 1731 |
ankur.sing |
249 |
|
| 1628 |
ankur.sing |
250 |
/**
|
| 1731 |
ankur.sing |
251 |
Returns the minimum and maximum amounts among successful payments.
|
|
|
252 |
List contains two double values, first minimum and second maximum amount.
|
| 1628 |
ankur.sing |
253 |
*/
|
| 2461 |
chandransh |
254 |
list<double> getSuccessfulPaymentsAmountRange(),
|
|
|
255 |
|
|
|
256 |
/**
|
|
|
257 |
Initialize the payment pipe for a HDFC payment. The URL the user should be redirected to is returned.
|
| 3010 |
chandransh |
258 |
In case of any processing error, an exception is raised.
|
| 2461 |
chandransh |
259 |
*/
|
| 10269 |
amit.gupta |
260 |
string initializeHdfcPayment(1:i64 merchantPaymentId, 2:bool isMobile) throws (1:PaymentException pe),
|
| 2689 |
chandransh |
261 |
|
|
|
262 |
/**
|
| 6050 |
anupam.sin |
263 |
Initialize the payment pipe for a HDFC payment in case of a digital order. The URL the user should be redirected to is returned.
|
| 6228 |
anupam.sin |
264 |
In case of any processing error, an exception is raised. The phone is a madatory field and is required in case of dth payments.
|
| 6050 |
anupam.sin |
265 |
*/
|
| 10269 |
amit.gupta |
266 |
string doHdfcPaymentForDigitalOrder(1:i64 merchantPaymentId, 2:i64 rechargeOrderId, 3:string phone, 4:bool isMobile) throws (1:PaymentException pe),
|
| 6050 |
anupam.sin |
267 |
|
|
|
268 |
/**
|
| 3616 |
chandransh |
269 |
Initialize the payment pipe for a HDFC EMI payment. The URL the user should be redirected to is returned.
|
|
|
270 |
In case of any processing error, an exception is raised.
|
|
|
271 |
*/
|
| 10269 |
amit.gupta |
272 |
string initializeHdfcEmiPayment(1:i64 merchantPaymentId, 2:bool isMobile) throws (1:PaymentException pe),
|
| 3616 |
chandransh |
273 |
|
|
|
274 |
/**
|
| 2689 |
chandransh |
275 |
Create a refund of the given amount corresponding to the given order to be processed through the same
|
|
|
276 |
payment gateway which processed the payment for the corresponding transaction.
|
|
|
277 |
Returns the id of the newly created Refund.
|
|
|
278 |
*/
|
| 3010 |
chandransh |
279 |
i64 createRefund(1:i64 orderId, 2:i64 merchantTxnId, 3:double amount) throws (1:PaymentException pe),
|
|
|
280 |
|
|
|
281 |
/**
|
|
|
282 |
Capture the payment for the given merchant transaction id. It processes the last payment for the given
|
| 4421 |
mandeep.dh |
283 |
transaction. If the capture attempt failed, the payment is marked as failed. PaymentException with error
|
| 6486 |
rajveer |
284 |
code 104 is thrown in case no payments are found for the transaction id passed. PaymentException is also
|
|
|
285 |
thrown with error code 106 in case capture was not possible due to connection
|
|
|
286 |
issue.
|
|
|
287 |
*/
|
| 8907 |
rajveer |
288 |
bool capturePayment(1:i64 merchantTxnId, 2:bool isDigital) throws (1:PaymentException pe),
|
| 6486 |
rajveer |
289 |
|
|
|
290 |
/**
|
|
|
291 |
Refund the payment for the given merchant transaction id. It processes the last payment for the given
|
| 6503 |
rajveer |
292 |
transaction. If refund will be failed nothing will be updated in database.
|
| 3010 |
chandransh |
293 |
*/
|
| 6486 |
rajveer |
294 |
bool refundPayment(1:i64 merchantTxnId, 2:double amount, 3:bool isDigital) throws (1:PaymentException pe),
|
| 3956 |
chandransh |
295 |
|
| 6486 |
rajveer |
296 |
|
| 3956 |
chandransh |
297 |
/**
|
|
|
298 |
Adds the given amount to the captured amount of a COD payment.
|
|
|
299 |
Updates the captured amount for the corresponding payment and marks it as PARTIALLY CAPTURED.
|
|
|
300 |
If the captured amount becomes equal to total amount, then the payment status is set as SUCCESS.
|
|
|
301 |
Also sets the name of the entity which transferred the money, the date on which it was transferred
|
|
|
302 |
and the corresponding transaction id.
|
|
|
303 |
|
|
|
304 |
Returns false if the payment couldn't be captured.
|
|
|
305 |
Throws exception if no such payment could be found or if the captured amount will exceed the total amount after capturing.
|
|
|
306 |
*/
|
| 4008 |
mandeep.dh |
307 |
bool partiallyCapturePayment(1:i64 merchantTxnId, 2:double amount, 3:string xferBy, 4:string xferTxnId, 5:i64 xferDate) throws (1:PaymentException pe),
|
|
|
308 |
|
|
|
309 |
/**
|
|
|
310 |
* Returns the list of payments that require some extra processing and
|
|
|
311 |
* which belong to a particular category. This is currently used by CRM
|
|
|
312 |
* application.
|
|
|
313 |
*/
|
|
|
314 |
list<i64> getPaymentsRequiringExtraProcessing(1:ExtraPaymentProcessingType category),
|
|
|
315 |
|
|
|
316 |
/**
|
|
|
317 |
* Marks a particular payment as processed for a particular cateogory.
|
|
|
318 |
* It essentially deletes the payment if it is processed for a particular
|
|
|
319 |
* category. This is currently used by CRM application.
|
|
|
320 |
*/
|
| 8907 |
rajveer |
321 |
void markPaymentAsProcessed(1:i64 paymentId, 2:ExtraPaymentProcessingType category),
|
|
|
322 |
|
| 8914 |
rajveer |
323 |
PaymentStatus getPaymentStatusAtGateway(1:i64 merchantTxnId, 2:double amount, 3:bool isDigital) throws (1:PaymentException pe)
|
| 121 |
ashish |
324 |
}
|