Subversion Repositories SmartDukaan

Rev

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

Rev 3583 Rev 6050
Line 3... Line 3...
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.List;
4
import java.util.List;
5
 
5
 
6
import org.apache.log4j.Logger;
6
import org.apache.log4j.Logger;
7
 
7
 
-
 
8
import in.shop2020.model.v1.order.RechargeOrder;
8
import in.shop2020.payments.Attribute;
9
import in.shop2020.payments.Attribute;
9
import in.shop2020.payments.Payment;
10
import in.shop2020.payments.Payment;
10
import in.shop2020.payments.PaymentStatus;
11
import in.shop2020.payments.PaymentStatus;
11
import in.shop2020.thrift.clients.PaymentClient;
12
import in.shop2020.thrift.clients.PaymentClient;
12
 
13
 
Line 30... Line 31...
30
		}else{
31
		}else{
31
			return initializePayment(cps.getPaymentId(), paymentOption);
32
			return initializePayment(cps.getPaymentId(), paymentOption);
32
		}
33
		}
33
	}
34
	}
34
	
35
	
-
 
36
	public long createPayment(RechargeOrder rechargeOrder, String paymentOption) {
-
 
37
	    log.info("Creating payment for the txn#: " + rechargeOrder.getId() + " for the user: " + rechargeOrder.getUserId() + " for processing through HDFC");
-
 
38
        CommonPaymentService cps = new CommonPaymentService();
-
 
39
        if(!cps.createPayment(rechargeOrder, gatewayId)){
-
 
40
            log.error("Error while creating the basic payment");
-
 
41
            return PAYMENT_NOT_CREATED;
-
 
42
        }else{
-
 
43
            return initializePayment(rechargeOrder, cps.getPaymentId(), paymentOption);
-
 
44
        }
-
 
45
    }
-
 
46
	
-
 
47
	private long initializePayment(RechargeOrder rechargeOrder, long merchantPaymentId,
-
 
48
            String paymentOption) {
-
 
49
	    List<Attribute> attributes = new ArrayList<Attribute>();
-
 
50
        attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
-
 
51
        PaymentClient paymentServiceClient = null;
-
 
52
        try {
-
 
53
            paymentServiceClient = new PaymentClient();
-
 
54
        } catch (Exception e) {
-
 
55
            log.error("Error while getting payment client", e);
-
 
56
            return PAYMENT_NOT_CREATED;
-
 
57
        }
-
 
58
        
-
 
59
        try {
-
 
60
            paymentServiceClient.getClient().updatePaymentDetails(merchantPaymentId, null, null, null, null, null, null, null, null, PaymentStatus.INIT, null, attributes);
-
 
61
            this.redirectURL = paymentServiceClient.getClient().doHdfcPaymentForDigitalOrder(merchantPaymentId, rechargeOrder.getId());
-
 
62
            return merchantPaymentId;
-
 
63
        }catch (Exception e) {
-
 
64
            log.error("Error while initializing payment.", e);
-
 
65
            return PAYMENT_NOT_CREATED;
-
 
66
        }
-
 
67
    }
-
 
68
 
35
	private long initializePayment(long merchantPaymentId, String paymentOption){
69
    private long initializePayment(long merchantPaymentId, String paymentOption){
36
		List<Attribute> attributes = new ArrayList<Attribute>();
70
		List<Attribute> attributes = new ArrayList<Attribute>();
37
		attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
71
		attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
38
		PaymentClient paymentServiceClient = null;
72
		PaymentClient paymentServiceClient = null;
39
		try {
73
		try {
40
			paymentServiceClient = new PaymentClient();
74
			paymentServiceClient = new PaymentClient();
Line 83... Line 117...
83
		
117
		
84
		//This test tries to capture an already captured payment.
118
		//This test tries to capture an already captured payment.
85
		//capturePayment(payment, "9644960021411730");	//Result: !ERROR!-GW00177-Failed Capture Greater Than Auth check.
119
		//capturePayment(payment, "9644960021411730");	//Result: !ERROR!-GW00177-Failed Capture Greater Than Auth check.
86
	}
120
	}
87
}
121
}
88
 
-