Subversion Repositories SmartDukaan

Rev

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