| Line 10... |
Line 10... |
| 10 |
}
|
10 |
}
|
| 11 |
|
11 |
|
| 12 |
enum PaymentStatus{
|
12 |
enum PaymentStatus{
|
| 13 |
INIT,
|
13 |
INIT,
|
| 14 |
PENDING,
|
14 |
PENDING,
|
| 15 |
SUCCESS,
|
15 |
SUCCESS, // HDFC Status: CAPTURED
|
| 16 |
FAILED
|
16 |
FAILED // HDFC status: NOT CAPTURED, DENIED BY RISK, HOST TIMEOUT, CANCELLED
|
| 17 |
}
|
17 |
}
|
| 18 |
|
18 |
|
| 19 |
enum RequestStatus{
|
19 |
struct Attribute{
|
| 20 |
RECEIVED,
|
- |
|
| 21 |
SENT_TO_GATEWAY,
|
20 |
1:string name,
|
| 22 |
GATEWAY_UNREACHABLE
|
- |
|
| 23 |
RESPONSE_FROM_GATEWAY,
|
- |
|
| 24 |
RESPONSE_SENT
|
21 |
2:string value
|
| 25 |
}
|
22 |
}
|
| 26 |
|
23 |
|
| 27 |
struct PaymentGateway{
|
24 |
struct PaymentGateway{
|
| 28 |
1:i64 id,
|
25 |
1:i64 id,
|
| 29 |
2:string gatewayName,
|
26 |
2:string name,
|
| 30 |
3:string gatewayProductionUrl,
|
27 |
3:string url,
|
| - |
|
28 |
4:i64 addedOn,
|
| 31 |
4:string gatewayStagingUrl,
|
29 |
5:string aliasName,
|
| 32 |
5:map<string,string> gatewayInfo,
|
30 |
6:string responseUrl,
|
| 33 |
6:i64 addedOn
|
31 |
7:string errorUrl,
|
| - |
|
32 |
8:PaymentGatewayStatus status
|
| - |
|
33 |
9:list<Attribute> attributes // list of all attributes for PG
|
| 34 |
}
|
34 |
}
|
| 35 |
|
35 |
|
| 36 |
struct Payment{
|
36 |
struct Payment{
|
| - |
|
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
|
| 37 |
1:string merchant_tx_id, //merchant transaction id. This will be propagated further to order processing
|
40 |
4:string merchantTxnId, //merchant transaction id. This will be propagated further to order processing
|
| 38 |
2:string bank_tx_id, //bank trnasaction id
|
41 |
5:string gatewayTxnId, //bank trnasaction id
|
| 39 |
3:double amount,
|
42 |
6:double amount,
|
| 40 |
4:i64 init_timestamp, //statring the payment processing timestamp
|
- |
|
| 41 |
5:i64 bank_ack_timestamp, //finishing processing timestamp
|
- |
|
| 42 |
6:string bank_status, //status provided by bank
|
43 |
7:string gatewayTxnStatus, // bank status will be stored here
|
| 43 |
7:PaymentStatus status, //shop2020 status
|
44 |
8:PaymentStatus status,
|
| 44 |
8:string message, //Will have the failure reason
|
- |
|
| 45 |
9:i64 user_id, //The user for which payment has to be processed.This is here to speed up querying.
|
45 |
9:i64 userId, //The user for which payment has to be processed.This is here to speed up querying.
|
| 46 |
10:i64 cart_id,
|
46 |
10:string errorCode,
|
| 47 |
11:map<string,string> other_info, //other misllaneous info about the payment
|
- |
|
| 48 |
12:i64 gateway_id, //payment gateway used
|
- |
|
| 49 |
13:string payment_id,
|
47 |
11:string description,
|
| 50 |
14:string error_code,
|
48 |
12:string authCode,
|
| 51 |
15:string session_id,
|
49 |
13:string referenceCode, // given by gateway
|
| 52 |
16:string ref_code,
|
50 |
14:string sessionId, // received from PG
|
| 53 |
17:string auth_code,
|
51 |
15:string gatewayTxnDate,
|
| 54 |
18:string post_date
|
52 |
16:list<Attribute> attributes, // list of all attributes received from PG
|
| 55 |
}
|
- |
|
| 56 |
|
- |
|
| 57 |
struct ApplicationRegistry{
|
53 |
17:i64 initTimestamp, //statring the payment processing timestamp
|
| 58 |
1:i64 application_id,
|
54 |
18:i64 successTimestamp, //timestamp when payment is captured
|
| 59 |
2:string callback_url
|
55 |
19:i64 errorTimestamp, // in case, error is received from PG
|
| 60 |
}
|
56 |
}
|
| 61 |
|
57 |
|
| 62 |
struct Param{
|
- |
|
| 63 |
1:string key,
|
- |
|
| 64 |
2:string value
|
- |
|
| 65 |
}
|
- |
|
| 66 |
|
- |
|
| 67 |
struct PaymentRequest{
|
- |
|
| 68 |
1:i64 request_id,
|
- |
|
| 69 |
2:i64 application_id,
|
- |
|
| 70 |
3:RequestStatus requestStatus,
|
- |
|
| 71 |
4:i64 receiving_timestamp,
|
- |
|
| 72 |
5:i64 sending_timestamp,
|
- |
|
| 73 |
6:list<Param> params,
|
- |
|
| 74 |
7:i64 merchant_tx_id
|
- |
|
| 75 |
}
|
- |
|
| 76 |
|
58 |
|
| 77 |
exception PaymentException{
|
59 |
exception PaymentException{
|
| 78 |
1:i64 error_code,
|
60 |
1:i64 error_code,
|
| 79 |
2:string message
|
61 |
2:string message
|
| 80 |
}
|
62 |
}
|
| 81 |
|
63 |
|
| 82 |
service PaymentService{
|
64 |
service PaymentService{
|
| 83 |
//create a new payment
|
65 |
/**
|
| 84 |
i64 createPayment(1:i64 user_id, 2:i64 cart_id, 3:double amount, 4:i64 gateway_id) throws (1:PaymentException pe),
|
66 |
* create a new payment and return payment id, throws an exception if gateway is not active
|
| 85 |
//create a new payment request
|
67 |
**/
|
| 86 |
void createPaymentRequest(1:i64 cart_id, 2:i64 application_id, 3:i64 merchant_tx_id, 5:list<Param> params) throws (1:PaymentException pe),
|
68 |
i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
|
| 87 |
//Add/update a new callback url for an application
|
- |
|
| 88 |
void addCallbackUrl(1:i64 application_id, 2:string callback_url, 3:bool updateIfExisting) throws (1:PaymentException pe),
|
- |
|
| - |
|
69 |
|
| 89 |
//Retrieve callback url
|
70 |
/**
|
| 90 |
void getCallbackUrl(1:i64 application_id) throws (1:PaymentException pe),
|
- |
|
| 91 |
//get payment for user. If status and gateway are null, it is ignore. Same for times as well.
|
71 |
* get payment for user. If status and gateway are null, it is ignored. Same for times as well.
|
| - |
|
72 |
**/
|
| 92 |
list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 from_time, 3:i64 to_time, 4:PaymentStatus status, 5:i64 gateway_id) throws (1:PaymentException pe),
|
73 |
list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
|
| - |
|
74 |
|
| - |
|
75 |
/**
|
| 93 |
//get payments for a cart. If status and gateway are null, it is ignore. Same for times as well.
|
76 |
* get all payments for user. Gateway is mandatory.
|
| 94 |
list<Payment> getPaymentsForCart(1:i64 cartId, 2:i64 from_time, 3:i64 to_time, 4:PaymentStatus status, 5:i64 gateway_id) throws (1:PaymentException pe),
|
- |
|
| 95 |
//get all payments.
|
77 |
**/
|
| 96 |
list<Payment> getPayments(1:i64 from_time, 2:i64 to_time, 3:PaymentStatus status, 4:i64 gateway_id) throws (1:PaymentException pe),
|
78 |
list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
|
| 97 |
//Get a particular payment
|
- |
|
| 98 |
list<Payment> getPaymentForMerchantId(1:i64 merchant_tx_id) throws (1:PaymentException pe),
|
- |
|
| 99 |
//change payment status
|
- |
|
| 100 |
void changePaymentStatus(1:i64 id, 2:PaymentStatus newStatus) throws (1:PaymentException pe),
|
- |
|
| 101 |
//change paymet request status
|
- |
|
| 102 |
void changePaymentRequestStatus(1:i64 request_id, 2:RequestStatus requestStatus) throws (1:PaymentException pe),
|
- |
|
| 103 |
|
79 |
|
| 104 |
//Get all payment gateways
|
- |
|
| 105 |
list<PaymentGateway> getPaymentGateways(1:PaymentGatewayStatus status) throws (1:PaymentException pe),
|
- |
|
| 106 |
|
80 |
|
| - |
|
81 |
/**
|
| 107 |
//Get a particular gateway
|
82 |
* Get a particular gateway
|
| - |
|
83 |
**/
|
| 108 |
PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
|
84 |
PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
|
| 109 |
|
85 |
|
| - |
|
86 |
/**
|
| 110 |
//change status of a gateway
|
87 |
* Get a particular payment info
|
| 111 |
void changeGatewayStatus(1:i64 id, 2:PaymentGatewayStatus status ) throws (1:PaymentException pe),
|
- |
|
| 112 |
|
88 |
**/
|
| 113 |
Payment getPayment(1:i64 id) throws (1:PaymentException pe),
|
89 |
Payment getPayment(1:i64 id) throws (1:PaymentException pe),
|
| - |
|
90 |
|
| - |
|
91 |
|
| - |
|
92 |
/**
|
| - |
|
93 |
* Get a particular payment for a transaction. Will raise exception.
|
| - |
|
94 |
**/
|
| - |
|
95 |
list<Payment> getPaymentForTxnId(1:i64 txnId) throws (1:PaymentException pe),
|
| 114 |
|
96 |
|
| - |
|
97 |
/**
|
| - |
|
98 |
* mark payment successful and store parameters
|
| - |
|
99 |
**/
|
| 115 |
void addBankDetails(1:i64 id, 2:string bid, 3: string btxid, 4:string error_code, 5:string session_id, 6:string postdate, 7:string auth_code, 8:string ref_code) throws (1:PaymentException pe),
|
100 |
bool markPaymentSuccessful(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:list<Attribute> attributes) throws (1:PaymentException pe),
|
| 116 |
|
101 |
|
| - |
|
102 |
/**
|
| - |
|
103 |
* mark payment failed and store parameters
|
| - |
|
104 |
**/
|
| - |
|
105 |
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)
|
| 117 |
|
106 |
|
| 118 |
}
|
107 |
}
|
| 119 |
|
108 |
|