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