Subversion Repositories SmartDukaan

Rev

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