Subversion Repositories SmartDukaan

Rev

Rev 3709 | Rev 3956 | 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
19
	AUTHORIZED  // EBS Status: Pending
121 ashish 20
}
21
 
3270 vikas 22
// If new paymethod is added here, sales database for pentaho must also be updated.
2303 ankur.sing 23
const map<string,string> PAYMENT_METHOD = {
24
	'1001' : 'EBS-TEST Payment'
25
	'1004' : 'EBS-AXIS Bank Account'
26
	'1007' : 'EBS-HDFC Bank Account'
27
	'1008' : 'EBS-VISA'
28
	'1009' : 'EBS-Citi Bank Debit Card'
29
	'1010' : 'EBS-Diners Club'
30
	'1012' : 'EBS-ItzCash'
31
	'1015' : 'EBS-JK Bank Account'
32
	'1016' : 'EBS-ICICI Bank Account'
33
	'1017' : 'EBS-MasterCard'
34
	'1029' : 'EBS-Federal Bank Account'
35
	'1032' : 'EBS-State Bank of India Netbanking'
36
	'1033' : 'EBS-State Bank of Bikaner and Jaipur Netbanking'
37
	'1034' : 'EBS-State Bank of Hyderabad Netbanking'
38
	'1035' : 'EBS-State Bank of Patiala Netbanking'
39
	'1036' : 'EBS-State Bank of Shaurashtra Netbanking'
40
	'1037' : 'EBS-State Bank of Indore Netbanking'
41
	'1038' : 'EBS-State Bank of Mysore Netbanking'
42
	'1039' : 'EBS-State Bank of Travancore Netbanking'
43
	'1040' : 'EBS-Citi Bank Reward Point'
44
	'1127' : 'EBS-Citi Bank Account'
45
	'1132' : 'EBS-Done Card'
2574 chandransh 46
	'1133' : 'EBS-Karnataka Bank Account'
47
	'1134' : 'EBS-ICash'
48
	'1135' : 'EBS-Corporation Bank Account'
49
 	'2000' : 'HDFC-VISA/VISA Electron Debit Card'
2461 chandransh 50
	'2008' : 'HDFC-VISA'
51
	'2017' : 'HDFC-MasterCard'
3164 chandransh 52
	'3000' : 'COD'
3270 vikas 53
	'2001' : 'Cheque'
3274 vikas 54
	'1026' : 'EBS-ICICI Bank Debit Card'
55
    '1027' : 'EBS-SBI Debit Card'
3709 chandransh 56
    '2020' : 'HDFC Credit Card 3-month EMI'
3724 vikas 57
    '4000' : 'BULK'
3274 vikas 58
}
2303 ankur.sing 59
 
680 rajveer 60
struct Attribute{
61
	1:string name,
62
	2:string value
121 ashish 63
}
64
 
420 ashish 65
struct PaymentGateway{
121 ashish 66
	1:i64 id,
680 rajveer 67
	2:string name,
68
	3:string url,
69
	4:i64 addedOn,
70
	5:string aliasName,
71
	6:string responseUrl,
72
	7:string errorUrl,
73
	8:PaymentGatewayStatus status
74
	9:list<Attribute> attributes  // list of all attributes for PG
121 ashish 75
}
76
 
77
struct Payment{
680 rajveer 78
	1:i64 paymentId,  				// trackId for bank, paymentid for us and id for table.
79
	2:i64 gatewayId, 				//payment gateway used
80
	3:string gatewayPaymentId
704 chandransh 81
	4:i64 merchantTxnId,			//merchant transaction id. This will be propagated further to order processing
680 rajveer 82
	5:string gatewayTxnId,			//bank trnasaction id
83
	6:double amount,
84
	7:string gatewayTxnStatus,  	// bank status will be stored here
85
	8:PaymentStatus status,
86
	9:i64 userId,					//The user for which payment has to be processed.This is here to speed up querying.
87
	10:string errorCode,
88
	11:string description,
89
	12:string authCode,
90
	13:string referenceCode,		// given by gateway
91
	14:string sessionId, 			// received from PG 
92
	15:string gatewayTxnDate,
93
	16:list<Attribute> attributes,  	// list of all attributes received from PG
94
	17:i64 initTimestamp,			//statring the payment processing timestamp
95
	18:i64 successTimestamp,		//timestamp when payment is captured
96
	19:i64 errorTimestamp,			// in case, error is received from PG
121 ashish 97
}
98
 
2747 chandransh 99
struct Refund{
100
	1:i64 id,
101
	2:i64 paymentId,
102
    3:i64 gatewayId,
103
    4:i64 orderId,
104
    5:double amount,
105
    6:string gatewayTxnId,
106
    7:i32 attempts,
107
    8:i64 createdAt,
108
    9:i64 processedAt,
109
    10:list<Attribute> attributes
110
}
121 ashish 111
 
112
exception PaymentException{
113
	1:i64 error_code,
114
	2:string message
115
}
116
 
3374 rajveer 117
service PaymentService extends GenericService.GenericService{
680 rajveer 118
	/**
119
	*	create a new payment and return payment id, throws an exception if gateway is not active
120
	**/
121
	i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
121 ashish 122
 
680 rajveer 123
	/**
124
	* get payment for user. If status and gateway are null, it is ignored. Same for times as well.
125
	**/ 
126
	list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 127
 
680 rajveer 128
	/**
2059 ankur.sing 129
	* get all payments for user. If gatewayId is 0, then it is ignored while filtering.
680 rajveer 130
	**/ 
131
	list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 132
 
133
 
680 rajveer 134
	/** 
135
	* Get a particular gateway
136
	**/
137
	PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
138
 
139
	/** 
140
	* Get a particular payment info
141
	**/
420 ashish 142
	Payment getPayment(1:i64 id) throws (1:PaymentException pe),
680 rajveer 143
 
144
 
145
	/** 
146
	* Get a particular payment for a transaction. Will raise exception.
147
	**/
148
	list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
121 ashish 149
 
680 rajveer 150
	/**
151
	* mark payment successful and store parameters
152
	**/
1118 rajveer 153
	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 154
 
680 rajveer 155
	/**
156
	* mark payment failed and store parameters
694 rajveer 157
 
680 rajveer 158
	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 159
	*/
1731 ankur.sing 160
 
1628 ankur.sing 161
	/**
1731 ankur.sing 162
	Returns the minimum and maximum amounts among successful payments.
163
	List contains two double values, first minimum and second maximum amount.
1628 ankur.sing 164
	*/
2461 chandransh 165
	list<double> getSuccessfulPaymentsAmountRange(),
166
 
167
	/**
168
	Initialize the payment pipe for a HDFC payment. The URL the user should be redirected to is returned.
3010 chandransh 169
	In case of any processing error, an exception is raised.
2461 chandransh 170
	*/
2689 chandransh 171
	string initializeHdfcPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
172
 
173
	/**
3616 chandransh 174
	Initialize the payment pipe for a HDFC EMI payment. The URL the user should be redirected to is returned.
175
	In case of any processing error, an exception is raised.
176
	*/
177
	string initializeHdfcEmiPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
178
 
179
	/**
2689 chandransh 180
	Create a refund of the given amount corresponding to the given order to be processed through the same
181
	payment gateway which processed the payment for the corresponding transaction.
182
	Returns the id of the newly created Refund.
183
	*/	
3010 chandransh 184
	i64 createRefund(1:i64 orderId, 2:i64 merchantTxnId, 3:double amount) throws (1:PaymentException pe),
185
 
186
	/**
187
	Capture the payment for the given merchant transaction id. It processes the last payment for the given
188
	transaction. If the capture attempt failed, the payment is marked as failed.
189
	*/
190
	bool capturePayment(1:i64 merchantTxnId) throws (1:PaymentException pe)
121 ashish 191
}