Subversion Repositories SmartDukaan

Rev

Rev 17782 | Rev 18578 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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