Subversion Repositories SmartDukaan

Rev

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