Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package in.shop2020.payment.domain;

import in.shop2020.payments.Attribute;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@SuppressWarnings("serial")
public class Refund implements Serializable {
        private long id;
        private long paymentId;
    private long gatewayId;
    private long orderId;
    
    private double amount;
    private String gatewayTxnId;
    private int attempts;
    
    private Date createdAt;
    private Date processedAt;
    
    private List<RefundAttribute> attributes;

    public in.shop2020.payments.Refund getThriftPayment(){
        in.shop2020.payments.Refund refund = new in.shop2020.payments.Refund();
        refund.setId(id);
        refund.setPaymentId(paymentId);
        refund.setGatewayId(gatewayId);
        refund.setOrderId(orderId);
        refund.setAmount(amount);
        refund.setAttempts(attempts);
        refund.setCreatedAt(createdAt.getTime());
        if(processedAt != null)
            refund.setProcessedAt(processedAt.getTime());
        if(gatewayTxnId != null)
            refund.setGatewayTxnId(gatewayTxnId);
        
        if(attributes == null || attributes.isEmpty())
            refund.setAttributes(new ArrayList<Attribute>());
        else {
            for(RefundAttribute attr : attributes){
                refund.addToAttributes(new Attribute(attr.getName(), attr.getValue()));
            }
        }
        
        return refund;
    }
    
        public long getId() {
                return id;
        }

        public void setId(long id) {
                this.id = id;
        }

        public long getPaymentId() {
                return paymentId;
        }

        public void setPaymentId(long paymentId) {
                this.paymentId = paymentId;
        }

        public long getGatewayId() {
                return gatewayId;
        }

        public void setGatewayId(long gatewayId) {
                this.gatewayId = gatewayId;
        }

        public long getOrderId() {
                return orderId;
        }

        public void setOrderId(long orderId) {
                this.orderId = orderId;
        }

        public double getAmount() {
                return amount;
        }

        public void setAmount(double amount) {
                this.amount = amount;
        }

        public String getGatewayTxnId() {
                return gatewayTxnId;
        }

        public void setGatewayTxnId(String gatewayTxnId) {
                this.gatewayTxnId = gatewayTxnId;
        }

        public int getAttempts() {
                return attempts;
        }

        public void setAttempts(int attempts) {
                this.attempts = attempts;
        }

        public Date getCreatedAt() {
                return createdAt;
        }

        public void setCreatedAt(Date createdAt) {
                this.createdAt = createdAt;
        }

        public Date getProcessedAt() {
                return processedAt;
        }

        public void setProcessedAt(Date processedAt) {
                this.processedAt = processedAt;
        }

        public List<RefundAttribute> getAttributes() {
                return attributes;
        }

        public void setAttributes(List<RefundAttribute> attributes) {
                this.attributes = attributes;
        }
}