| 121 |
ashish |
1 |
namespace java in.shop2020.payments
|
| 420 |
ashish |
2 |
namespace py shop2020.thriftpy.payments
|
| 121 |
ashish |
3 |
|
|
|
4 |
/**
|
|
|
5 |
Various structures
|
|
|
6 |
**/
|
|
|
7 |
enum PaymentGatewayStatus{
|
|
|
8 |
AVAILABLE,
|
|
|
9 |
BLOCKED
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
enum PaymentStatus{
|
|
|
13 |
INIT,
|
|
|
14 |
PENDING,
|
| 1854 |
chandransh |
15 |
SUCCESS, // HDFC Status: CAPTURED; EBS Status: Captured
|
|
|
16 |
FAILED, // HDFC status: NOT CAPTURED, DENIED BY RISK, HOST TIMEOUT, CANCELLED
|
|
|
17 |
AUTHORIZED // EBS Status: Pending
|
| 121 |
ashish |
18 |
}
|
|
|
19 |
|
| 680 |
rajveer |
20 |
struct Attribute{
|
|
|
21 |
1:string name,
|
|
|
22 |
2:string value
|
| 121 |
ashish |
23 |
}
|
|
|
24 |
|
| 420 |
ashish |
25 |
struct PaymentGateway{
|
| 121 |
ashish |
26 |
1:i64 id,
|
| 680 |
rajveer |
27 |
2:string name,
|
|
|
28 |
3:string url,
|
|
|
29 |
4:i64 addedOn,
|
|
|
30 |
5:string aliasName,
|
|
|
31 |
6:string responseUrl,
|
|
|
32 |
7:string errorUrl,
|
|
|
33 |
8:PaymentGatewayStatus status
|
|
|
34 |
9:list<Attribute> attributes // list of all attributes for PG
|
| 121 |
ashish |
35 |
}
|
|
|
36 |
|
|
|
37 |
struct Payment{
|
| 680 |
rajveer |
38 |
1:i64 paymentId, // trackId for bank, paymentid for us and id for table.
|
|
|
39 |
2:i64 gatewayId, //payment gateway used
|
|
|
40 |
3:string gatewayPaymentId
|
| 704 |
chandransh |
41 |
4:i64 merchantTxnId, //merchant transaction id. This will be propagated further to order processing
|
| 680 |
rajveer |
42 |
5:string gatewayTxnId, //bank trnasaction id
|
|
|
43 |
6:double amount,
|
|
|
44 |
7:string gatewayTxnStatus, // bank status will be stored here
|
|
|
45 |
8:PaymentStatus status,
|
|
|
46 |
9:i64 userId, //The user for which payment has to be processed.This is here to speed up querying.
|
|
|
47 |
10:string errorCode,
|
|
|
48 |
11:string description,
|
|
|
49 |
12:string authCode,
|
|
|
50 |
13:string referenceCode, // given by gateway
|
|
|
51 |
14:string sessionId, // received from PG
|
|
|
52 |
15:string gatewayTxnDate,
|
|
|
53 |
16:list<Attribute> attributes, // list of all attributes received from PG
|
|
|
54 |
17:i64 initTimestamp, //statring the payment processing timestamp
|
|
|
55 |
18:i64 successTimestamp, //timestamp when payment is captured
|
|
|
56 |
19:i64 errorTimestamp, // in case, error is received from PG
|
| 121 |
ashish |
57 |
}
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
exception PaymentException{
|
|
|
61 |
1:i64 error_code,
|
|
|
62 |
2:string message
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
service PaymentService{
|
| 680 |
rajveer |
66 |
/**
|
| 763 |
rajveer |
67 |
* For closing the open session in sqlalchemy
|
|
|
68 |
*/
|
|
|
69 |
void closeSession(),
|
|
|
70 |
|
|
|
71 |
/**
|
| 680 |
rajveer |
72 |
* create a new payment and return payment id, throws an exception if gateway is not active
|
|
|
73 |
**/
|
|
|
74 |
i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
|
| 121 |
ashish |
75 |
|
| 680 |
rajveer |
76 |
/**
|
|
|
77 |
* get payment for user. If status and gateway are null, it is ignored. Same for times as well.
|
|
|
78 |
**/
|
|
|
79 |
list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
80 |
|
| 680 |
rajveer |
81 |
/**
|
|
|
82 |
* get all payments for user. Gateway is mandatory.
|
|
|
83 |
**/
|
|
|
84 |
list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
|
| 121 |
ashish |
85 |
|
|
|
86 |
|
| 680 |
rajveer |
87 |
/**
|
|
|
88 |
* Get a particular gateway
|
|
|
89 |
**/
|
|
|
90 |
PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* Get a particular payment info
|
|
|
94 |
**/
|
| 420 |
ashish |
95 |
Payment getPayment(1:i64 id) throws (1:PaymentException pe),
|
| 680 |
rajveer |
96 |
|
|
|
97 |
|
|
|
98 |
/**
|
|
|
99 |
* Get a particular payment for a transaction. Will raise exception.
|
|
|
100 |
**/
|
|
|
101 |
list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
| 121 |
ashish |
102 |
|
| 680 |
rajveer |
103 |
/**
|
|
|
104 |
* mark payment successful and store parameters
|
|
|
105 |
**/
|
| 1118 |
rajveer |
106 |
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 |
107 |
|
| 680 |
rajveer |
108 |
/**
|
|
|
109 |
* mark payment failed and store parameters
|
| 694 |
rajveer |
110 |
|
| 680 |
rajveer |
111 |
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 |
112 |
*/
|
| 1731 |
ankur.sing |
113 |
|
| 1628 |
ankur.sing |
114 |
/**
|
| 1731 |
ankur.sing |
115 |
Returns the minimum and maximum amounts among successful payments.
|
|
|
116 |
List contains two double values, first minimum and second maximum amount.
|
| 1628 |
ankur.sing |
117 |
*/
|
| 1731 |
ankur.sing |
118 |
list<double> getSuccessfulPaymentsAmountRange()
|
| 121 |
ashish |
119 |
}
|