Subversion Repositories SmartDukaan

Rev

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

Rev 6983 Rev 10470
Line 36... Line 36...
36
    private static final int CAPTURE_STATUS_FOR_CONNECTION_ISSUE = -1;
36
    private static final int CAPTURE_STATUS_FOR_CONNECTION_ISSUE = -1;
37
 
37
 
38
    private static Logger log = Logger.getLogger(HdfcEmiPaymentHandler.class);
38
    private static Logger log = Logger.getLogger(HdfcEmiPaymentHandler.class);
39
 
39
 
40
    private static String responseURL;
40
    private static String responseURL;
-
 
41
    private static String mresponseURL;
41
    private static String errorURL;
42
    private static String errorURL;
-
 
43
    private static String merrorURL;
42
    private static final String regex = "[^a-zA-Z0-9\\s\\-\\@\\/\\.]";
44
    private static final String regex = "[^a-zA-Z0-9\\s\\-\\@\\/\\.]";
43
    private static final String replacement = " ";
45
    private static final String replacement = " ";
44
    private static final int MAX_UDF_LENGTH = 30;
46
    private static final int MAX_UDF_LENGTH = 30;
45
    private static final String currencyCode = "356";
47
    private static final String currencyCode = "356";
46
	private static final String resourceFileName = "resource.cgn";
48
	private static final String resourceFileName = "resource.cgn";
Line 85... Line 87...
85
					outStream.write(buf,0,len);
87
					outStream.write(buf,0,len);
86
				outStream.close();
88
				outStream.close();
87
				inputStream.close();
89
				inputStream.close();
88
	
90
	
89
				responseURL = ConfigClient.getClient().get("emi_payment_response_url");
91
				responseURL = ConfigClient.getClient().get("emi_payment_response_url");
-
 
92
				mresponseURL = ConfigClient.getClient().get("m_emi_payment_response_url");
90
	            errorURL = ConfigClient.getClient().get("emi_payment_error_url");
93
	            errorURL = ConfigClient.getClient().get("emi_payment_error_url");
-
 
94
	            merrorURL = ConfigClient.getClient().get("m_emi_payment_error_url");
91
	        } catch (ConfigException e) {
95
	        } catch (ConfigException e) {
92
	            log.error("Unable to get data from config server.");
96
	            log.error("Unable to get data from config server.");
93
	        } catch (FileNotFoundException e) {
97
	        } catch (FileNotFoundException e) {
94
				// TODO Auto-generated catch block
98
				// TODO Auto-generated catch block
95
				e.printStackTrace();
99
				e.printStackTrace();
Line 245... Line 249...
245
                        
249
                        
246
        return resultMap;
250
        return resultMap;
247
    }
251
    }
248
    
252
    
249
    
253
    
250
    public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler) throws Exception{
254
    public static String initializeHdfcPayment(Payment payment, PaymentServiceHandler handler, boolean isMobile) throws Exception{
251
        long merchantPaymentId = payment.getId();
255
        long merchantPaymentId = payment.getId();
252
        double amount = payment.getAmount();
256
        double amount = payment.getAmount();
253
        e24PaymentPipe pipe = new e24PaymentPipe();
257
        e24PaymentPipe pipe = new e24PaymentPipe();
254
        
258
        
255
        try {
259
        try {
256
            initializePayment(pipe, merchantPaymentId, amount, payment.getGatewayId());
260
            initializePayment(pipe, merchantPaymentId, amount, payment.getGatewayId(), isMobile);
257
        } catch (ShoppingCartException e1) {
261
        } catch (ShoppingCartException e1) {
258
            log.error("Error while creating hdfc payment.", e1);
262
            log.error("Error while creating hdfc payment.", e1);
259
            throw e1;    //Payment couldn't be initialized. Will be redirected to the shipping page.
263
            throw e1;    //Payment couldn't be initialized. Will be redirected to the shipping page.
260
        } catch (TException e1) {
264
        } catch (TException e1) {
261
            log.error("Error while creating hdfc payment.", e1);
265
            log.error("Error while creating hdfc payment.", e1);
Line 388... Line 392...
388
        attributes.add(attribute5);
392
        attributes.add(attribute5);
389
        
393
        
390
        return attributes;
394
        return attributes;
391
    }
395
    }
392
    
396
    
393
    private static void initializePayment(e24PaymentPipe pipe, long merchantPaymentId, double amounta, long gatewayId) throws ShoppingCartException, TException{
397
    private static void initializePayment(e24PaymentPipe pipe, long merchantPaymentId, double amounta, long gatewayId, boolean isMobile) throws ShoppingCartException, TException{
394
    	String aliasName = null;
398
    	String aliasName = null;
395
		try {
399
		try {
396
			aliasName = ConfigClient.getClient().get("emi_payment_alias_name" + gatewayId);
400
			aliasName = ConfigClient.getClient().get("emi_payment_alias_name" + gatewayId);
397
		} catch (ConfigException e1) {
401
		} catch (ConfigException e1) {
398
			e1.printStackTrace();
402
			e1.printStackTrace();
Line 411... Line 415...
411
    
415
    
412
        pipe.setAction(ActionType.AUTH.value());            //mandatory 
416
        pipe.setAction(ActionType.AUTH.value());            //mandatory 
413
        String ac=pipe.getAction();
417
        String ac=pipe.getAction();
414
        log.info("Action= " +ac);
418
        log.info("Action= " +ac);
415
    
419
    
416
        pipe.setResponseURL( responseURL ); //mandatory
-
 
417
        String at=pipe.getResponseURL();
-
 
418
        log.info("ResponseURL= "+at);
-
 
419
    
420
    
420
        //pipe.setErrorURL( errorURL + "?paymentId=" + merchantPaymentId );     //mandatory
421
        //pipe.setErrorURL( errorURL + "?paymentId=" + merchantPaymentId );     //mandatory
-
 
422
        if(isMobile) {
-
 
423
        	pipe.setErrorURL( merrorURL);
-
 
424
        	pipe.setResponseURL( mresponseURL ); //mandatory
-
 
425
        }else {
-
 
426
        	pipe.setResponseURL( responseURL ); //mandatory
421
        pipe.setErrorURL( errorURL);
427
        	pipe.setErrorURL( errorURL);
-
 
428
        }
422
        String ak=pipe.getErrorURL();
429
        String ak=pipe.getErrorURL();
423
        log.info("ErrorURL= " + ak);
430
        log.info("ErrorURL= " + ak);
-
 
431
        String at=pipe.getResponseURL();
-
 
432
        log.info("ResponseURL= "+at);
424
    
433
    
425
    
434
    
426
        pipe.setAmt(amount);        
435
        pipe.setAmt(amount);        
427
        String ap=pipe.getAmt();
436
        String ap=pipe.getAmt();
428
        log.info("Amt= " + ap);
437
        log.info("Amt= " + ap);