Subversion Repositories SmartDukaan

Rev

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

Rev 6091 Rev 6228
Line 366... Line 366...
366
		}
366
		}
367
		return udfString;
367
		return udfString;
368
	}
368
	}
369
 
369
 
370
    public static String initializeHdfcPayment(in.shop2020.payment.domain.Payment payment, RechargeOrder rechargeOrder,
370
    public static String initializeHdfcPayment(in.shop2020.payment.domain.Payment payment, RechargeOrder rechargeOrder,
371
            PaymentServiceHandler paymentServiceHandler) throws Exception {
371
            String phone, PaymentServiceHandler paymentServiceHandler) throws Exception {
372
        long merchantPaymentId = payment.getId();
372
        long merchantPaymentId = payment.getId();
373
        double amount = payment.getAmount();
373
        double amount = payment.getAmount();
374
        e24PaymentPipe pipe = new e24PaymentPipe();
374
        e24PaymentPipe pipe = new e24PaymentPipe();
375
        
375
        
376
        try {
376
        try {
Line 383... Line 383...
383
            throw e1;   //Payment couldn't be initialized. Will be redirected to the shipping page.
383
            throw e1;   //Payment couldn't be initialized. Will be redirected to the shipping page.
384
        }
384
        }
385
        
385
        
386
        List<Attribute> attributes = null;
386
        List<Attribute> attributes = null;
387
        try {
387
        try {
388
            attributes = getAttributesAndSetUdfs(pipe, rechargeOrder);
388
            attributes = getAttributesAndSetUdfs(pipe, rechargeOrder, phone);
389
        } catch (TransactionServiceException e1) {
389
        } catch (TransactionServiceException e1) {
390
            log.error("Error while setting udfs to payment.", e1);
390
            log.error("Error while setting udfs to payment.", e1);
391
            throw e1;   //Payment couldn't be initialized. Will be redirected to the shipping page.
391
            throw e1;   //Payment couldn't be initialized. Will be redirected to the shipping page.
392
        } catch (TException e1) {
392
        } catch (TException e1) {
393
            log.error("Error while setting udfs to payment.", e1);
393
            log.error("Error while setting udfs to payment.", e1);
Line 414... Line 414...
414
        //If the code reaches here, the payment initialization was not successful and we've not returned the redirect URL.
414
        //If the code reaches here, the payment initialization was not successful and we've not returned the redirect URL.
415
        //Throw the exception so that any failovers can happen.
415
        //Throw the exception so that any failovers can happen.
416
        throw new PaymentException(115, "Unable to initialize HDFC payment");
416
        throw new PaymentException(115, "Unable to initialize HDFC payment");
417
    }
417
    }
418
 
418
 
419
    private static List<Attribute> getAttributesAndSetUdfs(e24PaymentPipe pipe, RechargeOrder rechargeOrder) throws TransactionServiceException, TException {
419
    private static List<Attribute> getAttributesAndSetUdfs(e24PaymentPipe pipe, RechargeOrder rechargeOrder, String phone) throws TransactionServiceException, TException {
420
        
420
 
421
        StringBuilder orderDetails = new StringBuilder();
421
        StringBuilder orderDetails = new StringBuilder();
422
        StringBuilder billingAddress = new StringBuilder();
422
        StringBuilder billingAddress = new StringBuilder();
423
        String email = "";
423
        String email = "";
424
        String contactNumber = "";
424
        String contactNumber = "";
425
        
-
 
426
        //get udfs
-
 
427
        Address address = null;
425
        Address address = null;
-
 
426
        //get udfs
-
 
427
        if (phone == null || phone.isEmpty()) {
-
 
428
            //Remember in RechargePaymentController we kept phone set only for a specific case.
-
 
429
            //This is the case where we dont need to get the address and can safely set the phone number only.
-
 
430
 
-
 
431
            contactNumber = phone;
-
 
432
            email = rechargeOrder.getUserEmailId();
-
 
433
            billingAddress.append(" ");
-
 
434
            billingAddress.append("110001");
-
 
435
            billingAddress.append(" " + "Delhi");//city
-
 
436
            billingAddress.append(" " + email);//line1
-
 
437
            billingAddress.append(" " + email);//line2
-
 
438
            billingAddress.append(" " + email);//state
-
 
439
        } else {
428
        try {
440
            try {
429
            UserClient userClient = new UserClient();
441
                UserClient userClient = new UserClient();
430
            address = userClient.getClient().getAddressById(userClient.getClient().getDefaultAddressId(rechargeOrder.getUserId()));
442
                address = userClient.getClient().getAddressById(userClient.getClient().getDefaultAddressId(rechargeOrder.getUserId()));
431
        } catch (Exception e) {
443
            } catch (Exception e) {
432
            log.error("Unable to get transaction details", e);
444
                log.error("Unable to get transaction details", e);
433
        }
445
            }
-
 
446
 
434
        
447
 
435
        contactNumber= address.getPhone();
448
            contactNumber= address.getPhone();
436
        email = rechargeOrder.getUserEmailId();
449
            email = rechargeOrder.getUserEmailId();
437
        billingAddress.append(" ");
450
            billingAddress.append(" ");
438
        if(address.getPin()!=null){
451
            if(address.getPin()!=null){
439
            billingAddress.append(address.getPin());
452
                billingAddress.append(address.getPin());
440
        }
453
            }
441
        if(address.getCity()!=null){
454
            if(address.getCity()!=null){
442
            billingAddress.append(" " + address.getCity());
455
                billingAddress.append(" " + address.getCity());
443
        }
456
            }
444
        if(address.getLine1()!=null){
457
            if(address.getLine1()!=null){
445
            billingAddress.append(" " + address.getLine1());
458
                billingAddress.append(" " + address.getLine1());
446
        }
459
            }
447
        if(address.getLine2()!=null){
460
            if(address.getLine2()!=null){
448
            billingAddress.append(" " + address.getLine2());
461
                billingAddress.append(" " + address.getLine2());
449
        }
462
            }
450
        if(address.getState()!=null){
463
            if(address.getState()!=null){
451
            billingAddress.append(" " + address.getState());
464
                billingAddress.append(" " + address.getState());
-
 
465
            }
-
 
466
 
452
        }
467
        }
453
        orderDetails.append("Recharge : " + rechargeOrder.getDisplayId());
468
        orderDetails.append("Recharge : " + rechargeOrder.getDisplayId());
454
        orderDetails.append(" ");
469
        orderDetails.append(" ");
455
        
470
        
456
        Random random = new Random();
471
        Random random = new Random();