Rev 6050 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.payment.domain;import in.shop2020.payments.Attribute;import in.shop2020.payments.PaymentStatus;import java.io.Serializable;import java.util.ArrayList;import java.util.Date;import java.util.HashMap;import java.util.List;import java.util.Map;public class Payment implements Serializable{private static final long serialVersionUID = -6103855488779807100L;private long id;private long gatewayId;private String gatewayPaymentId;private long merchantTxnId;private String gatewayTxnId;private double amount;private String gatewayTxnStatus;private int status;private long userId;private String errorCode;private String description;private String authCode;private String referenceCode;private String sessionId;private String gatewayTxnDate;private double refundAmount;private List<PaymentAttribute> attributes;private Date initTimestamp;private Date successTimestamp;private Date errorTimestamp;private Date provisionalCaptureTimestamp;private boolean isDigital;public String toString(){StringBuilder str = new StringBuilder("Id: " + id + ", User Id: " + userId);str.append(", Amount: " + amount);for(PaymentAttribute attr: attributes){str.append(", " + attr.getName() + ":" + attr.getValue());}return str.toString();}public in.shop2020.payments.Payment getThriftPayment(){in.shop2020.payments.Payment tPayment = new in.shop2020.payments.Payment();tPayment.setPaymentId(this.id);tPayment.setGatewayId(this.gatewayId);tPayment.setGatewayPaymentId(this.gatewayPaymentId);tPayment.setMerchantTxnId(this.merchantTxnId);tPayment.setGatewayTxnId(this.gatewayTxnId);tPayment.setAmount(this.amount);tPayment.setGatewayTxnStatus(this.gatewayTxnStatus);tPayment.setStatus(PaymentStatus.findByValue(this.status));tPayment.setUserId(this.userId);tPayment.setDescription(this.description);tPayment.setAuthCode(this.authCode);tPayment.setReferenceCode(this.referenceCode);tPayment.setSessionId(this.sessionId);tPayment.setGatewayTxnDate(this.gatewayTxnDate);tPayment.setIsDigital(isDigital);tPayment.setRefundAmount(this.refundAmount);if(initTimestamp != null)tPayment.setInitTimestamp(this.initTimestamp.getTime());if(successTimestamp != null)tPayment.setSuccessTimestamp(this.successTimestamp.getTime());if(errorTimestamp != null)tPayment.setErrorTimestamp(this.errorTimestamp.getTime());if(provisionalCaptureTimestamp != null)tPayment.setProvisionalCaptureTimestamp(this.provisionalCaptureTimestamp.getTime());//Ensure that the attributes list is never nulltPayment.setAttributes(new ArrayList<Attribute>());if(!(attributes == null || attributes.isEmpty())){for(PaymentAttribute attr : attributes)tPayment.addToAttributes(new Attribute(attr.getName(), attr.getValue()));}return tPayment;}public long getId() {return id;}public void setId(long id) {this.id = id;}public long getGatewayId() {return gatewayId;}public void setGatewayId(long gatewayId) {this.gatewayId = gatewayId;}public String getGatewayPaymentId() {return gatewayPaymentId;}public void setGatewayPaymentId(String gatewayPaymentId) {this.gatewayPaymentId = gatewayPaymentId;}public long getMerchantTxnId() {return merchantTxnId;}public void setMerchantTxnId(long merchantTxnId) {this.merchantTxnId = merchantTxnId;}public String getGatewayTxnId() {return gatewayTxnId;}public void setGatewayTxnId(String gatewayTxnId) {this.gatewayTxnId = gatewayTxnId;}public double getAmount() {return amount;}public void setAmount(double amount) {this.amount = amount;}public String getGatewayTxnStatus() {return gatewayTxnStatus;}public void setGatewayTxnStatus(String gatewayTxnStatus) {this.gatewayTxnStatus = gatewayTxnStatus;}public int getStatus() {return status;}public void setStatus(int status) {this.status = status;}public long getUserId() {return userId;}public void setUserId(long userId) {this.userId = userId;}public String getErrorCode() {return errorCode;}public void setErrorCode(String errorCode) {this.errorCode = errorCode;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public String getAuthCode() {return authCode;}public void setAuthCode(String authCode) {this.authCode = authCode;}public String getReferenceCode() {return referenceCode;}public void setReferenceCode(String referenceCode) {this.referenceCode = referenceCode;}public String getSessionId() {return sessionId;}public void setSessionId(String sessionId) {this.sessionId = sessionId;}public String getGatewayTxnDate() {return gatewayTxnDate;}public void setGatewayTxnDate(String gatewayTxnDate) {this.gatewayTxnDate = gatewayTxnDate;}public List<PaymentAttribute> getAttributes() {return attributes;}public void setAttributes(List<PaymentAttribute> attributes) {this.attributes = attributes;}public Date getInitTimestamp() {return initTimestamp;}public void setInitTimestamp(Date initTimestamp) {this.initTimestamp = initTimestamp;}public Date getSuccessTimestamp() {return successTimestamp;}public void setSuccessTimestamp(Date successTimestamp) {this.successTimestamp = successTimestamp;}public Date getErrorTimestamp() {return errorTimestamp;}public void setErrorTimestamp(Date errorTimestamp) {this.errorTimestamp = errorTimestamp;}public Map<String, String> getAttributeMap(){Map<String, String> attrMap = new HashMap<String, String>();for(PaymentAttribute attr : this.attributes){attrMap.put(attr.getName(), attr.getValue());}return attrMap;}public Date getProvisionalCaptureTimestamp() {return provisionalCaptureTimestamp;}public void setProvisionalCaptureTimestamp(Date provisionalCaptureTimestamp) {this.provisionalCaptureTimestamp = provisionalCaptureTimestamp;}public boolean isDigital() {return isDigital;}public void setDigital(boolean isDigital) {this.isDigital = isDigital;}public void setRefundAmount(double refundAmount) {this.refundAmount = refundAmount;}public double getRefundAmount() {return refundAmount;}}