| 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 |
|
| 3374 |
rajveer |
118 |
service PaymentService extends GenericService.GenericService{
|
| 680 |
rajveer |
119 |
/**
|
|
|
120 |
* create a new payment and return payment id, throws an exception if gateway is not active
|
|
|
121 |
**/
|
|
|
122 |
i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
|
| 121 |
ashish |
123 |
|
| 680 |
rajveer |
124 |
/**
|
|
|
125 |
* get payment for user. If status and gateway are null, it is ignored. Same for times as well.
|
|
|
126 |
**/
|
|
|
127 |
list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
128 |
|
| 680 |
rajveer |
129 |
/**
|
| 2059 |
ankur.sing |
130 |
* get all payments for user. If gatewayId is 0, then it is ignored while filtering.
|
| 680 |
rajveer |
131 |
**/
|
|
|
132 |
list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
133 |
|
|
|
134 |
|
| 680 |
rajveer |
135 |
/**
|
|
|
136 |
* Get a particular gateway
|
|
|
137 |
**/
|
|
|
138 |
PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
|
|
|
139 |
|
|
|
140 |
/**
|
|
|
141 |
* Get a particular payment info
|
|
|
142 |
**/
|
| 420 |
ashish |
143 |
Payment getPayment(1:i64 id) throws (1:PaymentException pe),
|
| 680 |
rajveer |
144 |
|
|
|
145 |
|
|
|
146 |
/**
|
|
|
147 |
* Get a particular payment for a transaction. Will raise exception.
|
|
|
148 |
**/
|
|
|
149 |
list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
| 121 |
ashish |
150 |
|
| 680 |
rajveer |
151 |
/**
|
|
|
152 |
* mark payment successful and store parameters
|
|
|
153 |
**/
|
| 1118 |
rajveer |
154 |
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 |
155 |
|
| 680 |
rajveer |
156 |
/**
|
|
|
157 |
* mark payment failed and store parameters
|
| 694 |
rajveer |
158 |
|
| 680 |
rajveer |
159 |
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 |
160 |
*/
|
| 1731 |
ankur.sing |
161 |
|
| 1628 |
ankur.sing |
162 |
/**
|
| 1731 |
ankur.sing |
163 |
Returns the minimum and maximum amounts among successful payments.
|
|
|
164 |
List contains two double values, first minimum and second maximum amount.
|
| 1628 |
ankur.sing |
165 |
*/
|
| 2461 |
chandransh |
166 |
list<double> getSuccessfulPaymentsAmountRange(),
|
|
|
167 |
|
|
|
168 |
/**
|
|
|
169 |
Initialize the payment pipe for a HDFC payment. The URL the user should be redirected to is returned.
|
| 3010 |
chandransh |
170 |
In case of any processing error, an exception is raised.
|
| 2461 |
chandransh |
171 |
*/
|
| 2689 |
chandransh |
172 |
string initializeHdfcPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
|
|
|
173 |
|
|
|
174 |
/**
|
| 3616 |
chandransh |
175 |
Initialize the payment pipe for a HDFC EMI payment. The URL the user should be redirected to is returned.
|
|
|
176 |
In case of any processing error, an exception is raised.
|
|
|
177 |
*/
|
|
|
178 |
string initializeHdfcEmiPayment(1:i64 merchantPaymentId) throws (1:PaymentException pe),
|
|
|
179 |
|
|
|
180 |
/**
|
| 2689 |
chandransh |
181 |
Create a refund of the given amount corresponding to the given order to be processed through the same
|
|
|
182 |
payment gateway which processed the payment for the corresponding transaction.
|
|
|
183 |
Returns the id of the newly created Refund.
|
|
|
184 |
*/
|
| 3010 |
chandransh |
185 |
i64 createRefund(1:i64 orderId, 2:i64 merchantTxnId, 3:double amount) throws (1:PaymentException pe),
|
|
|
186 |
|
|
|
187 |
/**
|
|
|
188 |
Capture the payment for the given merchant transaction id. It processes the last payment for the given
|
|
|
189 |
transaction. If the capture attempt failed, the payment is marked as failed.
|
|
|
190 |
*/
|
| 3956 |
chandransh |
191 |
bool capturePayment(1:i64 merchantTxnId) throws (1:PaymentException pe),
|
|
|
192 |
|
|
|
193 |
/**
|
|
|
194 |
Adds the given amount to the captured amount of a COD payment.
|
|
|
195 |
Updates the captured amount for the corresponding payment and marks it as PARTIALLY CAPTURED.
|
|
|
196 |
If the captured amount becomes equal to total amount, then the payment status is set as SUCCESS.
|
|
|
197 |
Also sets the name of the entity which transferred the money, the date on which it was transferred
|
|
|
198 |
and the corresponding transaction id.
|
|
|
199 |
|
|
|
200 |
Returns false if the payment couldn't be captured.
|
|
|
201 |
Throws exception if no such payment could be found or if the captured amount will exceed the total amount after capturing.
|
|
|
202 |
*/
|
|
|
203 |
bool partiallyCapturePayment(1:i64 merchantTxnId, 2:double amount, 3:string xferBy, 4:string xferTxnId, 5:i64 xferDate) throws (1:PaymentException pe)
|
| 121 |
ashish |
204 |
}
|