Subversion Repositories SmartDukaan

Rev

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