Subversion Repositories SmartDukaan

Rev

Rev 3164 | Rev 3274 | 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'
3164 chandransh 52
 }
2303 ankur.sing 53
 
680 rajveer 54
struct Attribute{
55
	1:string name,
56
	2:string value
121 ashish 57
}
58
 
420 ashish 59
struct PaymentGateway{
121 ashish 60
	1:i64 id,
680 rajveer 61
	2:string name,
62
	3:string url,
63
	4:i64 addedOn,
64
	5:string aliasName,
65
	6:string responseUrl,
66
	7:string errorUrl,
67
	8:PaymentGatewayStatus status
68
	9:list<Attribute> attributes  // list of all attributes for PG
121 ashish 69
}
70
 
71
struct Payment{
680 rajveer 72
	1:i64 paymentId,  				// trackId for bank, paymentid for us and id for table.
73
	2:i64 gatewayId, 				//payment gateway used
74
	3:string gatewayPaymentId
704 chandransh 75
	4:i64 merchantTxnId,			//merchant transaction id. This will be propagated further to order processing
680 rajveer 76
	5:string gatewayTxnId,			//bank trnasaction id
77
	6:double amount,
78
	7:string gatewayTxnStatus,  	// bank status will be stored here
79
	8:PaymentStatus status,
80
	9:i64 userId,					//The user for which payment has to be processed.This is here to speed up querying.
81
	10:string errorCode,
82
	11:string description,
83
	12:string authCode,
84
	13:string referenceCode,		// given by gateway
85
	14:string sessionId, 			// received from PG 
86
	15:string gatewayTxnDate,
87
	16:list<Attribute> attributes,  	// list of all attributes received from PG
88
	17:i64 initTimestamp,			//statring the payment processing timestamp
89
	18:i64 successTimestamp,		//timestamp when payment is captured
90
	19:i64 errorTimestamp,			// in case, error is received from PG
121 ashish 91
}
92
 
2747 chandransh 93
struct Refund{
94
	1:i64 id,
95
	2:i64 paymentId,
96
    3:i64 gatewayId,
97
    4:i64 orderId,
98
    5:double amount,
99
    6:string gatewayTxnId,
100
    7:i32 attempts,
101
    8:i64 createdAt,
102
    9:i64 processedAt,
103
    10:list<Attribute> attributes
104
}
121 ashish 105
 
106
exception PaymentException{
107
	1:i64 error_code,
108
	2:string message
109
}
110
 
111
service PaymentService{
680 rajveer 112
	/**
763 rajveer 113
	* For closing the open session in sqlalchemy
114
	*/
115
	void closeSession(),
116
 
117
	/**
680 rajveer 118
	*	create a new payment and return payment id, throws an exception if gateway is not active
119
	**/
120
	i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
121 ashish 121
 
680 rajveer 122
	/**
123
	* get payment for user. If status and gateway are null, it is ignored. Same for times as well.
124
	**/ 
125
	list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 126
 
680 rajveer 127
	/**
2059 ankur.sing 128
	* get all payments for user. If gatewayId is 0, then it is ignored while filtering.
680 rajveer 129
	**/ 
130
	list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 131
 
132
 
680 rajveer 133
	/** 
134
	* Get a particular gateway
135
	**/
136
	PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
137
 
138
	/** 
139
	* Get a particular payment info
140
	**/
420 ashish 141
	Payment getPayment(1:i64 id) throws (1:PaymentException pe),
680 rajveer 142
 
143
 
144
	/** 
145
	* Get a particular payment for a transaction. Will raise exception.
146
	**/
147
	list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
121 ashish 148
 
680 rajveer 149
	/**
150
	* mark payment successful and store parameters
151
	**/
1118 rajveer 152
	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 153
 
680 rajveer 154
	/**
155
	* mark payment failed and store parameters
694 rajveer 156
 
680 rajveer 157
	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 158
	*/
1731 ankur.sing 159
 
1628 ankur.sing 160
	/**
1731 ankur.sing 161
	Returns the minimum and maximum amounts among successful payments.
162
	List contains two double values, first minimum and second maximum amount.
1628 ankur.sing 163
	*/
2461 chandransh 164
	list<double> getSuccessfulPaymentsAmountRange(),
165
 
166
	/**
2708 chandransh 167
	Captures an already authorized EBS Payment and returns a map containing the details of the captured transaction
2461 chandransh 168
	*/
2708 chandransh 169
	map<string, string> captureEbsPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
170
 
171
	/**
172
	Captures an already authorized Hdfc Payment and returns a map containing the details of the captured transaction
173
	*/
2461 chandransh 174
	map<string, string> captureHdfcPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
175
 
176
	/**
177
	Initialize the payment pipe for a HDFC payment. The URL the user should be redirected to is returned.
3010 chandransh 178
	In case of any processing error, an exception is raised.
2461 chandransh 179
	*/
2689 chandransh 180
	string initializeHdfcPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
181
 
182
	/**
183
	Create a refund of the given amount corresponding to the given order to be processed through the same
184
	payment gateway which processed the payment for the corresponding transaction.
185
	Returns the id of the newly created Refund.
186
	*/	
3010 chandransh 187
	i64 createRefund(1:i64 orderId, 2:i64 merchantTxnId, 3:double amount) throws (1:PaymentException pe),
188
 
189
	/**
190
	Capture the payment for the given merchant transaction id. It processes the last payment for the given
191
	transaction. If the capture attempt failed, the payment is marked as failed.
192
	*/
193
	bool capturePayment(1:i64 merchantTxnId) throws (1:PaymentException pe)
121 ashish 194
}