Subversion Repositories SmartDukaan

Rev

Rev 121 | Rev 680 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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,
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
 
420 ashish 27
struct PaymentGateway{
121 ashish 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{
420 ashish 37
	1:string merchant_tx_id,			//merchant transaction id. This will be propagated further to order processing
38
	2:string bank_tx_id,				//bank trnasaction id
121 ashish 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
420 ashish 48
	12:i64 gateway_id, 		//payment gateway used
49
	13:string payment_id,
50
	14:string error_code,
51
	15:string session_id,
52
	16:string ref_code,
53
	17:string auth_code,
54
	18:string post_date	
121 ashish 55
}	
56
 
57
struct ApplicationRegistry{
58
	1:i64 application_id,
59
	2:string callback_url
60
}
61
 
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
 
77
exception PaymentException{
78
	1:i64 error_code,
79
	2:string message
80
}
81
 
82
service PaymentService{
83
	//create a new payment
420 ashish 84
	i64 createPayment(1:i64 user_id, 2:i64 cart_id, 3:double amount, 4:i64 gateway_id) throws (1:PaymentException pe),
121 ashish 85
	//create a new payment request
420 ashish 86
	void createPaymentRequest(1:i64 cart_id, 2:i64 application_id, 3:i64 merchant_tx_id, 5:list<Param> params) throws (1:PaymentException pe),
121 ashish 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),
89
	//Retrieve callback url
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. 
420 ashish 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),
121 ashish 93
	//get payments for a cart. If status and gateway are null, it is ignore. Same for times as well.
420 ashish 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),
121 ashish 95
	//get all payments. 
420 ashish 96
	list<Payment> getPayments(1:i64 from_time, 2:i64 to_time, 3:PaymentStatus status, 4:i64 gateway_id) throws (1:PaymentException pe),
121 ashish 97
	//Get a particular payment
420 ashish 98
	list<Payment> getPaymentForMerchantId(1:i64 merchant_tx_id) throws (1:PaymentException pe),
121 ashish 99
	//change payment status
420 ashish 100
	void changePaymentStatus(1:i64 id, 2:PaymentStatus newStatus) throws (1:PaymentException pe),
121 ashish 101
	//change paymet request status
102
	void changePaymentRequestStatus(1:i64 request_id, 2:RequestStatus requestStatus) throws (1:PaymentException pe),
103
 
104
	//Get all payment gateways
105
	list<PaymentGateway> getPaymentGateways(1:PaymentGatewayStatus status) throws (1:PaymentException pe),
106
 
107
	//Get a particular gateway
108
	PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
109
 
110
	//change status of a gateway
420 ashish 111
	void changeGatewayStatus(1:i64 id, 2:PaymentGatewayStatus status 	) throws (1:PaymentException pe),
121 ashish 112
 
420 ashish 113
	Payment getPayment(1:i64 id) throws (1:PaymentException pe),
121 ashish 114
 
420 ashish 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),
116
 
117
 
121 ashish 118
}