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