Subversion Repositories SmartDukaan

Rev

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