Subversion Repositories SmartDukaan

Rev

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

Rev 3561 Rev 3583
Line 1... Line 1...
1
package in.shop2020.serving.services;
1
package in.shop2020.serving.services;
2
 
2
 
3
import java.util.ArrayList;
3
import java.util.ArrayList;
4
import java.util.HashMap;
-
 
5
import java.util.List;
4
import java.util.List;
6
import java.util.Map;
-
 
7
 
5
 
8
import org.apache.log4j.Logger;
6
import org.apache.log4j.Logger;
9
 
7
 
10
import in.shop2020.payments.Attribute;
8
import in.shop2020.payments.Attribute;
11
import in.shop2020.payments.Payment;
9
import in.shop2020.payments.Payment;
12
import in.shop2020.payments.PaymentStatus;
10
import in.shop2020.payments.PaymentStatus;
13
import in.shop2020.payments.PaymentService.Client;
-
 
14
import in.shop2020.thrift.clients.PaymentClient;
11
import in.shop2020.thrift.clients.PaymentClient;
15
 
12
 
16
public class HdfcPaymentService implements IPaymentService {
13
public class HdfcPaymentService implements IPaymentService {
17
	private static final long serialVersionUID = 1L;
14
	private static final long serialVersionUID = 1L;
18
	private static Logger log = Logger.getLogger(Class.class);
15
	private static Logger log = Logger.getLogger(Class.class);
Line 54... Line 51...
54
			log.error("Error while initializing payment.", e);
51
			log.error("Error while initializing payment.", e);
55
			return PAYMENT_NOT_CREATED;
52
			return PAYMENT_NOT_CREATED;
56
		}
53
		}
57
	}
54
	}
58
	
55
	
59
	public static Map<String, String> capturePayment(Payment payment){
-
 
60
		String amount = "" + payment.getAmount();
-
 
61
		String gatewayPaymentId = payment.getGatewayPaymentId();
-
 
62
		log.info("Capturing amount: Rs " + amount + " for payment Id: " + gatewayPaymentId);
-
 
63
		
-
 
64
		//Prepare resultMap to elicit failure behaviour in case anything goes wrong.
-
 
65
		Map<String, String> resultMap = new HashMap<String, String>();
-
 
66
	    resultMap.put(STATUS, "-2");
-
 
67
	    
-
 
68
		try {
-
 
69
			PaymentClient paymentServiceClient = new PaymentClient();
-
 
70
			Client paymentClient = paymentServiceClient.getClient();
-
 
71
			resultMap = paymentClient.captureHdfcPayment(payment.getPaymentId());
-
 
72
		} catch (Exception e) {
-
 
73
			log.error("Unable to capture payment", e);
-
 
74
			resultMap.put(ERR_CODE, Errors.CONN_FAILURE.code);
-
 
75
			resultMap.put(ERROR, "Unable to capture transaction.");
-
 
76
		}
-
 
77
		
-
 
78
		return resultMap;
-
 
79
	}
-
 
80
	
-
 
81
	public String getRedirectUrl(){
56
	public String getRedirectUrl(){
82
		return this.redirectURL;
57
		return this.redirectURL;
83
	}
58
	}
84
	
59
	
85
	public static void main(String args[]){
60
	public static void main(String args[]){