Subversion Repositories SmartDukaan

Rev

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

Rev 13545 Rev 22576
Line 28... Line 28...
28
import org.apache.commons.logging.LogFactory;
28
import org.apache.commons.logging.LogFactory;
29
import org.apache.thrift.TException;
29
import org.apache.thrift.TException;
30
import org.springframework.context.ApplicationContext;
30
import org.springframework.context.ApplicationContext;
31
import org.springframework.context.support.ClassPathXmlApplicationContext;
31
import org.springframework.context.support.ClassPathXmlApplicationContext;
32
 
32
 
-
 
33
import com.mongodb.util.Hash;
-
 
34
 
33
public class PaymentServiceHandler implements Iface {
35
public class PaymentServiceHandler implements Iface {
34
    
36
    
35
    private static final Log logger = LogFactory.getLog(PaymentServiceHandler.class);
37
    private static final Log logger = LogFactory.getLog(PaymentServiceHandler.class);
36
 
38
 
37
    
39
    
Line 66... Line 68...
66
	private static final long EBS_GATEWAY_ID = 2;
68
	private static final long EBS_GATEWAY_ID = 2;
67
	private static final long PAYU_GATEWAY_ID = 19;
69
	private static final long PAYU_GATEWAY_ID = 19;
68
	private static final long EBAY_GATEWAY_ID = 16;
70
	private static final long EBAY_GATEWAY_ID = 16;
69
	private static final long SNAPDEAL_GATEWAY_ID = 18;
71
	private static final long SNAPDEAL_GATEWAY_ID = 18;
70
	private static final List<Long> HDFC_EMI_GATEWAY_IDS = Arrays.asList(5L,10L,11L,12L,14L);
72
	private static final List<Long> HDFC_EMI_GATEWAY_IDS = Arrays.asList(5L,10L,11L,12L,14L);
-
 
73
	private static final long WALLET_GATEWAY_ID = 8;
71
	
74
	
72
	ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
75
	ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
73
	PaymentHandler paymentHandler = (PaymentHandler) context.getBean("paymentHandler");
76
	PaymentHandler paymentHandler = (PaymentHandler) context.getBean("paymentHandler");
74
    PaymentRequiringExtraProcessingHandler paymentRequiringExtraProcessingHandler =
77
    PaymentRequiringExtraProcessingHandler paymentRequiringExtraProcessingHandler =
75
        (PaymentRequiringExtraProcessingHandler) context.getBean("paymentRequiringExtraProcessingHandler");
78
        (PaymentRequiringExtraProcessingHandler) context.getBean("paymentRequiringExtraProcessingHandler");
Line 348... Line 351...
348
            return refundHdfcEmiPayment(payment, amount);
351
            return refundHdfcEmiPayment(payment, amount);
349
        }else if (gatewayId == PAYU_GATEWAY_ID) {
352
        }else if (gatewayId == PAYU_GATEWAY_ID) {
350
        	//Refund PayU
353
        	//Refund PayU
351
        	return refundPayUPayment(payment, amount);
354
        	return refundPayUPayment(payment, amount);
352
        	
355
        	
353
        }
356
        } 
-
 
357
        /*else if(gatewayId == WALLET_GATEWAY_ID) {
-
 
358
        	return refundWalletPayment(payment, amount);
-
 
359
        }*/
354
        
360
        
355
        logger.error("We have an captured payment from unknown gateway: " + gatewayId);
361
        logger.error("We have an captured payment from unknown gateway: " + gatewayId);
356
        return false;
362
        return false;
357
    }
363
    }
358
	
364
	
359
	
365
	
-
 
366
	private boolean refundWalletPayment(in.shop2020.payment.domain.Payment payment, double amount) throws PaymentException {
-
 
367
		//TransactionClient tc = new TransactionClient();
-
 
368
		Map<String, String> captureResult = new HashMap<String, String>();
-
 
369
		payment.setGatewayTxnStatus("Refunded to wallet");
-
 
370
		payment.setStatus(PaymentStatus.REFUNDED.getValue());
-
 
371
		payment.setRefundAmount(amount);
-
 
372
		
-
 
373
 
-
 
374
        SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
 
375
        captureResult.put(IPaymentHandler.REFUND_TXN_ID, captureResult.get(IPaymentHandler.REFUND_TXN_ID));
-
 
376
        captureResult.put(IPaymentHandler.REFUND_TIME, captureTimeDateFormatter.format(new Date()));
-
 
377
 
-
 
378
		return true;
-
 
379
	}
-
 
380
	
360
	private boolean refundPayUPayment (
381
	private boolean refundPayUPayment (
361
			in.shop2020.payment.domain.Payment payment, double amount) throws PaymentException{
382
			in.shop2020.payment.domain.Payment payment, double amount) throws PaymentException{
362
		Map<String, String> captureResult = PayuPaymentHandler.refundPayment(payment, amount);
383
		Map<String, String> captureResult = PayuPaymentHandler.refundPayment(payment, amount);
363
		if(captureResult.containsKey(IPaymentHandler.ERROR)){
384
		if(captureResult.containsKey(IPaymentHandler.ERROR)){
364
            payment.setDescription(captureResult.get(IPaymentHandler.ERROR));
385
            payment.setDescription(captureResult.get(IPaymentHandler.ERROR));