Subversion Repositories SmartDukaan

Rev

Rev 2593 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1946 chandransh 1
package in.shop2020.payment.domain;
2
 
3
import in.shop2020.payments.Attribute;
4
import in.shop2020.payments.PaymentStatus;
5
 
6
import java.io.Serializable;
7
import java.util.Date;
8
import java.util.List;
9
 
10
public class Payment implements Serializable{
11
 
12
	private static final long serialVersionUID = -6103855488779807100L;
13
 
14
	private long id;
15
    private long gatewayId;
16
 
17
    private String gatewayPaymentId;    
18
    private long merchantTxnId;
19
    private String gatewayTxnId;
20
    private double amount;
21
    private String gatewayTxnStatus;
22
    private int status;
23
    private long userId;
24
 
25
    private String errorCode;
26
    private String description;
27
    private String authCode;
28
    private String referenceCode;
29
    private String sessionId;
30
    private String gatewayTxnDate;
31
    private List<PaymentAttribute> attributes;
32
 
33
    private Date initTimestamp;
34
    private Date successTimestamp;
35
    private Date errorTimestamp;
36
 
37
    public String toString(){
38
    	StringBuilder str = new StringBuilder("Id: " + id + ", User Id: " + userId);
39
    	str.append(", Amount: " + amount);
40
    	for(PaymentAttribute attr: attributes){
41
    		str.append(", " + attr.getName() + ":" + attr.getValue());
42
    	}
43
    	return str.toString();
44
    }
45
 
46
    public in.shop2020.payments.Payment getThriftPayment(){
47
    	in.shop2020.payments.Payment tPayment = new in.shop2020.payments.Payment();
48
    	tPayment.setPaymentId(this.id);
49
    	tPayment.setGatewayId(this.gatewayId);
50
 
51
    	tPayment.setGatewayPaymentId(this.gatewayPaymentId);
52
    	tPayment.setMerchantTxnId(this.merchantTxnId);
53
    	tPayment.setGatewayTxnId(this.gatewayTxnId);
54
    	tPayment.setAmount(this.amount);
55
    	tPayment.setGatewayTxnStatus(this.gatewayTxnStatus);
56
    	tPayment.setStatus(PaymentStatus.findByValue(this.status));
57
    	tPayment.setUserId(this.userId);
58
 
59
    	tPayment.setDescription(this.description);
60
    	tPayment.setAuthCode(this.authCode);
61
    	tPayment.setReferenceCode(this.referenceCode);
62
    	tPayment.setSessionId(this.sessionId);
63
    	tPayment.setGatewayTxnDate(this.gatewayTxnDate);
64
 
65
    	if(initTimestamp != null)
66
    		tPayment.setInitTimestamp(this.initTimestamp.getTime());
67
    	if(successTimestamp != null)
68
    		tPayment.setSuccessTimestamp(this.successTimestamp.getTime());
69
    	if(errorTimestamp != null)
70
    		tPayment.setErrorTimestamp(this.errorTimestamp.getTime());
71
 
72
    	if(!(attributes == null || attributes.isEmpty())){
73
    		for(PaymentAttribute attr : attributes)
74
    			tPayment.addToAttributes(new Attribute(attr.getName(), attr.getValue()));
75
    	}
76
    	return tPayment;
77
    }
78
 
79
	public long getId() {
80
		return id;
81
	}
82
	public void setId(long id) {
83
		this.id = id;
84
	}
85
	public long getGatewayId() {
86
		return gatewayId;
87
	}
88
	public void setGatewayId(long gatewayId) {
89
		this.gatewayId = gatewayId;
90
	}
91
	public String getGatewayPaymentId() {
92
		return gatewayPaymentId;
93
	}
94
	public void setGatewayPaymentId(String gatewayPaymentId) {
95
		this.gatewayPaymentId = gatewayPaymentId;
96
	}
97
	public long getMerchantTxnId() {
98
		return merchantTxnId;
99
	}
100
	public void setMerchantTxnId(long merchantTxnId) {
101
		this.merchantTxnId = merchantTxnId;
102
	}
103
	public String getGatewayTxnId() {
104
		return gatewayTxnId;
105
	}
106
	public void setGatewayTxnId(String gatewayTxnId) {
107
		this.gatewayTxnId = gatewayTxnId;
108
	}
109
	public double getAmount() {
110
		return amount;
111
	}
112
	public void setAmount(double amount) {
113
		this.amount = amount;
114
	}
115
	public String getGatewayTxnStatus() {
116
		return gatewayTxnStatus;
117
	}
118
	public void setGatewayTxnStatus(String gatewayTxnStatus) {
119
		this.gatewayTxnStatus = gatewayTxnStatus;
120
	}
121
	public int getStatus() {
122
		return status;
123
	}
124
	public void setStatus(int status) {
125
		this.status = status;
126
	}
127
	public long getUserId() {
128
		return userId;
129
	}
130
	public void setUserId(long userId) {
131
		this.userId = userId;
132
	}
133
	public String getErrorCode() {
134
		return errorCode;
135
	}
136
	public void setErrorCode(String errorCode) {
137
		this.errorCode = errorCode;
138
	}
139
	public String getDescription() {
140
		return description;
141
	}
142
	public void setDescription(String description) {
143
		this.description = description;
144
	}
145
	public String getAuthCode() {
146
		return authCode;
147
	}
148
	public void setAuthCode(String authCode) {
149
		this.authCode = authCode;
150
	}
151
	public String getReferenceCode() {
152
		return referenceCode;
153
	}
154
	public void setReferenceCode(String referenceCode) {
155
		this.referenceCode = referenceCode;
156
	}
157
	public String getSessionId() {
158
		return sessionId;
159
	}
160
	public void setSessionId(String sessionId) {
161
		this.sessionId = sessionId;
162
	}
163
	public String getGatewayTxnDate() {
164
		return gatewayTxnDate;
165
	}
166
	public void setGatewayTxnDate(String gatewayTxnDate) {
167
		this.gatewayTxnDate = gatewayTxnDate;
168
	}
169
	public List<PaymentAttribute> getAttributes() {
170
		return attributes;
171
	}
172
	public void setAttributes(List<PaymentAttribute> attributes) {
173
		this.attributes = attributes;
174
	}
175
	public Date getInitTimestamp() {
176
		return initTimestamp;
177
	}
178
	public void setInitTimestamp(Date initTimestamp) {
179
		this.initTimestamp = initTimestamp;
180
	}
181
	public Date getSuccessTimestamp() {
182
		return successTimestamp;
183
	}
184
	public void setSuccessTimestamp(Date successTimestamp) {
185
		this.successTimestamp = successTimestamp;
186
	}
187
	public Date getErrorTimestamp() {
188
		return errorTimestamp;
189
	}
190
	public void setErrorTimestamp(Date errorTimestamp) {
191
		this.errorTimestamp = errorTimestamp;
192
	}
193
}