Subversion Repositories SmartDukaan

Rev

Rev 3956 | Rev 4141 | 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
3956 chandransh 19
	AUTHORIZED,  // EBS Status: Pending, HDFC Status: APPROVED
20
	PARTIALLY_CAPTURED //In case of COD
121 ashish 21
}
22
 
3270 vikas 23
// If new paymethod is added here, sales database for pentaho must also be updated.
2303 ankur.sing 24
const map<string,string> PAYMENT_METHOD = {
25
	'1001' : 'EBS-TEST Payment'
26
	'1004' : 'EBS-AXIS Bank Account'
27
	'1007' : 'EBS-HDFC Bank Account'
28
	'1008' : 'EBS-VISA'
29
	'1009' : 'EBS-Citi Bank Debit Card'
30
	'1010' : 'EBS-Diners Club'
31
	'1012' : 'EBS-ItzCash'
32
	'1015' : 'EBS-JK Bank Account'
33
	'1016' : 'EBS-ICICI Bank Account'
34
	'1017' : 'EBS-MasterCard'
35
	'1029' : 'EBS-Federal Bank Account'
36
	'1032' : 'EBS-State Bank of India Netbanking'
37
	'1033' : 'EBS-State Bank of Bikaner and Jaipur Netbanking'
38
	'1034' : 'EBS-State Bank of Hyderabad Netbanking'
39
	'1035' : 'EBS-State Bank of Patiala Netbanking'
40
	'1036' : 'EBS-State Bank of Shaurashtra Netbanking'
41
	'1037' : 'EBS-State Bank of Indore Netbanking'
42
	'1038' : 'EBS-State Bank of Mysore Netbanking'
43
	'1039' : 'EBS-State Bank of Travancore Netbanking'
44
	'1040' : 'EBS-Citi Bank Reward Point'
45
	'1127' : 'EBS-Citi Bank Account'
46
	'1132' : 'EBS-Done Card'
2574 chandransh 47
	'1133' : 'EBS-Karnataka Bank Account'
48
	'1134' : 'EBS-ICash'
49
	'1135' : 'EBS-Corporation Bank Account'
50
 	'2000' : 'HDFC-VISA/VISA Electron Debit Card'
2461 chandransh 51
	'2008' : 'HDFC-VISA'
52
	'2017' : 'HDFC-MasterCard'
3164 chandransh 53
	'3000' : 'COD'
3270 vikas 54
	'2001' : 'Cheque'
3274 vikas 55
	'1026' : 'EBS-ICICI Bank Debit Card'
56
    '1027' : 'EBS-SBI Debit Card'
3709 chandransh 57
    '2020' : 'HDFC Credit Card 3-month EMI'
3724 vikas 58
    '4000' : 'BULK'
3274 vikas 59
}
2303 ankur.sing 60
 
680 rajveer 61
struct Attribute{
62
	1:string name,
63
	2:string value
121 ashish 64
}
65
 
420 ashish 66
struct PaymentGateway{
121 ashish 67
	1:i64 id,
680 rajveer 68
	2:string name,
69
	3:string url,
70
	4:i64 addedOn,
71
	5:string aliasName,
72
	6:string responseUrl,
73
	7:string errorUrl,
74
	8:PaymentGatewayStatus status
75
	9:list<Attribute> attributes  // list of all attributes for PG
121 ashish 76
}
77
 
78
struct Payment{
680 rajveer 79
	1:i64 paymentId,  				// trackId for bank, paymentid for us and id for table.
80
	2:i64 gatewayId, 				//payment gateway used
81
	3:string gatewayPaymentId
704 chandransh 82
	4:i64 merchantTxnId,			//merchant transaction id. This will be propagated further to order processing
680 rajveer 83
	5:string gatewayTxnId,			//bank trnasaction id
84
	6:double amount,
85
	7:string gatewayTxnStatus,  	// bank status will be stored here
86
	8:PaymentStatus status,
87
	9:i64 userId,					//The user for which payment has to be processed.This is here to speed up querying.
88
	10:string errorCode,
89
	11:string description,
90
	12:string authCode,
91
	13:string referenceCode,		// given by gateway
92
	14:string sessionId, 			// received from PG 
93
	15:string gatewayTxnDate,
94
	16:list<Attribute> attributes,  	// list of all attributes received from PG
95
	17:i64 initTimestamp,			//statring the payment processing timestamp
96
	18:i64 successTimestamp,		//timestamp when payment is captured
97
	19:i64 errorTimestamp,			// in case, error is received from PG
121 ashish 98
}
99
 
2747 chandransh 100
struct Refund{
101
	1:i64 id,
102
	2:i64 paymentId,
103
    3:i64 gatewayId,
104
    4:i64 orderId,
105
    5:double amount,
106
    6:string gatewayTxnId,
107
    7:i32 attempts,
108
    8:i64 createdAt,
109
    9:i64 processedAt,
110
    10:list<Attribute> attributes
111
}
121 ashish 112
 
113
exception PaymentException{
114
	1:i64 error_code,
115
	2:string message
116
}
117
 
4008 mandeep.dh 118
enum ExtraPaymentProcessingType {
119
    FAILED_PAYMENTS
120
}
121
 
3374 rajveer 122
service PaymentService extends GenericService.GenericService{
680 rajveer 123
	/**
124
	*	create a new payment and return payment id, throws an exception if gateway is not active
125
	**/
126
	i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
121 ashish 127
 
680 rajveer 128
	/**
129
	* get payment for user. If status and gateway are null, it is ignored. Same for times as well.
130
	**/ 
131
	list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 132
 
680 rajveer 133
	/**
2059 ankur.sing 134
	* get all payments for user. If gatewayId is 0, then it is ignored while filtering.
680 rajveer 135
	**/ 
136
	list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 137
 
138
 
680 rajveer 139
	/** 
140
	* Get a particular gateway
141
	**/
142
	PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
143
 
144
	/** 
145
	* Get a particular payment info
146
	**/
420 ashish 147
	Payment getPayment(1:i64 id) throws (1:PaymentException pe),
680 rajveer 148
 
149
 
150
	/** 
151
	* Get a particular payment for a transaction. Will raise exception.
152
	**/
153
	list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
121 ashish 154
 
680 rajveer 155
	/**
156
	* mark payment successful and store parameters
157
	**/
1118 rajveer 158
	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 159
 
680 rajveer 160
	/**
161
	* mark payment failed and store parameters
694 rajveer 162
 
680 rajveer 163
	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 164
	*/
1731 ankur.sing 165
 
1628 ankur.sing 166
	/**
1731 ankur.sing 167
	Returns the minimum and maximum amounts among successful payments.
168
	List contains two double values, first minimum and second maximum amount.
1628 ankur.sing 169
	*/
2461 chandransh 170
	list<double> getSuccessfulPaymentsAmountRange(),
171
 
172
	/**
173
	Initialize the payment pipe for a HDFC payment. The URL the user should be redirected to is returned.
3010 chandransh 174
	In case of any processing error, an exception is raised.
2461 chandransh 175
	*/
2689 chandransh 176
	string initializeHdfcPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
177
 
178
	/**
3616 chandransh 179
	Initialize the payment pipe for a HDFC EMI payment. The URL the user should be redirected to is returned.
180
	In case of any processing error, an exception is raised.
181
	*/
182
	string initializeHdfcEmiPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
183
 
184
	/**
2689 chandransh 185
	Create a refund of the given amount corresponding to the given order to be processed through the same
186
	payment gateway which processed the payment for the corresponding transaction.
187
	Returns the id of the newly created Refund.
188
	*/	
3010 chandransh 189
	i64 createRefund(1:i64 orderId, 2:i64 merchantTxnId, 3:double amount) throws (1:PaymentException pe),
190
 
191
	/**
192
	Capture the payment for the given merchant transaction id. It processes the last payment for the given
193
	transaction. If the capture attempt failed, the payment is marked as failed.
194
	*/
3956 chandransh 195
	bool capturePayment(1:i64 merchantTxnId) throws (1:PaymentException pe),
196
 
197
	/**
198
	Adds the given amount to the captured amount of a COD payment.
199
	Updates the captured amount for the corresponding payment and marks it as PARTIALLY CAPTURED.
200
	If the captured amount becomes equal to total amount, then the payment status is set as SUCCESS.
201
	Also sets the name of the entity which transferred the money, the date on which it was transferred
202
	and the corresponding transaction id.
203
 
204
	Returns false if the payment couldn't be captured.
205
	Throws exception if no such payment could be found or if the captured amount will exceed the total amount after capturing.
206
	*/
4008 mandeep.dh 207
	bool partiallyCapturePayment(1:i64 merchantTxnId, 2:double amount, 3:string xferBy, 4:string xferTxnId, 5:i64 xferDate) throws (1:PaymentException pe),
208
 
209
    /**
210
     * Returns the list of payments that require some extra processing and
211
     * which belong to a particular category. This is currently used by CRM
212
     * application.
213
     */
214
    list<i64> getPaymentsRequiringExtraProcessing(1:ExtraPaymentProcessingType category),
215
 
216
    /**
217
     * Marks a particular payment as processed for a particular cateogory.
218
     * It essentially deletes the payment if it is processed for a particular
219
     * category. This is currently used by CRM application.
220
     */
221
    void markPaymentAsProcessed(1:i64 paymentId, 2:ExtraPaymentProcessingType category)
121 ashish 222
}