Subversion Repositories SmartDukaan

Rev

Rev 13524 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 13524 Rev 20278
Line 4... Line 4...
4
import in.shop2020.model.v1.order.EmiScheme;
4
import in.shop2020.model.v1.order.EmiScheme;
5
import in.shop2020.model.v1.order.TransactionService.Client;
5
import in.shop2020.model.v1.order.TransactionService.Client;
6
import in.shop2020.model.v1.user.Address;
6
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.Cart;
7
import in.shop2020.model.v1.user.Cart;
8
import in.shop2020.model.v1.user.PromotionService;
8
import in.shop2020.model.v1.user.PromotionService;
-
 
9
import in.shop2020.serving.services.IPaymentService;
9
import in.shop2020.serving.utils.FormattingUtils;
10
import in.shop2020.serving.utils.FormattingUtils;
-
 
11
import in.shop2020.serving.utils.PaymentUtils;
10
import in.shop2020.serving.utils.Utils;
12
import in.shop2020.serving.utils.Utils;
11
import in.shop2020.thrift.clients.PromotionClient;
13
import in.shop2020.thrift.clients.PromotionClient;
12
import in.shop2020.thrift.clients.TransactionClient;
14
import in.shop2020.thrift.clients.TransactionClient;
13
import in.shop2020.thrift.clients.UserClient;
15
import in.shop2020.thrift.clients.UserClient;
14
import in.shop2020.utils.DataLogger;
16
import in.shop2020.utils.DataLogger;
Line 30... Line 32...
30
import org.apache.thrift.transport.TTransportException;
32
import org.apache.thrift.transport.TTransportException;
31
 
33
 
32
import com.google.gson.Gson;
34
import com.google.gson.Gson;
33
 
35
 
34
@SuppressWarnings("serial")
36
@SuppressWarnings("serial")
35
@InterceptorRefs({
-
 
36
    @InterceptorRef("myDefault"),
37
@InterceptorRefs({ @InterceptorRef("myDefault"), @InterceptorRef("login") })
37
    @InterceptorRef("login")
-
 
38
})
-
 
39
 
38
 
40
@Results({
-
 
41
    @Result(name="shipping-redirect", type="redirectAction", params = {"actionName" , "shipping"})
39
@Results({ @Result(name = "shipping-redirect", type = "redirectAction", params = { "actionName", "shipping" }) })
42
})
-
 
43
 
40
 
44
public class ProceedToPayController extends BaseController {
41
public class ProceedToPayController extends BaseController {
45
    
-
 
46
    private static Logger logger = Logger.getLogger(ProceedToPayController.class);
-
 
47
    private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
-
 
48
    private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean.parseBoolean(resource.getString("show_ebs_test_gateway"));
-
 
49
    
-
 
50
    private static List<EmiScheme> emiSchemes;
-
 
51
    private static String emiSchemesInJSON;
-
 
52
    private boolean hasGiftVoucher = false;
-
 
53
    private long addressId = -1;
-
 
54
    private String totalAmount = "";
-
 
55
    private double totalAmountD = 0l;
-
 
56
    private boolean showCodOption = true;
-
 
57
    private boolean showEmiOption = false;
-
 
58
    private String errorMsg = "";
-
 
59
    private String deliveryLocation = ""; //This could be set as myLocation or HotSpot
-
 
60
    private boolean showStorePickUpOption = false;
-
 
61
    private long hotSpotAddressId = 1;
-
 
62
    private boolean amountZero = false;
-
 
63
    
-
 
64
    
-
 
65
    public String index(){
-
 
66
        return processPaymentOptions();
-
 
67
    }
-
 
68
    
-
 
69
    public String create(){
-
 
70
        String addressIdString = this.request.getParameter("addressid");
-
 
71
        if(addressIdString == null){
-
 
72
            addActionError("Please specify shipping address to continue.");
-
 
73
            return "shipping-redirect";
-
 
74
        }
-
 
75
 
-
 
76
        try {
-
 
77
            addressId = Long.parseLong(addressIdString);
-
 
78
        } catch(NumberFormatException nfe) {
-
 
79
            logger.error("Unable to parse address id", nfe);
-
 
80
            addActionError("Please specify shipping address to continue.");
-
 
81
            return "shipping-redirect";
-
 
82
        }
-
 
83
        return processPaymentOptions();
-
 
84
    }
-
 
85
 
-
 
86
    private String processPaymentOptions() {
-
 
87
    	if(emiSchemes == null){
-
 
88
    		populateEmiSchemes();
-
 
89
    	}
-
 
90
    	
-
 
91
        String showEmiOptionStr = this.request.getParameter("showEmiOption");
-
 
92
        if(showEmiOptionStr!=null){
-
 
93
            try{
-
 
94
                showEmiOption = Boolean.parseBoolean(showEmiOptionStr);
-
 
95
            }catch(Exception e){
-
 
96
                logger.info("A non-boolean value passed for showing EMI option");
-
 
97
            }
-
 
98
        }
-
 
99
        
-
 
100
        UserClient userContextServiceClient = null;
-
 
101
        in.shop2020.model.v1.user.UserContextService.Client userClient = null;
-
 
102
        
-
 
103
        Address address;
-
 
104
        String itemIdString = "";
-
 
105
        try {
-
 
106
            userContextServiceClient = new UserClient();
-
 
107
            userClient = userContextServiceClient.getClient();
-
 
108
            
-
 
109
            long cartId = userinfo.getCartId();
-
 
110
            if(deliveryLocation.equals("myLocation")) {
-
 
111
                userClient.addStoreToCart(cartId, 0);
-
 
112
            }
-
 
113
            // Validate the cart to ensure that we are not accepting payment for
-
 
114
            // an invalid order.
-
 
115
            errorMsg = userClient.validateCart(cartId, sourceId).get(0);
-
 
116
            
-
 
117
            Cart cart = userClient.getCart(cartId);
-
 
118
            String couponCode = cart.getCouponCode();
-
 
119
            logger.info("Coupon: " + couponCode);
-
 
120
            
-
 
121
            setTotalAmount(cart);
-
 
122
            itemIdString = Utils.getItemIdStringInCart(cart);
-
 
123
            
-
 
124
            PromotionService.Client pc = new PromotionClient().getClient();
-
 
125
            /*
-
 
126
             * If a gift voucher is used such that all of the amount is paid by the gift voucher then we
-
 
127
             * do not need set the hasGiftVoucher flag.
-
 
128
             */
-
 
129
            if(StringUtils.isNotEmpty(couponCode) && pc.isGiftVoucher(couponCode) && getTotalAmountL() > 0){
-
 
130
            	hasGiftVoucher = true;
-
 
131
            }
-
 
132
            
-
 
133
            if (!hasGiftVoucher && deliveryLocation.equals("HotSpot")) {
-
 
134
            	userClient.addStoreToCart(cartId, hotSpotAddressId);
-
 
135
            	showStorePickUpOption = true;
-
 
136
            }
-
 
137
            
-
 
138
            // Get the address to check if COD option is available for this
-
 
139
            // address.
-
 
140
            if(addressId == -1){
-
 
141
                addressId = cart.getAddressId();
-
 
142
            }
-
 
143
            address = userClient.getAddressById(addressId);
-
 
144
            
-
 
145
            try {
-
 
146
                showCodOption = userClient.showCODOption(cartId, sourceId, address.getPin());
-
 
147
            } catch(Exception e) {
-
 
148
                logger.error("Error while checking if COD is available for: " + showCodOption, e);
-
 
149
                showCodOption = false; //Not a critical error, proceeding with defensive behaviour.
-
 
150
            }
-
 
151
            
-
 
152
            showStorePickUpOption = showStorePickUpOption && showCodOption;
-
 
153
            
-
 
154
//            DataLogger.logData(EventType.PROCEED_TO_PAY, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
-
 
155
//                    Long.toString(cartId), itemIdString);
-
 
156
        } catch(Exception e) {
-
 
157
            logger.error("Error while either validating the cart or getting the address", e);
-
 
158
            addActionError("We are experiencing some problem. Please try again.");
-
 
159
            return "shipping-redirect";
-
 
160
        }
-
 
161
        
-
 
162
        Collection<String> actionErrors = getActionErrors();
-
 
163
        if(actionErrors != null && !actionErrors.isEmpty()){
-
 
164
            for (String str : actionErrors) {
-
 
165
                errorMsg += str + "<BR/>";
-
 
166
            }
-
 
167
        }
-
 
168
        
-
 
169
        return "index";
-
 
170
    }
-
 
171
 
42
 
-
 
43
	private static Logger logger = Logger.getLogger(ProceedToPayController.class);
-
 
44
	private static final ResourceBundle resource = ResourceBundle.getBundle(ProceedToPayController.class.getName());
-
 
45
	private static final boolean SHOW_EBS_TEST_GATEWAY = Boolean
-
 
46
			.parseBoolean(resource.getString("show_ebs_test_gateway"));
-
 
47
 
-
 
48
	private static List<EmiScheme> emiSchemes;
-
 
49
	private static String emiSchemesInJSON;
-
 
50
	private boolean hasGiftVoucher = false;
-
 
51
	private long addressId = -1;
-
 
52
	private String totalAmount = "";
-
 
53
	private double totalAmountD = 0l;
-
 
54
	private boolean showCodOption = true;
-
 
55
	private boolean showEmiOption = false;
-
 
56
	private String errorMsg = "";
-
 
57
	private String deliveryLocation = ""; // This could be set as myLocation or
-
 
58
											// HotSpot
-
 
59
	private boolean showStorePickUpOption = false;
-
 
60
	private long hotSpotAddressId = 1;
-
 
61
	private boolean amountZero = false;
-
 
62
 
-
 
63
	public String index() {
-
 
64
		return processPaymentOptions();
-
 
65
	}
-
 
66
 
-
 
67
	public String create() {
-
 
68
		String addressIdString = this.request.getParameter("addressid");
-
 
69
		if (addressIdString == null) {
-
 
70
			addActionError("Please specify shipping address to continue.");
-
 
71
			return "shipping-redirect";
-
 
72
		}
-
 
73
 
-
 
74
		try {
-
 
75
			addressId = Long.parseLong(addressIdString);
-
 
76
		} catch (NumberFormatException nfe) {
-
 
77
			logger.error("Unable to parse address id", nfe);
-
 
78
			addActionError("Please specify shipping address to continue.");
-
 
79
			return "shipping-redirect";
-
 
80
		}
-
 
81
		return processPaymentOptions();
-
 
82
	}
-
 
83
 
-
 
84
	private String processPaymentOptions() {
-
 
85
		if (emiSchemes == null) {
-
 
86
			populateEmiSchemes();
-
 
87
		}
-
 
88
 
-
 
89
		String showEmiOptionStr = this.request.getParameter("showEmiOption");
-
 
90
		if (showEmiOptionStr != null) {
-
 
91
			try {
-
 
92
				showEmiOption = Boolean.parseBoolean(showEmiOptionStr);
-
 
93
			} catch (Exception e) {
-
 
94
				logger.info("A non-boolean value passed for showing EMI option");
-
 
95
			}
-
 
96
		}
-
 
97
 
-
 
98
		UserClient userContextServiceClient = null;
-
 
99
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
-
 
100
 
-
 
101
		Address address;
-
 
102
		String itemIdString = "";
-
 
103
		try {
-
 
104
			userContextServiceClient = new UserClient();
-
 
105
			userClient = userContextServiceClient.getClient();
-
 
106
 
-
 
107
			long cartId = userinfo.getCartId();
-
 
108
			if (deliveryLocation.equals("myLocation")) {
-
 
109
				userClient.addStoreToCart(cartId, 0);
-
 
110
			}
-
 
111
			// Validate the cart to ensure that we are not accepting payment for
-
 
112
			// an invalid order.
-
 
113
			errorMsg = userClient.validateCart(cartId, sourceId).get(0);
-
 
114
 
-
 
115
			Cart cart = userClient.getCart(cartId);
-
 
116
			String couponCode = cart.getCouponCode();
-
 
117
			logger.info("Coupon: " + couponCode);
-
 
118
 
-
 
119
			setTotalAmount(cart);
-
 
120
			itemIdString = Utils.getItemIdStringInCart(cart);
-
 
121
 
-
 
122
			PromotionService.Client pc = new PromotionClient().getClient();
-
 
123
			/*
-
 
124
			 * If a gift voucher is used such that all of the amount is paid by
-
 
125
			 * the gift voucher then we do not need set the hasGiftVoucher flag.
-
 
126
			 */
-
 
127
			if (StringUtils.isNotEmpty(couponCode) && pc.isGiftVoucher(couponCode) && getTotalAmountL() > 0) {
-
 
128
				hasGiftVoucher = true;
-
 
129
			}
-
 
130
 
-
 
131
			if (!hasGiftVoucher && deliveryLocation.equals("HotSpot")) {
-
 
132
				userClient.addStoreToCart(cartId, hotSpotAddressId);
-
 
133
				showStorePickUpOption = true;
-
 
134
			}
-
 
135
 
-
 
136
			// Get the address to check if COD option is available for this
-
 
137
			// address.
-
 
138
			if (addressId == -1) {
-
 
139
				addressId = cart.getAddressId();
-
 
140
			}
-
 
141
			address = userClient.getAddressById(addressId);
-
 
142
 
-
 
143
			try {
-
 
144
				showCodOption = userClient.showCODOption(cartId, sourceId, address.getPin());
-
 
145
			} catch (Exception e) {
-
 
146
				logger.error("Error while checking if COD is available for: " + showCodOption, e);
-
 
147
				showCodOption = false; // Not a critical error, proceeding with
-
 
148
										// defensive behaviour.
-
 
149
			}
-
 
150
 
-
 
151
			showStorePickUpOption = showStorePickUpOption && showCodOption;
-
 
152
 
-
 
153
			// DataLogger.logData(EventType.PROCEED_TO_PAY, getSessionId(),
-
 
154
			// userinfo.getUserId(), userinfo.getEmail(),
-
 
155
			// Long.toString(cartId), itemIdString);
-
 
156
		} catch (Exception e) {
-
 
157
			logger.error("Error while either validating the cart or getting the address", e);
-
 
158
			addActionError("We are experiencing some problem. Please try again.");
-
 
159
			return "shipping-redirect";
-
 
160
		}
-
 
161
 
-
 
162
		Collection<String> actionErrors = getActionErrors();
-
 
163
		if (actionErrors != null && !actionErrors.isEmpty()) {
-
 
164
			for (String str : actionErrors) {
-
 
165
				errorMsg += str + "<BR/>";
-
 
166
			}
-
 
167
		}
-
 
168
 
-
 
169
		return "index";
-
 
170
	}
-
 
171
 
172
    public static void populateEmiSchemes(){
172
	public static void populateEmiSchemes() {
173
    	try {
173
		try {
174
			Client tClient = new TransactionClient().getClient();
174
			Client tClient = new TransactionClient().getClient();
175
			emiSchemes = tClient.getAvailableEmiSchemes();
175
			emiSchemes = tClient.getAvailableEmiSchemes();
176
		} catch (TTransportException e) {
176
		} catch (TTransportException e) {
177
			logger.error("Error while getting EMI schemes: ", e);
177
			logger.error("Error while getting EMI schemes: ", e);
178
		} catch (TException e) {
178
		} catch (TException e) {
179
			logger.error("Error while getting EMI schemes: ", e);
179
			logger.error("Error while getting EMI schemes: ", e);
180
		}
180
		}
181
    }
181
	}
182
    
182
 
183
    private void setTotalAmount(Cart cart) {
183
	private void setTotalAmount(Cart cart) {
184
    	String couponCode = cart.getCouponCode();
184
		String couponCode = cart.getCouponCode();
185
        if(couponCode == null || "".equals(couponCode))
185
		if (couponCode == null || "".equals(couponCode))
186
        	totalAmountD = cart.getTotalPrice();
186
			totalAmountD = cart.getTotalPrice();
187
        else
187
		else
188
            totalAmountD = cart.getDiscountedPrice();
188
			totalAmountD = cart.getDiscountedPrice();
189
        
189
 
190
        FormattingUtils formattingUtils = new FormattingUtils();
190
		FormattingUtils formattingUtils = new FormattingUtils();
191
        totalAmount = formattingUtils.formatPrice(totalAmountD);
191
		totalAmount = formattingUtils.formatPrice(totalAmountD);
192
        if(totalAmountD == 0) {
192
		if (totalAmountD == 0) {
193
            amountZero = true;
193
			amountZero = true;
194
        }
194
		}
195
    }
195
	}
196
 
196
 
197
    public long getAddressId(){
197
	public long getAddressId() {
198
        return this.addressId;
198
		return this.addressId;
199
    }
199
	}
200
    
200
 
201
    public String getErrorMsg(){
201
	public String getErrorMsg() {
202
    	logger.info("added error msg:" + this.errorMsg);
202
		logger.info("added error msg:" + this.errorMsg);
203
        return this.errorMsg;
203
		return this.errorMsg;
204
    }
204
	}
205
    
205
 
206
    public boolean shouldShowCodOption() {
206
	public boolean shouldShowCodOption() {
207
        return showCodOption;
207
		return showCodOption;
208
    }
208
	}
209
 
209
 
210
    public boolean shouldShowEmiOption() {
210
	public boolean shouldShowEmiOption() {
211
        return showEmiOption;
211
		return showEmiOption;
212
    }
212
	}
213
 
213
 
214
    public String getTotalAmount(){
214
	public String getTotalAmount() {
215
        return totalAmount;
215
		return totalAmount;
216
    }
216
	}
217
    
217
 
218
    public double getTotalAmountL(){
218
	public double getTotalAmountL() {
219
    	return totalAmountD;
219
		return totalAmountD;
220
    }
220
	}
221
    
221
 
222
    public boolean shouldShowEbsTestGateway() {
222
	public boolean shouldShowEbsTestGateway() {
223
        return SHOW_EBS_TEST_GATEWAY;
223
		return SHOW_EBS_TEST_GATEWAY;
224
    }
224
	}
225
    
225
 
226
	@Override
226
	@Override
227
	public String getHeaderSnippet() {
227
	public String getHeaderSnippet() {
228
		String url = request.getQueryString();
228
		String url = request.getQueryString();
229
		if (url == null) {
229
		if (url == null) {
230
			url = "";
230
			url = "";
231
		} else {
231
		} else {
232
			url = "?" + url;
232
			url = "?" + url;
233
		}
233
		}
234
		url = request.getRequestURI() + url;
234
		url = request.getRequestURI() + url;
235
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getEmail(), userinfo.getTotalItems(), url , 0, false, userinfo.isPrivateDealUser());
235
		return pageLoader.getHeaderHtml(userinfo.isLoggedIn(), userinfo.getEmail(), userinfo.getTotalItems(), url, 0,
-
 
236
				false, userinfo.isPrivateDealUser());
236
	}
237
	}
237
 
238
 
238
    public String getDeliveryLocation() {
239
	public String getDeliveryLocation() {
239
        return deliveryLocation;
240
		return deliveryLocation;
240
    }
241
	}
241
 
242
 
242
    public void setDeliveryLocation(String deliveryLocation) {
243
	public void setDeliveryLocation(String deliveryLocation) {
243
        this.deliveryLocation = deliveryLocation;
244
		this.deliveryLocation = deliveryLocation;
244
    }
245
	}
245
 
246
 
246
    public long getHotSpotAddressId() {
247
	public long getHotSpotAddressId() {
247
        return hotSpotAddressId;
248
		return hotSpotAddressId;
248
    }
249
	}
249
 
250
 
250
    public void setHotSpotAddressId(long hotSpotAddressId) {
251
	public void setHotSpotAddressId(long hotSpotAddressId) {
251
        this.hotSpotAddressId = hotSpotAddressId;
252
		this.hotSpotAddressId = hotSpotAddressId;
252
    }
253
	}
253
 
254
 
254
    public boolean shouldShowStorePickUpOption() {
255
	public boolean shouldShowStorePickUpOption() {
255
        return showStorePickUpOption;
256
		return showStorePickUpOption;
256
    }
257
	}
257
    
258
 
258
    public String getJSONEmiSchemes(){
259
	public String getJSONEmiSchemes() {
259
    	getEmiSchemes();
260
		getEmiSchemes();
260
    	Double totalAmount = getTotalAmountL();
261
		Double totalAmount = getTotalAmountL();
261
    	List<EmiScheme> schemes = new ArrayList<EmiScheme>();
262
		List<EmiScheme> schemes = new ArrayList<EmiScheme>();
262
    	for(EmiScheme emiScheme : emiSchemes) {
263
		for (EmiScheme emiScheme : emiSchemes) {
263
    		if(emiScheme.getMinAmount() <= totalAmount ) {
264
			if (emiScheme.getMinAmount() <= totalAmount) {
264
    			schemes.add(emiScheme);
265
				schemes.add(emiScheme);
265
    		}
266
			}
266
    	}
267
		}
267
    	Gson gson  = new Gson();
268
		Gson gson = new Gson();
268
    	return gson.toJson(schemes);
269
		return gson.toJson(schemes);
269
    }
270
	}
270
    
271
 
271
    public String getJSONEmiDiscountSchemes(){
272
	public String getJSONEmiDiscountSchemes() {
272
    	try {
273
		try {
273
    	PromotionService.Client pc = new PromotionClient().getClient();
274
			PromotionService.Client pc = new PromotionClient().getClient();
274
    	Gson gson  = new Gson();
275
			Gson gson = new Gson();
275
    	return gson.toJson(pc.getEmiDiscount(userinfo.getCartId()));
276
			return gson.toJson(pc.getEmiDiscount(userinfo.getCartId()));
276
    	}catch (Exception e){
277
		} catch (Exception e) {
277
    		logger.warn("Could not retrive emi based promotions for cart: " + userinfo.getCartId() + ".\n" + e);
278
			logger.warn("Could not retrive emi based promotions for cart: " + userinfo.getCartId() + ".\n" + e);
278
    		return "{}";
279
			return "{}";
279
    	}
280
		}
280
    }
281
	}
281
    
282
 
282
    public static List<EmiScheme> getEmiSchemes(){
283
	public static List<EmiScheme> getEmiSchemes() {
283
    	if (emiSchemes != null) { 
284
		if (emiSchemes != null) {
284
    		return emiSchemes;
285
			return emiSchemes;
285
    	} else {
286
		} else {
286
    		populateEmiSchemes();
287
			populateEmiSchemes();
287
    		return emiSchemes;
288
			return emiSchemes;
288
    	}
289
		}
289
    }
290
	}
290
    
291
 
291
    public static long getGatewayId(long emiSchemeId){
292
	public static long getGatewayId(String paymentOptions) {
292
    	for(EmiScheme scheme: emiSchemes){
293
		String payCode = "";
293
    		if(scheme.getId() == emiSchemeId){
294
		// checking for emis
294
    			return scheme.getGatewayId();
295
		if (paymentOptions.startsWith(PaymentUtils.PAYMENT_TYPE.EMI.toString())) {
295
    		}
296
			payCode = paymentOptions.replace(PaymentUtils.PAYMENT_TYPE.EMI.toString(), "");
296
    	}
297
			for (EmiScheme scheme : emiSchemes) {
297
    	return 0;
298
				if (scheme.getId() == Long.parseLong(payCode)) {
298
    }
299
					return scheme.getGatewayId();
299
    
300
				}
300
    public static double getInterestRate(long emiSchemeId){
301
			}
301
    	for(EmiScheme scheme: emiSchemes){
302
		}
302
    		if(scheme.getId() == emiSchemeId){
303
 
303
    			return scheme.getInterestRate();
304
		// As of on august 2 2016 all the debit,credit and netbanking payments
304
    		}
305
		// have to be redirected to payu.
305
    	}
306
		// so returning 13 as payment gateway
306
    	return 0;
307
		// this can be re-written for other business logic
307
    }
308
		if (paymentOptions.startsWith(PaymentUtils.PAYMENT_TYPE.CC.toString())) {
308
 
309
			// payCode =
309
    public void setAmountZero(boolean amountZero) {
310
			// paymentOptions.replace(PaymentUtils.PAYMENT_TYPE.CC.toString(),
310
        this.amountZero = amountZero;
311
			// "");
311
    }
312
			return 5;
312
 
313
 
313
    public boolean isAmountZero() {
314
		}
314
        return amountZero;
315
		if (paymentOptions.startsWith(PaymentUtils.PAYMENT_TYPE.DC.toString())) {
315
    }
316
			// payCode =
316
    
317
			// paymentOptions.replace(PaymentUtils.PAYMENT_TYPE.CC.toString(),
317
    public static String getEmiSchemesInJSON(){
318
			// "");
318
    	if(emiSchemesInJSON==null){
319
			return 5;
319
    		List<Map<String, Object>> schemeList = new ArrayList<Map<String,Object>>();
320
		}
320
    		for(EmiScheme scheme: getEmiSchemes()){
321
		if (paymentOptions.startsWith(PaymentUtils.PAYMENT_TYPE.NB.toString())) {
321
    			Map<String,Object> arrayMap = new HashMap<String, Object>();
322
			// payCode =
322
    			arrayMap.put("bankId",scheme.getBankId());
323
			// paymentOptions.replace(PaymentUtils.PAYMENT_TYPE.CC.toString(),
323
    			arrayMap.put("bankName",scheme.getBankName());
324
			// "");
324
    			arrayMap.put("chargeType",scheme.getChargeType());
325
			return 5;
325
    			arrayMap.put("chargeValue",scheme.getChargeValue());
326
		}
326
    			arrayMap.put("gatewayId",scheme.getGatewayId());
327
		if (paymentOptions.startsWith(PaymentUtils.PAYMENT_TYPE.WAL.toString())) {
327
    			arrayMap.put("minAmount",scheme.getMinAmount());
328
			payCode = paymentOptions.replace(PaymentUtils.PAYMENT_TYPE.WAL.toString(), "");
328
    			arrayMap.put("tenure",scheme.getTenure());
329
			if (PaymentUtils.PAYU_CC.equals(payCode))
329
    			arrayMap.put("tenureDescription",scheme.getTenureDescription());
330
				return 5;
330
    			arrayMap.put("id",scheme.getId());
331
			return 5;
331
    			arrayMap.put("interestRate",scheme.getInterestRate());
332
		}
332
    			schemeList.add(arrayMap);
333
		if (paymentOptions.startsWith(PaymentUtils.PAYMENT_TYPE.CAS.toString())) {
333
    		}
334
			return 18;
334
    		return new Gson().toJson(schemeList);
335
		}
335
    	} else {
336
		if (paymentOptions.startsWith(PaymentUtils.PAYMENT_TYPE.COD.toString())) {
336
    		return emiSchemesInJSON;
337
			payCode = paymentOptions.replace(PaymentUtils.PAYMENT_TYPE.COD.toString(), "");
337
    	}
338
			if (payCode.equals(IPaymentService.COD)) {
338
    }
339
				return 4;
339
    
340
			}
340
    public boolean isPrivateDealUser(){
341
			if (payCode.equals(IPaymentService.COUPON)) {
341
    	return userinfo.isPrivateDealUser();
342
				return 17;
342
    }
343
			}
-
 
344
		}
-
 
345
 
-
 
346
		return 0;
-
 
347
	}
-
 
348
 
-
 
349
	public static double getInterestRate(long emiSchemeId) {
-
 
350
		for (EmiScheme scheme : emiSchemes) {
-
 
351
			if (scheme.getId() == emiSchemeId) {
-
 
352
				return scheme.getInterestRate();
-
 
353
			}
-
 
354
		}
-
 
355
		return 0;
-
 
356
	}
-
 
357
 
-
 
358
	public void setAmountZero(boolean amountZero) {
-
 
359
		this.amountZero = amountZero;
-
 
360
	}
-
 
361
 
-
 
362
	public boolean isAmountZero() {
-
 
363
		return amountZero;
-
 
364
	}
-
 
365
 
-
 
366
	public static String getEmiSchemesInJSON() {
-
 
367
		if (emiSchemesInJSON == null) {
-
 
368
			List<Map<String, Object>> schemeList = new ArrayList<Map<String, Object>>();
-
 
369
			for (EmiScheme scheme : getEmiSchemes()) {
-
 
370
				Map<String, Object> arrayMap = new HashMap<String, Object>();
-
 
371
				arrayMap.put("bankId", scheme.getBankId());
-
 
372
				arrayMap.put("bankName", scheme.getBankName());
-
 
373
				arrayMap.put("chargeType", scheme.getChargeType());
-
 
374
				arrayMap.put("chargeValue", scheme.getChargeValue());
-
 
375
				arrayMap.put("gatewayId", scheme.getGatewayId());
-
 
376
				arrayMap.put("minAmount", scheme.getMinAmount());
-
 
377
				arrayMap.put("tenure", scheme.getTenure());
-
 
378
				arrayMap.put("tenureDescription", scheme.getTenureDescription());
-
 
379
				arrayMap.put("id", scheme.getId());
-
 
380
				arrayMap.put("interestRate", scheme.getInterestRate());
-
 
381
				schemeList.add(arrayMap);
-
 
382
			}
-
 
383
			return new Gson().toJson(schemeList);
-
 
384
		} else {
-
 
385
			return emiSchemesInJSON;
-
 
386
		}
-
 
387
	}
-
 
388
 
-
 
389
	public boolean isPrivateDealUser() {
-
 
390
		return userinfo.isPrivateDealUser();
-
 
391
	}
343
}
392
}
344
393