| 121 |
ashish |
1 |
namespace java in.shop2020.payments
|
|
|
2 |
namespace py shop2020.payments
|
|
|
3 |
|
|
|
4 |
/**
|
|
|
5 |
Various structures
|
|
|
6 |
**/
|
|
|
7 |
enum PaymentGatewayStatus{
|
|
|
8 |
AVAILABLE,
|
|
|
9 |
BLOCKED
|
|
|
10 |
}
|
|
|
11 |
|
|
|
12 |
enum PaymentStatus{
|
|
|
13 |
INIT,
|
|
|
14 |
PENDING,
|
|
|
15 |
SUCCESS,
|
|
|
16 |
FAILED
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
enum RequestStatus{
|
|
|
20 |
RECEIVED,
|
|
|
21 |
SENT_TO_GATEWAY,
|
|
|
22 |
GATEWAY_UNREACHABLE
|
|
|
23 |
RESPONSE_FROM_GATEWAY,
|
|
|
24 |
RESPONSE_SENT
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
struct Paymentgateway{
|
|
|
28 |
1:i64 id,
|
|
|
29 |
2:string gatewayName,
|
|
|
30 |
3:string gatewayProductionUrl,
|
|
|
31 |
4:string gatewayStagingUrl,
|
|
|
32 |
5:map<string,string> gatewayInfo,
|
|
|
33 |
6:i64 addedOn
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
struct Payment{
|
|
|
37 |
1:i64 merchant_tx_id, //merchant transaction id. This will be propagated further to order processing
|
|
|
38 |
2:i64 bank_tx_id, //bank trnasaction id
|
|
|
39 |
3: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:PaymentStatus status, //shop2020 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.
|
|
|
46 |
10:i64 cart_id,
|
|
|
47 |
11:map<string,string> other_info, //other misllaneous info about the payment
|
|
|
48 |
12:PaymentGateway gateway //payment gateway used
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
struct ApplicationRegistry{
|
|
|
52 |
1:i64 application_id,
|
|
|
53 |
2:string callback_url
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
struct Param{
|
|
|
57 |
1:string key,
|
|
|
58 |
2:string value
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
struct PaymentRequest{
|
|
|
62 |
1:i64 request_id,
|
|
|
63 |
2:i64 application_id,
|
|
|
64 |
3:RequestStatus requestStatus,
|
|
|
65 |
4:i64 receiving_timestamp,
|
|
|
66 |
5:i64 sending_timestamp,
|
|
|
67 |
6:list<Param> params,
|
|
|
68 |
7:i64 merchant_tx_id
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
exception PaymentException{
|
|
|
72 |
1:i64 error_code,
|
|
|
73 |
2:string message
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
service PaymentService{
|
|
|
77 |
//create a new payment
|
|
|
78 |
Payment createPayment(1:i64 user_id, 2:i64 cart_id, 3:double amount, 4:i64 gateway_id) throws (1:PaymentException pe),
|
|
|
79 |
//create a new payment request
|
|
|
80 |
PaymentRequest createPaymentRequest(1:i64 cart_id, 2:i64 application_id, 3:i64 merchant_tx_id, 5:list<Param> params) throws (1:PaymentException pe),
|
|
|
81 |
//Add/update a new callback url for an application
|
|
|
82 |
void addCallbackUrl(1:i64 application_id, 2:string callback_url, 3:bool updateIfExisting) throws (1:PaymentException pe),
|
|
|
83 |
//Retrieve callback url
|
|
|
84 |
void getCallbackUrl(1:i64 application_id) throws (1:PaymentException pe),
|
|
|
85 |
//get payment for user. If status and gateway are null, it is ignore. Same for times as well.
|
|
|
86 |
list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 from_time, 3:i64 to_time, 4:PaymentStatus status, 5:PaymentGateway gateway) throws (1:PaymentException pe),
|
|
|
87 |
//get payments for a cart. If status and gateway are null, it is ignore. Same for times as well.
|
|
|
88 |
list<Payment> getPaymentsForCart(1:i64 cartId, 2:i64 from_time, 3:i64 to_time, 4:PaymentStatus status, 5:PaymentGateway gateway) throws (1:PaymentException pe),
|
|
|
89 |
//get all payments.
|
|
|
90 |
list<Payment> getPayments(1:i64 from_time, 2:i64 to_time, 3:PaymentStatus status, 4:PaymentGateway gateway) throws (1:PaymentException pe),
|
|
|
91 |
//Get a particular payment
|
|
|
92 |
Payment getPaymentForMerchantId(1:i64 merchant_tx_id) throws (1:PaymentException pe),
|
|
|
93 |
//change payment status
|
|
|
94 |
void changePaymentStatus(1:i64 merchant_tx_id, 2:PaymentStatus newStatus) throws (1:PaymentException pe),
|
|
|
95 |
//change paymet request status
|
|
|
96 |
void changePaymentRequestStatus(1:i64 request_id, 2:RequestStatus requestStatus) throws (1:PaymentException pe),
|
|
|
97 |
|
|
|
98 |
//Get all payment gateways
|
|
|
99 |
list<PaymentGateway> getPaymentGateways(1:PaymentGatewayStatus status) throws (1:PaymentException pe),
|
|
|
100 |
|
|
|
101 |
//Get a particular gateway
|
|
|
102 |
PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
|
|
|
103 |
|
|
|
104 |
//change status of a gateway
|
|
|
105 |
void changeGatewayStatus(1:i64 id, 2:PaymentGatewayStatus) throws (1:PaymentException pe),
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
}
|