Subversion Repositories SmartDukaan

Rev

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

Rev 3583 Rev 3616
Line 196... Line 196...
196
		}
196
		}
197
		return redirectURL;
197
		return redirectURL;
198
	}
198
	}
199
	
199
	
200
	@Override
200
	@Override
-
 
201
    public String initializeHdfcEmiPayment(long merchantPaymentId) throws PaymentException, TException {
-
 
202
        logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
-
 
203
        in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
-
 
204
        String redirectURL;
-
 
205
        try {
-
 
206
            redirectURL = HdfcEmiPaymentHandler.initializeHdfcPayment(payment, this);
-
 
207
        } catch (Exception e) {
-
 
208
            throw new PaymentException(102, "Error while initiliazing payment. Check service log for more details.");
-
 
209
        }
-
 
210
        return redirectURL;
-
 
211
    }
-
 
212
	
-
 
213
	@Override
201
    public long createRefund(long orderId, long merchantTxnId, double amount) throws PaymentException, TException{
214
    public long createRefund(long orderId, long merchantTxnId, double amount) throws PaymentException, TException{
202
	    logger.info("Attempting to create a refund for order: " + orderId);
215
	    logger.info("Attempting to create a refund for order: " + orderId);
203
		List<in.shop2020.payment.domain.Payment> payments = paymentHandler.getPaymentForTxn(merchantTxnId);
216
		List<in.shop2020.payment.domain.Payment> payments = paymentHandler.getPaymentForTxn(merchantTxnId);
204
		if(payments ==null || payments.isEmpty())
217
		if(payments ==null || payments.isEmpty())
205
			throw new PaymentException(104, "No payments found corresponding to the merchant txn " + merchantTxnId);
218
			throw new PaymentException(104, "No payments found corresponding to the merchant txn " + merchantTxnId);
Line 278... Line 291...
278
 
291
 
279
        Map<String, String> attrMap = new HashMap<String, String>();
292
        Map<String, String> attrMap = new HashMap<String, String>();
280
        if (!captureStatus.trim().equals("0") 
293
        if (!captureStatus.trim().equals("0") 
281
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
294
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
282
            // Failure
295
            // Failure
283
            logger.info("Capture attempt failed for HDFC payment with id: " + merchantPaymentId);
296
            logger.error("Capture attempt failed for HDFC payment with id: " + merchantPaymentId);
284
            String description = captureResult.get(IPaymentHandler.ERROR);
297
            String description = captureResult.get(IPaymentHandler.ERROR);
285
            String errorCode = captureResult.get(IPaymentHandler.ERR_CODE);
298
            String errorCode = captureResult.get(IPaymentHandler.ERR_CODE);
286
 
299
 
287
            payment.setDescription(description);
300
            payment.setDescription(description);
288
            payment.setErrorCode(errorCode);
301
            payment.setErrorCode(errorCode);
Line 291... Line 304...
291
            paymentHandler.updatePayment(payment, attrMap);
304
            paymentHandler.updatePayment(payment, attrMap);
292
            createTicketForFailedPayment(payment);
305
            createTicketForFailedPayment(payment);
293
            return false;
306
            return false;
294
        } else {
307
        } else {
295
            // Success
308
            // Success
296
            logger.error("Capture attempt successful for HDFC payment with id: " + merchantPaymentId);
309
            logger.info("Capture attempt successful for HDFC payment with id: " + merchantPaymentId);
297
            payment.setDescription("Payment Captured");
310
            payment.setDescription("Payment Captured");
298
            payment.setGatewayTxnStatus(gatewayStatus);
311
            payment.setGatewayTxnStatus(gatewayStatus);
299
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
312
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
300
            payment.setSuccessTimestamp(new Date());           
313
            payment.setSuccessTimestamp(new Date());           
301
            
314
            
Line 330... Line 343...
330
 
343
 
331
        Map<String, String> attrMap = new HashMap<String, String>();
344
        Map<String, String> attrMap = new HashMap<String, String>();
332
        if (!captureStatus.trim().equals("0") 
345
        if (!captureStatus.trim().equals("0") 
333
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
346
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
334
            // Failure
347
            // Failure
335
            logger.info("Capture attempt failed for HDFC payment with id: " + merchantPaymentId);
348
            logger.error("Capture attempt failed for HDFC payment with id: " + merchantPaymentId);
336
            String description = captureResult.get(IPaymentHandler.ERROR);
349
            String description = captureResult.get(IPaymentHandler.ERROR);
337
            String errorCode = captureResult.get(IPaymentHandler.ERR_CODE);
350
            String errorCode = captureResult.get(IPaymentHandler.ERR_CODE);
338
 
351
 
339
            payment.setDescription(description);
352
            payment.setDescription(description);
340
            payment.setErrorCode(errorCode);
353
            payment.setErrorCode(errorCode);
Line 343... Line 356...
343
            paymentHandler.updatePayment(payment, attrMap);
356
            paymentHandler.updatePayment(payment, attrMap);
344
            createTicketForFailedPayment(payment);
357
            createTicketForFailedPayment(payment);
345
            return false;
358
            return false;
346
        } else {
359
        } else {
347
            // Success
360
            // Success
348
            logger.error("Capture attempt successful for HDFC payment with id: " + merchantPaymentId);
361
            logger.info("Capture attempt successful for HDFC payment with id: " + merchantPaymentId);
349
            payment.setDescription("Payment Captured");
362
            payment.setDescription("Payment Captured");
350
            payment.setGatewayTxnStatus(gatewayStatus);
363
            payment.setGatewayTxnStatus(gatewayStatus);
351
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
364
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
352
            payment.setSuccessTimestamp(new Date());           
365
            payment.setSuccessTimestamp(new Date());           
353
            
366
            
Line 377... Line 390...
377
        String captureStatus = captureResult.get(EbsPaymentHandler.STATUS);
390
        String captureStatus = captureResult.get(EbsPaymentHandler.STATUS);
378
        
391
        
379
        Map<String, String> attrMap = new HashMap<String, String>();
392
        Map<String, String> attrMap = new HashMap<String, String>();
380
        if("".equals(captureStatus)){
393
        if("".equals(captureStatus)){
381
            //Failure
394
            //Failure
-
 
395
            logger.error("Capture attempt failed for EBS payment with id: " + payment.getId());
382
            String description = captureResult.get(EbsPaymentHandler.ERROR);
396
            String description = captureResult.get(EbsPaymentHandler.ERROR);
383
            String errorCode = captureResult.get(EbsPaymentHandler.ERR_CODE);
397
            String errorCode = captureResult.get(EbsPaymentHandler.ERR_CODE);
384
            
398
            
385
            payment.setDescription(description);
399
            payment.setDescription(description);
386
            payment.setErrorCode(errorCode);
400
            payment.setErrorCode(errorCode);
Line 389... Line 403...
389
            paymentHandler.updatePayment(payment, attrMap);
403
            paymentHandler.updatePayment(payment, attrMap);
390
            createTicketForFailedPayment(payment);
404
            createTicketForFailedPayment(payment);
391
            return false;
405
            return false;
392
        }else{
406
        }else{
393
            //Success
407
            //Success
-
 
408
            logger.info("Capture attempt successful for EBS payment with id: " + payment.getId());
394
            payment.setGatewayTxnStatus(captureStatus);
409
            payment.setGatewayTxnStatus(captureStatus);
395
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
410
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
396
            payment.setSuccessTimestamp(new Date());
411
            payment.setSuccessTimestamp(new Date());
397
            
412
            
398
            attrMap.put(IPaymentHandler.CAPTURE_TXN_ID, captureResult.get(IPaymentHandler.CAPTURE_TXN_ID));
413
            attrMap.put(IPaymentHandler.CAPTURE_TXN_ID, captureResult.get(IPaymentHandler.CAPTURE_TXN_ID));