Subversion Repositories SmartDukaan

Rev

Rev 3616 | Rev 3724 | 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'
3709 chandransh 56
    '2020' : 'HDFC Credit Card 3-month EMI'
3274 vikas 57
}
2303 ankur.sing 58
 
680 rajveer 59
struct Attribute{
60
	1:string name,
61
	2:string value
121 ashish 62
}
63
 
420 ashish 64
struct PaymentGateway{
121 ashish 65
	1:i64 id,
680 rajveer 66
	2:string name,
67
	3:string url,
68
	4:i64 addedOn,
69
	5:string aliasName,
70
	6:string responseUrl,
71
	7:string errorUrl,
72
	8:PaymentGatewayStatus status
73
	9:list<Attribute> attributes  // list of all attributes for PG
121 ashish 74
}
75
 
76
struct Payment{
680 rajveer 77
	1:i64 paymentId,  				// trackId for bank, paymentid for us and id for table.
78
	2:i64 gatewayId, 				//payment gateway used
79
	3:string gatewayPaymentId
704 chandransh 80
	4:i64 merchantTxnId,			//merchant transaction id. This will be propagated further to order processing
680 rajveer 81
	5:string gatewayTxnId,			//bank trnasaction id
82
	6:double amount,
83
	7:string gatewayTxnStatus,  	// bank status will be stored here
84
	8:PaymentStatus status,
85
	9:i64 userId,					//The user for which payment has to be processed.This is here to speed up querying.
86
	10:string errorCode,
87
	11:string description,
88
	12:string authCode,
89
	13:string referenceCode,		// given by gateway
90
	14:string sessionId, 			// received from PG 
91
	15:string gatewayTxnDate,
92
	16:list<Attribute> attributes,  	// list of all attributes received from PG
93
	17:i64 initTimestamp,			//statring the payment processing timestamp
94
	18:i64 successTimestamp,		//timestamp when payment is captured
95
	19:i64 errorTimestamp,			// in case, error is received from PG
121 ashish 96
}
97
 
2747 chandransh 98
struct Refund{
99
	1:i64 id,
100
	2:i64 paymentId,
101
    3:i64 gatewayId,
102
    4:i64 orderId,
103
    5:double amount,
104
    6:string gatewayTxnId,
105
    7:i32 attempts,
106
    8:i64 createdAt,
107
    9:i64 processedAt,
108
    10:list<Attribute> attributes
109
}
121 ashish 110
 
111
exception PaymentException{
112
	1:i64 error_code,
113
	2:string message
114
}
115
 
3374 rajveer 116
service PaymentService extends GenericService.GenericService{
680 rajveer 117
	/**
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
	/**
167
	Initialize the payment pipe for a HDFC payment. The URL the user should be redirected to is returned.
3010 chandransh 168
	In case of any processing error, an exception is raised.
2461 chandransh 169
	*/
2689 chandransh 170
	string initializeHdfcPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
171
 
172
	/**
3616 chandransh 173
	Initialize the payment pipe for a HDFC EMI payment. The URL the user should be redirected to is returned.
174
	In case of any processing error, an exception is raised.
175
	*/
176
	string initializeHdfcEmiPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
177
 
178
	/**
2689 chandransh 179
	Create a refund of the given amount corresponding to the given order to be processed through the same
180
	payment gateway which processed the payment for the corresponding transaction.
181
	Returns the id of the newly created Refund.
182
	*/	
3010 chandransh 183
	i64 createRefund(1:i64 orderId, 2:i64 merchantTxnId, 3:double amount) throws (1:PaymentException pe),
184
 
185
	/**
186
	Capture the payment for the given merchant transaction id. It processes the last payment for the given
187
	transaction. If the capture attempt failed, the payment is marked as failed.
188
	*/
189
	bool capturePayment(1:i64 merchantTxnId) throws (1:PaymentException pe)
121 ashish 190
}