Subversion Repositories SmartDukaan

Rev

Rev 680 | Rev 704 | 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,
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
40
	4:string merchantTxnId,			//merchant transaction id. This will be propagated further to order processing
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
	/**
66
	*	create a new payment and return payment id, throws an exception if gateway is not active
67
	**/
68
	i64 createPayment(1:i64 userId, 2:double amount, 3:i64 gatewayId, 4:i64 txnId) throws (1:PaymentException pe),
121 ashish 69
 
680 rajveer 70
	/**
71
	* get payment for user. If status and gateway are null, it is ignored. Same for times as well.
72
	**/ 
73
	list<Payment> getPaymentsForUser(1:i64 userId, 2:i64 fromTime, 3:i64 toTime, 4:PaymentStatus status, 5:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 74
 
680 rajveer 75
	/**
76
	* get all payments for user. Gateway is mandatory.
77
	**/ 
78
	list<Payment> getPayments(1:i64 fromTime, 2:i64 toTime, 3:PaymentStatus status, 4:i64 gatewayId) throws (1:PaymentException pe),
121 ashish 79
 
80
 
680 rajveer 81
	/** 
82
	* Get a particular gateway
83
	**/
84
	PaymentGateway getPaymentGateway(1:i64 id) throws (1:PaymentException pe),
85
 
86
	/** 
87
	* Get a particular payment info
88
	**/
420 ashish 89
	Payment getPayment(1:i64 id) throws (1:PaymentException pe),
680 rajveer 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),
121 ashish 96
 
680 rajveer 97
	/**
98
	* mark payment successful and store parameters
99
	**/
694 rajveer 100
	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:list<Attribute> attributes) throws (1:PaymentException pe),
420 ashish 101
 
680 rajveer 102
	/**
103
	* mark payment failed and store parameters
694 rajveer 104
 
680 rajveer 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)
694 rajveer 106
	*/
420 ashish 107
 
121 ashish 108
}