Subversion Repositories SmartDukaan

Rev

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

Rev 20112 Rev 20278
Line 20... Line 20...
20
	private long paymentId;
20
	private long paymentId;
21
	public HdfcPaymentService() {
21
	public HdfcPaymentService() {
22
	
22
	
23
	}
23
	}
24
	
24
	
25
	public long createPayment(long userId, long txnId, String paymentOption, int gatewayId){
25
	public long createPayment(long userId, long txnId, String paymentOption, int gatewayId, String paymentType){
26
		log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId + " for processing through HDFC");
26
		log.info("Creating payment for the txn#: " + txnId + " for the user: " + userId + " for processing through HDFC");
27
		CommonPaymentService cps = new CommonPaymentService();
27
		CommonPaymentService cps = new CommonPaymentService();
28
		if(!cps.createPayment(userId, txnId, gatewayId)){
28
		if(!cps.createPayment(userId, txnId, gatewayId)){
29
			log.error("Error while creating the basic payment");
29
			log.error("Error while creating the basic payment");
30
			return PAYMENT_NOT_CREATED;
30
			return PAYMENT_NOT_CREATED;
31
		}
31
		}
32
		paymentId = cps.getPaymentId();
32
		paymentId = cps.getPaymentId();
33
		if(paymentOption != null){
33
		if(paymentOption != null){
34
			List<Attribute> attributes = new ArrayList<Attribute>();
34
			List<Attribute> attributes = new ArrayList<Attribute>();
35
			attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
35
			attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
-
 
36
			attributes.add(new Attribute(IPaymentService.PAYMENT_TYPE, paymentType));
36
			
37
			
37
			try {
38
			try {
38
				PaymentClient paymentServiceClient = new PaymentClient();
39
				PaymentClient paymentServiceClient = new PaymentClient();
39
				paymentServiceClient.getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
40
				paymentServiceClient.getClient().updatePaymentDetails(paymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
40
			} catch (Exception e) {
41
			} catch (Exception e) {
Line 48... Line 49...
48
		}
49
		}
49
 
50
 
50
		return paymentId;
51
		return paymentId;
51
	}
52
	}
52
	
53
	
53
	public long createPayment(RechargeOrder rechargeOrder, String paymentOption, String phone) {
54
	public long createPayment(RechargeOrder rechargeOrder, String paymentOption, String phone, String paymentType) {
54
	    log.info("Creating payment for the txn#: " + rechargeOrder.getId() + " for the user: " + rechargeOrder.getUserId() + " for processing through HDFC");
55
	    log.info("Creating payment for the txn#: " + rechargeOrder.getId() + " for the user: " + rechargeOrder.getUserId() + " for processing through HDFC");
55
	    log.info("createPayment phone---- " + phone);
56
	    log.info("createPayment phone---- " + phone);
56
        CommonPaymentService cps = new CommonPaymentService();
57
        CommonPaymentService cps = new CommonPaymentService();
57
        if(!cps.createPayment(rechargeOrder, gatewayId)){
58
        if(!cps.createPayment(rechargeOrder, gatewayId)){
58
            log.error("Error while creating the basic payment");
59
            log.error("Error while creating the basic payment");
59
            return PAYMENT_NOT_CREATED;
60
            return PAYMENT_NOT_CREATED;
60
        }else{
61
        }else{
61
            return initializePayment(rechargeOrder, cps.getPaymentId(), paymentOption, phone);
62
            return initializePayment(rechargeOrder, cps.getPaymentId(), paymentOption, phone, paymentType);
62
        }
63
        }
63
    }
64
    }
64
	
65
	
65
	private long initializePayment(RechargeOrder rechargeOrder, long merchantPaymentId,
66
	private long initializePayment(RechargeOrder rechargeOrder, long merchantPaymentId,
66
            String paymentOption, String phone) {
67
            String paymentOption, String phone, String paymentType) {
67
	    List<Attribute> attributes = new ArrayList<Attribute>();
68
	    List<Attribute> attributes = new ArrayList<Attribute>();
68
        attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
69
        attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
-
 
70
        attributes.add(new Attribute(IPaymentService.PAYMENT_TYPE, paymentType));
69
        log.info("initializePayment phone---- " + phone);
71
        log.info("initializePayment phone---- " + phone);
70
        PaymentClient paymentServiceClient = null;
72
        PaymentClient paymentServiceClient = null;
71
        try {
73
        try {
72
            paymentServiceClient = new PaymentClient();
74
            paymentServiceClient = new PaymentClient();
73
        } catch (Exception e) {
75
        } catch (Exception e) {