Subversion Repositories SmartDukaan

Rev

Rev 5613 | Rev 5716 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5613 Rev 5614
Line 37... Line 37...
37
    private long addressId = -1;
37
    private long addressId = -1;
38
    private String totalAmount = "";
38
    private String totalAmount = "";
39
    private boolean showCodOption = true;
39
    private boolean showCodOption = true;
40
    private boolean showEmiOption = false;
40
    private boolean showEmiOption = false;
41
    private String errorMsg = "";
41
    private String errorMsg = "";
42
    private String deliveryLocation = ""; //This could be set as myLocation or HotSpot
-
 
43
    private boolean showStorePickUpOption = false;
-
 
44
    private long hotSpotAddressId = 1;
-
 
45
    
42
    
46
    public String index(){
43
    public String index(){
47
        return processPaymentOptions();
44
        return processPaymentOptions();
48
    }
45
    }
49
    
46
    
Line 81... Line 78...
81
        String itemIdString = "";
78
        String itemIdString = "";
82
        try {
79
        try {
83
            userContextServiceClient = new UserClient();
80
            userContextServiceClient = new UserClient();
84
            userClient = userContextServiceClient.getClient();
81
            userClient = userContextServiceClient.getClient();
85
            
82
            
86
            
-
 
87
            long cartId = userinfo.getCartId();
83
            long cartId = userinfo.getCartId();
88
            if(deliveryLocation.equals("myLocation")) {
-
 
89
                userClient.addStoreToCart(cartId, 0);
-
 
90
            }
84
                  
91
            
-
 
92
            
-
 
93
            // Validate the cart to ensure that we are not accepting payment for
85
            // Validate the cart to ensure that we are not accepting payment for
94
            // an invalid order.
86
            // an invalid order.
95
            errorMsg = userClient.validateCart(cartId, sourceId);
87
            errorMsg = userClient.validateCart(cartId, sourceId);
96
            
88
            
97
            Cart cart = userClient.getCart(cartId);
89
            Cart cart = userClient.getCart(cartId);
Line 108... Line 100...
108
            if(addressId == -1){
100
            if(addressId == -1){
109
                addressId = cart.getAddressId();
101
                addressId = cart.getAddressId();
110
            }
102
            }
111
            address = userClient.getAddressById(addressId);
103
            address = userClient.getAddressById(addressId);
112
            
104
            
113
            if (deliveryLocation.equals("HotSpot")) {
-
 
114
                showStorePickUpOption = true;
-
 
115
                userClient.addStoreToCart(cartId, hotSpotAddressId);
-
 
116
                showCodOption = true;
-
 
117
            }else{
-
 
118
            	try {
105
            try {
119
            		showCodOption = userClient.showCODOption(cartId, sourceId, address.getPin());
106
                showCodOption = userClient.showCODOption(cartId, sourceId, address.getPin());
120
            	} catch(Exception e) {
107
            } catch(Exception e) {
121
            		logger.error("Error while checking if COD is available for: " + showCodOption, e);
108
                logger.error("Error while checking if COD is available for: " + showCodOption, e);
122
            		showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
109
                showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
123
            	}
-
 
124
            }
110
            }
125
            
111
            
126
            
-
 
127
            DataLogger.logData(EventType.PROCEED_TO_PAY, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
112
            DataLogger.logData(EventType.PROCEED_TO_PAY, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
128
                    Long.toString(cartId), itemIdString);
113
                    Long.toString(cartId), itemIdString);
129
        } catch(Exception e) {
114
        } catch(Exception e) {
130
            logger.error("Error while either validating the cart or getting the address", e);
115
            logger.error("Error while either validating the cart or getting the address", e);
131
            addActionError("We are experiencing some problem. Please try again.");
116
            addActionError("We are experiencing some problem. Please try again.");
Line 185... Line 170...
185
			url = "?" + url;
170
			url = "?" + url;
186
		}
171
		}
187
		url = request.getRequestURI() + url;
172
		url = request.getRequestURI() + url;
188
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getEmail(), url , 0, false);
173
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getEmail(), url , 0, false);
189
	}
174
	}
190
 
-
 
191
    public String getDeliveryLocation() {
-
 
192
        return deliveryLocation;
-
 
193
    }
-
 
194
 
-
 
195
    public void setDeliveryLocation(String deliveryLocation) {
-
 
196
        this.deliveryLocation = deliveryLocation;
-
 
197
    }
-
 
198
 
-
 
199
    public long getHotSpotAddressId() {
-
 
200
        return hotSpotAddressId;
-
 
201
    }
-
 
202
 
-
 
203
    public void setHotSpotAddressId(long hotSpotAddressId) {
-
 
204
        this.hotSpotAddressId = hotSpotAddressId;
-
 
205
    }
-
 
206
 
-
 
207
    public boolean shouldShowStorePickUpOption() {
-
 
208
        return showStorePickUpOption;
-
 
209
    }
-
 
210
}
175
}
211
176