Subversion Repositories SmartDukaan

Rev

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