Subversion Repositories SmartDukaan

Rev

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