Subversion Repositories SmartDukaan

Rev

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

Rev 6228 Rev 6233
Line 367... Line 367...
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
            String phone, 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 {
377
            initializePayment(pipe, merchantPaymentId, amount, true);
377
            initializePayment(pipe, merchantPaymentId, amount, true);
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, phone);
388
            attributes = getAttributesAndSetUdfs(pipe, rechargeOrder, merchantPaymentId.toString(), 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, String phone) throws TransactionServiceException, TException {
419
    private static List<Attribute> getAttributesAndSetUdfs(e24PaymentPipe pipe, RechargeOrder rechargeOrder, String merchantPaymentId, 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
        Address address = null;
425
        Address address = null;
426
        //get udfs
426
        //get udfs
427
        if (phone == null || phone.isEmpty()) {
427
        if (!(phone == null) && !(phone.isEmpty())) {
428
            //Remember in RechargePaymentController we kept phone set only for a specific case.
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.
429
            //This is the case where we don't need to get the address and can safely set the phone number only.
430
 
430
 
431
            contactNumber = phone;
431
            contactNumber = phone;
432
            email = rechargeOrder.getUserEmailId();
432
            email = rechargeOrder.getUserEmailId();
433
            billingAddress.append(" ");
433
            billingAddress.append(" ");
434
            billingAddress.append("110001");
434
            billingAddress.append("110001");
435
            billingAddress.append(" " + "Delhi");//city
435
            billingAddress.append(" " + "Delhi");//city
436
            billingAddress.append(" " + email);//line1
436
            billingAddress.append(" " + merchantPaymentId);//line1
437
            billingAddress.append(" " + email);//line2
437
            billingAddress.append(" " + merchantPaymentId);//line2
438
            billingAddress.append(" " + email);//state
438
            billingAddress.append(" " + merchantPaymentId);//state
439
        } else {
439
        } else {
440
            try {
440
            try {
441
                UserClient userClient = new UserClient();
441
                UserClient userClient = new UserClient();
442
                address = userClient.getClient().getAddressById(userClient.getClient().getDefaultAddressId(rechargeOrder.getUserId()));
442
                address = userClient.getClient().getAddressById(userClient.getClient().getDefaultAddressId(rechargeOrder.getUserId()));
443
            } catch (Exception e) {
443
            } catch (Exception e) {