Subversion Repositories SmartDukaan

Rev

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