Subversion Repositories SmartDukaan

Rev

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

Rev 3010 Rev 3126
Line 9... Line 9...
9
 
9
 
10
import in.shop2020.payments.Attribute;
10
import in.shop2020.payments.Attribute;
11
import in.shop2020.payments.Payment;
11
import in.shop2020.payments.Payment;
12
import in.shop2020.payments.PaymentStatus;
12
import in.shop2020.payments.PaymentStatus;
13
import in.shop2020.payments.PaymentService.Client;
13
import in.shop2020.payments.PaymentService.Client;
14
import in.shop2020.thrift.clients.PaymentServiceClient;
14
import in.shop2020.thrift.clients.PaymentClient;
15
 
15
 
16
public class HdfcPaymentService implements IPaymentService {
16
public class HdfcPaymentService implements IPaymentService {
17
	private static final long serialVersionUID = 1L;
17
	private static final long serialVersionUID = 1L;
18
	private static Logger log = Logger.getLogger(Class.class);
18
	private static Logger log = Logger.getLogger(Class.class);
19
	
19
	
Line 36... Line 36...
36
	}
36
	}
37
	
37
	
38
	private long initializePayment(long merchantPaymentId, String paymentOption){
38
	private long initializePayment(long merchantPaymentId, String paymentOption){
39
		List<Attribute> attributes = new ArrayList<Attribute>();
39
		List<Attribute> attributes = new ArrayList<Attribute>();
40
		attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
40
		attributes.add(new Attribute(IPaymentService.PAYMENT_METHOD, paymentOption));
41
		PaymentServiceClient paymentServiceClient = null;
41
		PaymentClient paymentServiceClient = null;
42
		try {
42
		try {
43
			paymentServiceClient = new PaymentServiceClient();
43
			paymentServiceClient = new PaymentClient();
44
		} catch (Exception e) {
44
		} catch (Exception e) {
45
			log.error("Error while getting payment client", e);
45
			log.error("Error while getting payment client", e);
46
			return PAYMENT_NOT_CREATED;
46
			return PAYMENT_NOT_CREATED;
47
		}
47
		}
48
		
48
		
Line 64... Line 64...
64
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
64
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
65
		Map<String, String> resultMap = new HashMap<String, String>();
65
		Map<String, String> resultMap = new HashMap<String, String>();
66
	    resultMap.put(STATUS, "-2");
66
	    resultMap.put(STATUS, "-2");
67
	    
67
	    
68
		try {
68
		try {
69
			PaymentServiceClient paymentServiceClient = new PaymentServiceClient();
69
			PaymentClient paymentServiceClient = new PaymentClient();
70
			Client paymentClient = paymentServiceClient.getClient();
70
			Client paymentClient = paymentServiceClient.getClient();
71
			resultMap = paymentClient.captureHdfcPayment(payment.getPaymentId());
71
			resultMap = paymentClient.captureHdfcPayment(payment.getPaymentId());
72
		} catch (Exception e) {
72
		} catch (Exception e) {
73
			log.error("Unable to capture payment", e);
73
			log.error("Unable to capture payment", e);
74
			resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
74
			resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);