| 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'
|
| 6459 |
rajveer |
61 |
'5001' : 'HDFC Credit Card 3-month EMI'
|
|
|
62 |
'5002' : 'HDFC Credit Card 6-month EMI'
|
|
|
63 |
'5003' : 'HDFC Credit Card 9-month EMI'
|
|
|
64 |
'5004' : 'HDFC Credit Card 12-month EMI'
|
| 5102 |
phani.kuma |
65 |
'1139' : 'EBS-VISA Credit Card 3-months EMI'
|
|
|
66 |
'1140' : 'EBS-MasterCard Credit Card 3-months EMI'
|
|
|
67 |
'1141' : 'EBS-VISA Credit Card 6-months EMI'
|
|
|
68 |
'1142' : 'EBS-MasterCard Credit Card 6-months EMI'
|
|
|
69 |
'1143' : 'EBS-Indian Bank Netbanking'
|
|
|
70 |
'1164' : 'EBS-Maestro Debit Card'
|
| 3724 |
vikas |
71 |
'4000' : 'BULK'
|
| 3274 |
vikas |
72 |
}
|
| 2303 |
ankur.sing |
73 |
|
| 680 |
rajveer |
74 |
struct Attribute{
|
|
|
75 |
1:string name,
|
|
|
76 |
2:string value
|
| 121 |
ashish |
77 |
}
|
|
|
78 |
|
| 420 |
ashish |
79 |
struct PaymentGateway{
|
| 121 |
ashish |
80 |
1:i64 id,
|
| 680 |
rajveer |
81 |
2:string name,
|
|
|
82 |
3:string url,
|
|
|
83 |
4:i64 addedOn,
|
|
|
84 |
5:string aliasName,
|
|
|
85 |
6:string responseUrl,
|
|
|
86 |
7:string errorUrl,
|
|
|
87 |
8:PaymentGatewayStatus status
|
|
|
88 |
9:list<Attribute> attributes // list of all attributes for PG
|
| 121 |
ashish |
89 |
}
|
|
|
90 |
|
|
|
91 |
struct Payment{
|
| 680 |
rajveer |
92 |
1:i64 paymentId, // trackId for bank, paymentid for us and id for table.
|
|
|
93 |
2:i64 gatewayId, //payment gateway used
|
|
|
94 |
3:string gatewayPaymentId
|
| 704 |
chandransh |
95 |
4:i64 merchantTxnId, //merchant transaction id. This will be propagated further to order processing
|
| 680 |
rajveer |
96 |
5:string gatewayTxnId, //bank trnasaction id
|
|
|
97 |
6:double amount,
|
|
|
98 |
7:string gatewayTxnStatus, // bank status will be stored here
|
|
|
99 |
8:PaymentStatus status,
|
|
|
100 |
9:i64 userId, //The user for which payment has to be processed.This is here to speed up querying.
|
|
|
101 |
10:string errorCode,
|
|
|
102 |
11:string description,
|
|
|
103 |
12:string authCode,
|
|
|
104 |
13:string referenceCode, // given by gateway
|
|
|
105 |
14:string sessionId, // received from PG
|
|
|
106 |
15:string gatewayTxnDate,
|
|
|
107 |
16:list<Attribute> attributes, // list of all attributes received from PG
|
|
|
108 |
17:i64 initTimestamp, //statring the payment processing timestamp
|
|
|
109 |
18:i64 successTimestamp, //timestamp when payment is captured
|
|
|
110 |
19:i64 errorTimestamp, // in case, error is received from PG
|
| 6050 |
anupam.sin |
111 |
20:i64 provisionalCaptureTimestamp, // in case, error is received from PG
|
|
|
112 |
21:bool isDigital
|
| 121 |
ashish |
113 |
}
|
|
|
114 |
|
| 2747 |
chandransh |
115 |
struct Refund{
|
|
|
116 |
1:i64 id,
|
|
|
117 |
2:i64 paymentId,
|
|
|
118 |
3:i64 gatewayId,
|
|
|
119 |
4:i64 orderId,
|
|
|
120 |
5:double amount,
|
|
|
121 |
6:string gatewayTxnId,
|
|
|
122 |
7:i32 attempts,
|
|
|
123 |
8:i64 createdAt,
|
|
|
124 |
9:i64 processedAt,
|
|
|
125 |
10:list<Attribute> attributes
|
|
|
126 |
}
|
| 121 |
ashish |
127 |
|
|
|
128 |
exception PaymentException{
|
|
|
129 |
1:i64 error_code,
|
|
|
130 |
2:string message
|
|
|
131 |
}
|
|
|
132 |
|
| 4008 |
mandeep.dh |
133 |
enum ExtraPaymentProcessingType {
|
| 4421 |
mandeep.dh |
134 |
FAILED_PAYMENTS,
|
|
|
135 |
PENDING_CAPTURE
|
| 4008 |
mandeep.dh |
136 |
}
|
|
|
137 |
|
| 3374 |
rajveer |
138 |
service PaymentService extends GenericService.GenericService{
|
| 680 |
rajveer |
139 |
/**
|
| 4141 |
chandransh |
140 |
create a new payment and return payment id, throws an exception if gateway is not active
|
|
|
141 |
*/
|
| 6050 |
anupam.sin |
142 |
i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId, 5:bool isDigital) throws (1:PaymentException pe),
|
| 121 |
ashish |
143 |
|
| 680 |
rajveer |
144 |
/**
|
| 4141 |
chandransh |
145 |
Get all payments for user. If status and gateway are null, they are ignored. Same for times as well.
|
|
|
146 |
*/
|
| 680 |
rajveer |
147 |
list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
148 |
|
| 680 |
rajveer |
149 |
/**
|
| 4141 |
chandransh |
150 |
Get all payments in the given status for the given gateway. If gatewayId is 0, then it is ignored.
|
|
|
151 |
*/
|
| 680 |
rajveer |
152 |
list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
153 |
|
| 4141 |
chandransh |
154 |
/**
|
|
|
155 |
Get all payments for the given gateway which were captured between the given dates. If the gatewayId is 0, it's ignored.
|
|
|
156 |
*/
|
|
|
157 |
list<Payment> getPaymentsByCapturedDate(1:i64 fromTime, 2:i64 toTime, 3:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
158 |
|
| 680 |
rajveer |
159 |
/**
|
| 4141 |
chandransh |
160 |
Get the gateway for the given id.
|
|
|
161 |
*/
|
| 680 |
rajveer |
162 |
PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
|
| 4600 |
varun.gupt |
163 |
|
|
|
164 |
/**
|
|
|
165 |
*Get all active Payment Gateways
|
|
|
166 |
**/
|
|
|
167 |
list<PaymentGateway> getActivePaymentGateways() throws (1:PaymentException pe),
|
|
|
168 |
|
| 680 |
rajveer |
169 |
/**
|
|
|
170 |
* Get a particular payment info
|
|
|
171 |
**/
|
| 420 |
ashish |
172 |
Payment getPayment(1:i64 id) throws (1:PaymentException pe),
|
| 680 |
rajveer |
173 |
|
|
|
174 |
|
|
|
175 |
/**
|
| 4600 |
varun.gupt |
176 |
* Get payments for a transaction. Will raise exception.
|
| 680 |
rajveer |
177 |
**/
|
|
|
178 |
list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
| 121 |
ashish |
179 |
|
| 4600 |
varun.gupt |
180 |
/**
|
|
|
181 |
* Get successful payment for a transaction. Will raise exception.
|
|
|
182 |
**/
|
|
|
183 |
Payment getSuccessfulPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
|
|
184 |
|
| 680 |
rajveer |
185 |
/**
|
|
|
186 |
* mark payment successful and store parameters
|
|
|
187 |
**/
|
| 1118 |
rajveer |
188 |
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 |
189 |
|
| 680 |
rajveer |
190 |
/**
|
|
|
191 |
* mark payment failed and store parameters
|
| 694 |
rajveer |
192 |
|
| 680 |
rajveer |
193 |
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 |
194 |
*/
|
| 1731 |
ankur.sing |
195 |
|
| 1628 |
ankur.sing |
196 |
/**
|
| 1731 |
ankur.sing |
197 |
Returns the minimum and maximum amounts among successful payments.
|
|
|
198 |
List contains two double values, first minimum and second maximum amount.
|
| 1628 |
ankur.sing |
199 |
*/
|
| 2461 |
chandransh |
200 |
list<double> getSuccessfulPaymentsAmountRange(),
|
|
|
201 |
|
|
|
202 |
/**
|
|
|
203 |
Initialize the payment pipe for a HDFC payment. The URL the user should be redirected to is returned.
|
| 3010 |
chandransh |
204 |
In case of any processing error, an exception is raised.
|
| 2461 |
chandransh |
205 |
*/
|
| 2689 |
chandransh |
206 |
string initializeHdfcPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
|
|
|
207 |
|
|
|
208 |
/**
|
| 6050 |
anupam.sin |
209 |
Initialize the payment pipe for a HDFC payment in case of a digital order. The URL the user should be redirected to is returned.
|
| 6228 |
anupam.sin |
210 |
In case of any processing error, an exception is raised. The phone is a madatory field and is required in case of dth payments.
|
| 6050 |
anupam.sin |
211 |
*/
|
| 6228 |
anupam.sin |
212 |
string doHdfcPaymentForDigitalOrder(1:i64 merchantPaymentId, 2:i64 rechargeOrderId, string phone) throws (1:PaymentException pe),
|
| 6050 |
anupam.sin |
213 |
|
|
|
214 |
/**
|
| 3616 |
chandransh |
215 |
Initialize the payment pipe for a HDFC EMI payment. The URL the user should be redirected to is returned.
|
|
|
216 |
In case of any processing error, an exception is raised.
|
|
|
217 |
*/
|
|
|
218 |
string initializeHdfcEmiPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
|
|
|
219 |
|
|
|
220 |
/**
|
| 2689 |
chandransh |
221 |
Create a refund of the given amount corresponding to the given order to be processed through the same
|
|
|
222 |
payment gateway which processed the payment for the corresponding transaction.
|
|
|
223 |
Returns the id of the newly created Refund.
|
|
|
224 |
*/
|
| 3010 |
chandransh |
225 |
i64 createRefund(1:i64 orderId, 2:i64 merchantTxnId, 3:double amount) throws (1:PaymentException pe),
|
|
|
226 |
|
|
|
227 |
/**
|
|
|
228 |
Capture the payment for the given merchant transaction id. It processes the last payment for the given
|
| 4421 |
mandeep.dh |
229 |
transaction. If the capture attempt failed, the payment is marked as failed. PaymentException with error
|
|
|
230 |
code 104 is thrown in case no payments are found for the transaction id passed.
|
|
|
231 |
PaymentException is also thrown with error code 106 in case capture was not possible due to connection
|
|
|
232 |
issue. Here, we payment also gets updated to CAPTURE_INPROCESS state
|
| 3010 |
chandransh |
233 |
*/
|
| 3956 |
chandransh |
234 |
bool capturePayment(1:i64 merchantTxnId) throws (1:PaymentException pe),
|
|
|
235 |
|
|
|
236 |
/**
|
|
|
237 |
Adds the given amount to the captured amount of a COD payment.
|
|
|
238 |
Updates the captured amount for the corresponding payment and marks it as PARTIALLY CAPTURED.
|
|
|
239 |
If the captured amount becomes equal to total amount, then the payment status is set as SUCCESS.
|
|
|
240 |
Also sets the name of the entity which transferred the money, the date on which it was transferred
|
|
|
241 |
and the corresponding transaction id.
|
|
|
242 |
|
|
|
243 |
Returns false if the payment couldn't be captured.
|
|
|
244 |
Throws exception if no such payment could be found or if the captured amount will exceed the total amount after capturing.
|
|
|
245 |
*/
|
| 4008 |
mandeep.dh |
246 |
bool partiallyCapturePayment(1:i64 merchantTxnId, 2:double amount, 3:string xferBy, 4:string xferTxnId, 5:i64 xferDate) throws (1:PaymentException pe),
|
|
|
247 |
|
|
|
248 |
/**
|
|
|
249 |
* Returns the list of payments that require some extra processing and
|
|
|
250 |
* which belong to a particular category. This is currently used by CRM
|
|
|
251 |
* application.
|
|
|
252 |
*/
|
|
|
253 |
list<i64> getPaymentsRequiringExtraProcessing(1:ExtraPaymentProcessingType category),
|
|
|
254 |
|
|
|
255 |
/**
|
|
|
256 |
* Marks a particular payment as processed for a particular cateogory.
|
|
|
257 |
* It essentially deletes the payment if it is processed for a particular
|
|
|
258 |
* category. This is currently used by CRM application.
|
|
|
259 |
*/
|
|
|
260 |
void markPaymentAsProcessed(1:i64 paymentId, 2:ExtraPaymentProcessingType category)
|
| 121 |
ashish |
261 |
}
|