Subversion Repositories SmartDukaan

Rev

Rev 8618 | Rev 8907 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1946 chandransh 1
package in.shop2020.payment.service.handler;
2
 
6050 anupam.sin 3
import in.shop2020.model.v1.order.RechargeOrder;
3578 mandeep.dh 4
import in.shop2020.payment.domain.Refund;
5
import in.shop2020.payment.handler.PaymentGatewayHandler;
6
import in.shop2020.payment.handler.PaymentHandler;
4008 mandeep.dh 7
import in.shop2020.payment.handler.PaymentRequiringExtraProcessingHandler;
3578 mandeep.dh 8
import in.shop2020.payment.handler.RefundHandler;
9
import in.shop2020.payments.Attribute;
4008 mandeep.dh 10
import in.shop2020.payments.ExtraPaymentProcessingType;
3578 mandeep.dh 11
import in.shop2020.payments.Payment;
12
import in.shop2020.payments.PaymentException;
13
import in.shop2020.payments.PaymentGateway;
14
import in.shop2020.payments.PaymentService.Iface;
15
import in.shop2020.payments.PaymentStatus;
6050 anupam.sin 16
import in.shop2020.thrift.clients.TransactionClient;
3578 mandeep.dh 17
 
3010 chandransh 18
import java.text.SimpleDateFormat;
1946 chandransh 19
import java.util.ArrayList;
6448 rajveer 20
import java.util.Arrays;
1946 chandransh 21
import java.util.Date;
22
import java.util.HashMap;
23
import java.util.List;
24
import java.util.Map;
25
 
8618 rajveer 26
import org.apache.commons.logging.Log;
27
import org.apache.commons.logging.LogFactory;
1946 chandransh 28
import org.apache.thrift.TException;
29
import org.springframework.context.ApplicationContext;
30
import org.springframework.context.support.ClassPathXmlApplicationContext;
31
 
32
public class PaymentServiceHandler implements Iface {
3010 chandransh 33
 
8618 rajveer 34
    private static final Log logger = LogFactory.getLog(PaymentServiceHandler.class);
35
 
3010 chandransh 36
 
37
    /**
38
     * Enum of all statuses that can be returned by the HDFC gateway
39
     * 
40
     * @author Chandranshu
41
     * 
42
     */
43
    private enum HdfcPaymentReturnStatus{
44
        APPROVED("APPROVED"),
45
        NOT_APPROVED("NOT APPROVED"),
46
        CAPTURED("CAPTURED"),
47
        NOT_CAPTURED ("NOT CAPTURED"),
48
        CANCELLED ("CANCELLED"),
49
        DENIED_BY_RISK("DENIED BY RISK"),
50
        HOST_TIMEOUT("HOST TIMEOUT");
51
        private String value;
52
        HdfcPaymentReturnStatus(String value) {
53
            this.value = value;
54
        }
55
        public String value(){
56
            return this.value;
57
        }
58
    }
59
 
2391 chandransh 60
	public static final long PAYMENT_NOT_CREATED = -1;
61
 
3010 chandransh 62
	private static final long HDFC_GATEWAY_ID = 1;
63
	private static final long EBS_GATEWAY_ID = 2;
8208 amar.kumar 64
	private static final long EBAY_GATEWAY_ID = 16;
8488 amar.kumar 65
	private static final long SNAPDEAL_GATEWAY_ID = 18;
7042 amar.kumar 66
	private static final List<Long> HDFC_EMI_GATEWAY_IDS = Arrays.asList(5L,10L,11L,12L,14L);
3010 chandransh 67
 
4651 rajveer 68
	ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
1946 chandransh 69
	PaymentHandler paymentHandler = (PaymentHandler) context.getBean("paymentHandler");
4008 mandeep.dh 70
    PaymentRequiringExtraProcessingHandler paymentRequiringExtraProcessingHandler =
71
        (PaymentRequiringExtraProcessingHandler) context.getBean("paymentRequiringExtraProcessingHandler");
72
 
73
    PaymentGatewayHandler paymentGatewayHandler = (PaymentGatewayHandler) context.getBean("paymentGatewayHandler");
2747 chandransh 74
	RefundHandler refundHandler = (RefundHandler) context.getBean("refundHandler");
1946 chandransh 75
 
4651 rajveer 76
	public void setDataSourceUrl(String dbHost){
77
		org.apache.commons.dbcp.BasicDataSource ds = (org.apache.commons.dbcp.BasicDataSource)context.getBean("dataSource");
78
		ds.setUrl(dbHost);
79
	}
80
 
81
	public String getDataSourceUrl(){
82
		org.apache.commons.dbcp.BasicDataSource ds = (org.apache.commons.dbcp.BasicDataSource)context.getBean("dataSource");
83
		return ds.getUrl();
84
	}
85
 
1946 chandransh 86
	@Override
6050 anupam.sin 87
	public long createPayment(long userId, double amount, long gatewayId, long txnId, boolean isDigital) throws PaymentException, TException {
3010 chandransh 88
	    logger.info("Creating payment corresponding to our txn id:" + txnId);
1946 chandransh 89
		in.shop2020.payment.domain.Payment payment = new in.shop2020.payment.domain.Payment();
90
		payment.setUserId(userId);
91
		payment.setAmount(amount);
92
		payment.setGatewayId(gatewayId);
93
		payment.setMerchantTxnId(txnId);
94
		payment.setStatus(PaymentStatus.INIT.getValue());
6050 anupam.sin 95
		payment.setDigital(isDigital);
1946 chandransh 96
 
97
		return paymentHandler.insertPayment(payment);
98
	}
99
 
100
	@Override
101
	public List<Payment> getPaymentsForUser(long userId, long fromTime, long toTime, PaymentStatus status, long gatewayId) throws PaymentException, TException {
3010 chandransh 102
	    logger.info("Getting payments from " + fromTime + " to " + toTime + " for user: " + userId);
2291 chandransh 103
		int statusValue = -1;
104
		if(status != null)
105
			statusValue = status.getValue();
106
		else
107
			statusValue = -1;
108
		return getThriftPayments(paymentHandler.getPaymentsForUser(userId, fromTime, toTime, statusValue, gatewayId));
1946 chandransh 109
	}
110
 
111
	@Override
112
	public List<Payment> getPayments(long fromTime, long toTime, PaymentStatus status, long gatewayId) throws PaymentException,	TException {
3010 chandransh 113
	    logger.info("Getting payments from " + fromTime + " to " + toTime);
2291 chandransh 114
		int statusValue = -1;
115
		if(status != null)
116
			statusValue = status.getValue();
117
		else
118
			statusValue = -1;
119
		return getThriftPayments(paymentHandler.getPayments(fromTime, toTime, statusValue, gatewayId));
1946 chandransh 120
	}
4141 chandransh 121
 
122
	@Override
123
	public List<Payment> getPaymentsByCapturedDate(long fromTime, long toTime, long gatewayId) throws PaymentException, TException {
124
		logger.info("Getting payments from " + fromTime + " to " + toTime + " for " + gatewayId);
125
		return getThriftPayments(paymentHandler.getPaymentsByCapturedDate(fromTime, toTime, gatewayId));
126
	}
1946 chandransh 127
 
128
	@Override
129
	public PaymentGateway getPaymentGateway(long id) throws PaymentException, TException {
3010 chandransh 130
	    logger.info("Getting payment gateway with id:" + id);
2291 chandransh 131
		return paymentGatewayHandler.getPaymentGateway(id).getThriftPaymentGateway();
1946 chandransh 132
	}
4600 varun.gupt 133
 
1946 chandransh 134
	@Override
4600 varun.gupt 135
	public List<PaymentGateway> getActivePaymentGateways() throws PaymentException, TException {
136
	    logger.info("Getting all active payment gateways");
137
	    return getThriftPaymentGateways(paymentGatewayHandler.getActivePaymentGateways());
138
	}
139
 
140
	@Override
1946 chandransh 141
	public Payment getPayment(long id) throws PaymentException, TException {
3010 chandransh 142
	    logger.info("Getting payment with id: " + id);
1946 chandransh 143
		return paymentHandler.getPayment(id).getThriftPayment();
144
	}
145
 
146
	@Override
147
	public List<Payment> getPaymentForTxnId(long txnId) throws PaymentException, TException {
3010 chandransh 148
	    logger.info("Getting payment for the txn id: " + txnId);
1946 chandransh 149
		return getThriftPayments(paymentHandler.getPaymentForTxn(txnId));
150
	}
4600 varun.gupt 151
 
152
	@Override
7049 anupam.sin 153
    public List<Payment> getPaymentForRechargeTxnId(long txnId) throws PaymentException, TException {
154
        logger.info("Getting payment for the txn id: " + txnId);
155
        return getThriftPayments(paymentHandler.getPaymentForRechargeTxn(txnId));
156
    }
157
 
158
	@Override
4600 varun.gupt 159
	public Payment getSuccessfulPaymentForTxnId(long txnId) throws PaymentException, TException {
160
 
161
		for (Payment payment: getPaymentForTxnId(txnId))	{
162
			if (payment.getStatus() == PaymentStatus.SUCCESS || payment.getStatus() == PaymentStatus.PARTIALLY_CAPTURED)	{
163
				return payment;
164
			}
165
		}
166
		return null;
167
	}
1946 chandransh 168
 
169
	@Override
170
	public boolean updatePaymentDetails(long id, String gatewayPaymentId,
171
			String sessionId, String gatewayTxnStatus, String description,
172
			String gatewayTxnId, String authCode, String referenceCode,
173
			String errorCode, PaymentStatus status, String gatewayTxnDate,
174
			List<Attribute> attributes) throws PaymentException, TException {
3010 chandransh 175
	    logger.info("Updating details of payment id: " + id);
1946 chandransh 176
		in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(id);
177
		payment.setGatewayPaymentId(gatewayPaymentId);
178
		payment.setSessionId(sessionId);
179
		payment.setGatewayTxnStatus(gatewayTxnStatus);
180
		payment.setDescription(description);
181
		payment.setGatewayTxnId(gatewayTxnId);
182
		payment.setAuthCode(authCode);
183
		payment.setReferenceCode(referenceCode);
184
		payment.setErrorCode(errorCode);
185
		if(status!=null){
186
			payment.setStatus(status.getValue());
187
			if(status.equals(PaymentStatus.SUCCESS))
188
				payment.setSuccessTimestamp(new Date());
3578 mandeep.dh 189
			else if(status.equals(PaymentStatus.FAILED)) {
190
			    payment.setErrorTimestamp(new Date());
4421 mandeep.dh 191
			    persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
3578 mandeep.dh 192
			}
4421 mandeep.dh 193
			else if (status.equals(PaymentStatus.PROVISIONALLY_CAPTURED)) {
194
			    // FIXME different column to note provisional capture timestamp
195
			    // FIXME Requires extra processing at Crm end for actual manual capture
196
			    payment.setProvisionalCaptureTimestamp(new Date());
197
			    persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.PENDING_CAPTURE);
198
			}
1946 chandransh 199
		}
200
 
201
		payment.setGatewayTxnDate(gatewayTxnDate);
202
 
203
		Map<String, String> attrMap = new HashMap<String, String>();
2272 rajveer 204
		if(attributes != null){
205
			for(Attribute attribute : attributes){
206
				attrMap.put(attribute.getName(), attribute.getValue());
207
			}
1946 chandransh 208
		}
209
 
210
		paymentHandler.updatePayment(payment, attrMap);
211
		return true;
212
	}
213
 
3649 mandeep.dh 214
	/**
4008 mandeep.dh 215
	 * Persists a given payment Id in another table for future processing by CRM etc.
216
	 * Failed payments generally require a follow-up to help customers through our
217
	 * CRM-Outbound team.
3649 mandeep.dh 218
	 *
219
	 * @param payment  the payment object that failed.
4421 mandeep.dh 220
	 * @param type TODO
3649 mandeep.dh 221
	 */
4421 mandeep.dh 222
	private void persistPaymentRequiringExtraProcessing(in.shop2020.payment.domain.Payment payment, ExtraPaymentProcessingType type) {
4008 mandeep.dh 223
	    try {
4421 mandeep.dh 224
            paymentRequiringExtraProcessingHandler.insert(payment.getId(), type);
4008 mandeep.dh 225
        } catch (Exception e) {
226
            logger.error("Could not persist payment: " + payment.getId(), e);
3578 mandeep.dh 227
        }
228
    }
229
 
230
    @Override
1946 chandransh 231
	public List<Double> getSuccessfulPaymentsAmountRange() throws TException {
3010 chandransh 232
	    logger.info("Getting the range of successful payments.");
1946 chandransh 233
		List<Double> minMaxAmounts = new ArrayList<Double>();
234
		Map<String, Float> minMax = paymentHandler.getMinMaxPaymentAmount();
235
		minMaxAmounts.add(Double.parseDouble(Float.toString(minMax.get("MIN"))));
236
		minMaxAmounts.add(Double.parseDouble(Float.toString(minMax.get("MAX"))));
237
		return minMaxAmounts;
238
	}
239
 
6050 anupam.sin 240
    @Override
241
    public String initializeHdfcPayment(long merchantPaymentId) throws PaymentException, TException {
242
        logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
243
        in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
244
        String redirectURL;
245
        try {
246
            redirectURL = HdfcPaymentHandler.initializeHdfcPayment(payment, this);
247
        } catch (Exception e) {
248
            throw new PaymentException(102, "Error while initiliazing payment. Check service log for more details.");
249
        }
250
        return redirectURL;
251
    }
252
 
253
    @Override
6228 anupam.sin 254
	public String doHdfcPaymentForDigitalOrder(long merchantPaymentId, long rechargeOrderId, String phone) throws PaymentException, TException {
6050 anupam.sin 255
        logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
256
        in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
257
        TransactionClient tc = new TransactionClient();
258
        String redirectURL;
259
        RechargeOrder rechargeOrder;
260
        try {
261
            rechargeOrder = tc.getClient().getRechargeOrder(rechargeOrderId);
6228 anupam.sin 262
            redirectURL = HdfcPaymentHandler.initializeHdfcPayment(payment, rechargeOrder, phone, this);
6050 anupam.sin 263
        } catch (Exception e) {
264
            throw new PaymentException(102, "Error while initiliazing payment. Check service log for more details.");
265
        }
266
 
267
        return redirectURL;
268
    }
2391 chandransh 269
 
270
	@Override
3616 chandransh 271
    public String initializeHdfcEmiPayment(long merchantPaymentId) throws PaymentException, TException {
272
        logger.info("Initializing HDFC payment with id: " + merchantPaymentId);
273
        in.shop2020.payment.domain.Payment payment = paymentHandler.getPayment(merchantPaymentId);
274
        String redirectURL;
275
        try {
276
            redirectURL = HdfcEmiPaymentHandler.initializeHdfcPayment(payment, this);
277
        } catch (Exception e) {
278
            throw new PaymentException(102, "Error while initiliazing payment. Check service log for more details.");
279
        }
280
        return redirectURL;
281
    }
282
 
6486 rajveer 283
	@Override
284
	public synchronized boolean refundPayment(long merchantTxnId, double amount, boolean isDigital) throws PaymentException, TException {
6482 rajveer 285
        logger.info("Attempting to refund payment of amount " + amount + " corresponding to our transaction " + merchantTxnId);
8409 rajveer 286
        List<in.shop2020.payment.domain.Payment> payments;
287
        if(isDigital){
288
        	payments = paymentHandler.getPaymentForRechargeTxn(merchantTxnId);
289
        }else{
290
        	payments = paymentHandler.getPaymentForTxn(merchantTxnId);
291
        }
6482 rajveer 292
        if(payments ==null || payments.isEmpty())
293
            throw new PaymentException(104, "No payments found corresponding to the merchant txn " + merchantTxnId);
294
 
6486 rajveer 295
        if(payments ==null || payments.isEmpty())
296
            throw new PaymentException(104, "No payments found corresponding to the merchant txn " + merchantTxnId);
297
 
6482 rajveer 298
        in.shop2020.payment.domain.Payment payment = payments.get(0);
6486 rajveer 299
 
300
        if(payment.getAmount() < amount){
301
        	logger.warn("Refund amount is more than payment amount.");
302
            return false;
303
        }
304
 
6482 rajveer 305
        switch(PaymentStatus.findByValue(payment.getStatus())){
306
        case PENDING:
307
            logger.error("Attempt to refund a non-authorized payment");
308
            return false;
309
        case INIT:
310
            logger.warn("Attempt to refund a non-authorized payment");
311
            return false;
312
        case AUTHORIZED:
313
        	logger.warn("Attempt to refund a non-captured payment");
314
            return false;
315
        case CAPTURE_IN_PROCESS:
316
        	logger.warn("Attempt to refund a non-captured payment");
317
            return false;
318
        case PROVISIONALLY_CAPTURED:
319
        	logger.warn("Attempt to refund a non-captured payment");
320
            return false;
6486 rajveer 321
        case REFUNDED:
322
        	logger.warn("Attempt to refund a refunded payment");
323
            return false;
6482 rajveer 324
        case SUCCESS:
325
            break;
326
        case FAILED:
327
            logger.error("Attempting to capture a failed payment");
328
            return false;
329
        }
330
 
331
        long gatewayId = payment.getGatewayId();
332
 
333
        if(gatewayId == HDFC_GATEWAY_ID){
6491 rajveer 334
            //Refund the HDFC payment
6482 rajveer 335
            return refundHdfcPayment(payment, amount);
6491 rajveer 336
        }else if (gatewayId == EBS_GATEWAY_ID){
337
            //Refund the EBS payment
338
            return refundEbsPayment(payment, amount);
6482 rajveer 339
        } 
6491 rajveer 340
        else if (HDFC_EMI_GATEWAY_IDS.contains(gatewayId)){
341
             //Capture and update the HDFC EMI payment
342
            return refundHdfcEmiPayment(payment, amount);
343
        }
6482 rajveer 344
 
345
        logger.error("We have an captured payment from unknown gateway: " + gatewayId);
346
        return false;
347
    }
348
 
349
 
3616 chandransh 350
	@Override
2689 chandransh 351
    public long createRefund(long orderId, long merchantTxnId, double amount) throws PaymentException, TException{
6482 rajveer 352
		logger.info("Attempting to create a refund for order: " + orderId);
6488 rajveer 353
//		if(!refundPayment(merchantTxnId, amount, false)){
354
//			logger.warn("Not able to refund corresponding to the merchant txn " + merchantTxnId);
355
//		}
2689 chandransh 356
		List<in.shop2020.payment.domain.Payment> payments = paymentHandler.getPaymentForTxn(merchantTxnId);
357
		if(payments ==null || payments.isEmpty())
358
			throw new PaymentException(104, "No payments found corresponding to the merchant txn " + merchantTxnId);
359
 
3010 chandransh 360
		in.shop2020.payment.domain.Payment payment = payments.get(0);
2689 chandransh 361
		if(payment.getStatus() != PaymentStatus.SUCCESS.getValue())
362
			throw new PaymentException(104, "No successful payments found corresponding to the merchant txn " + merchantTxnId);
363
 
2747 chandransh 364
		Refund refund = new Refund();
365
		refund.setOrderId(orderId);
366
		refund.setPaymentId(payment.getId());
367
		refund.setGatewayId(payment.getGatewayId());
368
		refund.setAmount(amount);
369
		refund.setAttempts(0);
370
		return refundHandler.createRefund(refund);
2689 chandransh 371
    }
372
 
3010 chandransh 373
    @Override
8618 rajveer 374
    public synchronized boolean capturePayment(long merchantTxnId, boolean isDigital) throws PaymentException, TException {
375
        logger.info("Attempting to capture payment corresponding to our transaction " + merchantTxnId + " and Is Digital is:" + isDigital);
376
        List<in.shop2020.payment.domain.Payment> payments;
377
        if(isDigital){
378
        	payments = paymentHandler.getPaymentForRechargeTxn(merchantTxnId);
379
        }else{
380
        	payments = paymentHandler.getPaymentForTxn(merchantTxnId);
381
        }
3010 chandransh 382
        if(payments ==null || payments.isEmpty())
383
            throw new PaymentException(104, "No payments found corresponding to the merchant txn " + merchantTxnId);
384
 
385
        in.shop2020.payment.domain.Payment payment = payments.get(0);
386
        switch(PaymentStatus.findByValue(payment.getStatus())){
387
        case PENDING:
388
            logger.error("Attempt to capture a non-authorized payment");
389
            return false;
390
        case INIT:
391
            logger.warn("Attempt to capture a non-authorized payment");
392
            return false;
393
        case AUTHORIZED:
4421 mandeep.dh 394
        case CAPTURE_IN_PROCESS:
3010 chandransh 395
            //Actual work to be done in this case. Let the call proceed.
396
            break;
4421 mandeep.dh 397
        case PROVISIONALLY_CAPTURED:
398
            logger.info("Attempting to capture a payment that is provisonally captured but we can let the client proceed.");
399
            return true;
3010 chandransh 400
        case SUCCESS:
401
            logger.warn("Attempting to capture an already captured payment but we can let the client proceed.");
402
            return true;
403
        case FAILED:
404
            logger.error("Attempting to capture a failed payment");
405
            return false;
406
        }
407
 
408
        long gatewayId = payment.getGatewayId();
409
 
410
        if(gatewayId == HDFC_GATEWAY_ID){
411
            //Capture and update the HDFC payment
412
            return captureAndUpdateHdfcPayment(payment);
413
        } else if (gatewayId == EBS_GATEWAY_ID){
414
            //Capture and update the EBS payment
415
            return captureAndUpdateEbsPayment(payment);
6449 rajveer 416
        } else if (HDFC_EMI_GATEWAY_IDS.contains(gatewayId)){
3583 chandransh 417
            //Capture and update the HDFC EMI payment
418
            return captureAndUpdateHdfcEmiPayment(payment);
8488 amar.kumar 419
        } else if (gatewayId == EBAY_GATEWAY_ID || gatewayId == SNAPDEAL_GATEWAY_ID) {
8208 amar.kumar 420
        	return true;
3010 chandransh 421
        }
422
 
423
        logger.error("We have an authorized payment from unknown gateway: " + gatewayId);
424
        return false;
425
    }
426
 
3956 chandransh 427
    @Override
428
    public boolean partiallyCapturePayment(long merchantTxnId, double amount, String xferBy, String xferTxnId, long xferDate) throws PaymentException, TException {
429
        logger.info("Attempting to partially capture payment corresponding to our transaction " + merchantTxnId);
430
        List<in.shop2020.payment.domain.Payment> payments = paymentHandler.getPaymentForTxn(merchantTxnId);
431
        if(payments ==null || payments.isEmpty())
432
            throw new PaymentException(104, "No payments found corresponding to the merchant txn " + merchantTxnId);
433
 
434
        in.shop2020.payment.domain.Payment payment = payments.get(0);
435
        switch(PaymentStatus.findByValue(payment.getStatus())){
436
        case PENDING:
437
            // COD payments lie in this state before settlement.
438
        case INIT:
439
        case PARTIALLY_CAPTURED:
440
        case AUTHORIZED:
441
            // COD payments would not be in this state but we are processing
442
            // payments in this state as well for forward compatibility since
443
            // someday we'd want to be able to capture authorized CC payments
444
            // partially.
445
            break;
446
        case SUCCESS:
447
            logger.warn("Attempting to capture an already captured payment but we can let the client proceed.");
448
            return true;
449
        case FAILED:
450
            logger.error("Attempting to capture a failed payment");
451
            return false;
452
        }
453
        SimpleDateFormat mysqlDateFormatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
454
        String xferDateStr = mysqlDateFormatter.format(new Date(xferDate));
455
 
456
        return settleAndUpdateCodPayment(payment, amount, xferBy, xferTxnId, xferDateStr);
457
    }
458
 
3010 chandransh 459
    /**
460
     * Capture the HDFC payment represented by the given payment object. If the
461
     * capture attempt is not successful, we mark this payment as failed. We
462
     * don't retry or anything. We'll add the support of multiple attempts later
463
     * on.
464
     * 
465
     * @param payment The payment which has to be captured.
466
     * @return True if the payment attempt is successful, false if not.
4421 mandeep.dh 467
     * @throws PaymentException 
3010 chandransh 468
     */
4421 mandeep.dh 469
    private boolean captureAndUpdateHdfcPayment(in.shop2020.payment.domain.Payment payment) throws PaymentException {
3010 chandransh 470
        long merchantPaymentId = payment.getId();
471
        logger.info("Capturing HDFC payment with id: " + merchantPaymentId);
472
        Map<String, String> captureResult = HdfcPaymentHandler.capturePayment(payment);
473
        String captureStatus = captureResult.get(IPaymentHandler.STATUS);
474
        String gatewayStatus = captureResult.get(IPaymentHandler.GATEWAY_STATUS);
475
 
476
        Map<String, String> attrMap = new HashMap<String, String>();
477
        if (!captureStatus.trim().equals("0") 
478
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
479
            // Failure
3616 chandransh 480
            logger.error("Capture attempt failed for HDFC payment with id: " + merchantPaymentId);
3010 chandransh 481
            String description = captureResult.get(IPaymentHandler.ERROR);
482
            String errorCode = captureResult.get(IPaymentHandler.ERR_CODE);
483
 
484
            payment.setDescription(description);
485
            payment.setErrorCode(errorCode);
486
            payment.setErrorTimestamp(new Date());
4421 mandeep.dh 487
 
488
            if (IPaymentHandler.Errors.CONN_FAILURE.code.equals(errorCode)) {
489
                payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());
490
                paymentHandler.updatePayment(payment, attrMap);
491
                throw new PaymentException(106, "Could not capture due to connection issue");
492
            }
493
            else {
494
                payment.setStatus(PaymentStatus.FAILED.getValue());
495
                paymentHandler.updatePayment(payment, attrMap);
496
                persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
497
            }
498
 
3010 chandransh 499
            return false;
500
        } else {
501
            // Success
3616 chandransh 502
            logger.info("Capture attempt successful for HDFC payment with id: " + merchantPaymentId);
3010 chandransh 503
            payment.setDescription("Payment Captured");
504
            payment.setGatewayTxnStatus(gatewayStatus);
505
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
506
            payment.setSuccessTimestamp(new Date());           
507
 
508
            attrMap.put(IPaymentHandler.CAPTURE_TXN_ID, captureResult.get(IPaymentHandler.CAPTURE_TXN_ID));
509
            attrMap.put(IPaymentHandler.CAPTURE_REF_ID, captureResult.get(IPaymentHandler.CAPTURE_REF_ID));
510
            attrMap.put(IPaymentHandler.CAPTURE_AUTH_ID, captureResult.get(IPaymentHandler.CAPTURE_AUTH_ID));
511
 
512
            SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
513
            attrMap.put(HdfcPaymentHandler.CAPTURE_TIME, captureTimeDateFormatter.format(new Date()));
514
 
515
            paymentHandler.updatePayment(payment, attrMap);
516
            return true;
517
          }
518
    }
519
 
520
    /**
3583 chandransh 521
     * Capture the HDFC EMI payment represented by the given payment object. If
522
     * the capture attempt is not successful, we mark this payment as failed. We
523
     * don't retry or anything. We'll add the support of multiple attempts later
524
     * on.
525
     * 
526
     * @param payment
527
     *            The payment which has to be captured.
528
     * @return True if the payment attempt is successful, false if not.
4421 mandeep.dh 529
     * @throws PaymentException 
3583 chandransh 530
     */
4421 mandeep.dh 531
    private boolean captureAndUpdateHdfcEmiPayment(in.shop2020.payment.domain.Payment payment) throws PaymentException{
3583 chandransh 532
        long merchantPaymentId = payment.getId();
533
        logger.info("Capturing HDFC payment with id: " + merchantPaymentId);
534
        Map<String, String> captureResult = HdfcEmiPaymentHandler.capturePayment(payment);
535
        String captureStatus = captureResult.get(IPaymentHandler.STATUS);
536
        String gatewayStatus = captureResult.get(IPaymentHandler.GATEWAY_STATUS);
537
 
538
        Map<String, String> attrMap = new HashMap<String, String>();
539
        if (!captureStatus.trim().equals("0") 
540
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
541
            // Failure
3616 chandransh 542
            logger.error("Capture attempt failed for HDFC payment with id: " + merchantPaymentId);
3583 chandransh 543
            String description = captureResult.get(IPaymentHandler.ERROR);
544
            String errorCode = captureResult.get(IPaymentHandler.ERR_CODE);
545
 
546
            payment.setDescription(description);
547
            payment.setErrorCode(errorCode);
4421 mandeep.dh 548
            payment.setErrorTimestamp(new Date());                
549
 
550
            // Not marking payments as failed in case of connection issues
551
            if (IPaymentHandler.Errors.CONN_FAILURE.code.equals(errorCode)) {
552
                payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());
553
                paymentHandler.updatePayment(payment, attrMap);
554
                throw new PaymentException(106, "Could not capture due to connection issue");
555
            }
556
            else {
557
                payment.setStatus(PaymentStatus.FAILED.getValue());
558
                paymentHandler.updatePayment(payment, attrMap);
559
                persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
560
            }
561
 
3583 chandransh 562
            return false;
563
        } else {
564
            // Success
3616 chandransh 565
            logger.info("Capture attempt successful for HDFC payment with id: " + merchantPaymentId);
3583 chandransh 566
            payment.setDescription("Payment Captured");
567
            payment.setGatewayTxnStatus(gatewayStatus);
568
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
4421 mandeep.dh 569
            payment.setSuccessTimestamp(new Date());
3583 chandransh 570
 
571
            attrMap.put(IPaymentHandler.CAPTURE_TXN_ID, captureResult.get(IPaymentHandler.CAPTURE_TXN_ID));
572
            attrMap.put(IPaymentHandler.CAPTURE_REF_ID, captureResult.get(IPaymentHandler.CAPTURE_REF_ID));
573
            attrMap.put(IPaymentHandler.CAPTURE_AUTH_ID, captureResult.get(IPaymentHandler.CAPTURE_AUTH_ID));
574
 
575
            SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
576
            attrMap.put(HdfcPaymentHandler.CAPTURE_TIME, captureTimeDateFormatter.format(new Date()));
577
 
578
            paymentHandler.updatePayment(payment, attrMap);
579
            return true;
580
          }
581
    }
582
 
583
    /**
3010 chandransh 584
     * Capture the EBS payment represented by the given payment object. If the
585
     * capture attempt is not successful, we mark this payment as failed. We
586
     * don't retry or anything. We'll add the support of multiple attempts later
587
     * on.
588
     * 
589
     * @param payment The payment which has to be captured.
590
     * @return True if the payment attempt is successful, false if not.
4421 mandeep.dh 591
     * @throws PaymentException 
3010 chandransh 592
     */
4421 mandeep.dh 593
    private boolean captureAndUpdateEbsPayment(in.shop2020.payment.domain.Payment payment) throws PaymentException{
3010 chandransh 594
        Map<String, String> captureResult = EbsPaymentHandler.capturePayment(payment);
595
        String captureStatus = captureResult.get(EbsPaymentHandler.STATUS);
8650 anupam.sin 596
        for(String key : captureResult.keySet()) {
597
            logger.info("key : " + key + " value : " + captureResult.get(key));
598
        }
3010 chandransh 599
 
8650 anupam.sin 600
        logger.info("capture status : " + captureStatus);
601
 
3010 chandransh 602
        Map<String, String> attrMap = new HashMap<String, String>();
603
        if("".equals(captureStatus)){
604
            //Failure
3616 chandransh 605
            logger.error("Capture attempt failed for EBS payment with id: " + payment.getId());
3010 chandransh 606
            String description = captureResult.get(EbsPaymentHandler.ERROR);
607
            String errorCode = captureResult.get(EbsPaymentHandler.ERR_CODE);
4421 mandeep.dh 608
 
3010 chandransh 609
            payment.setDescription(description);
610
            payment.setErrorCode(errorCode);
611
            payment.setErrorTimestamp(new Date());
4421 mandeep.dh 612
 
613
            if (IPaymentHandler.Errors.CONN_FAILURE.code.equals(errorCode)) {
614
                payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());            
615
                paymentHandler.updatePayment(payment, attrMap);
616
                throw new PaymentException(106, "Could not capture due to connection issue");
617
            }
618
            else {
619
                payment.setStatus(PaymentStatus.FAILED.getValue());            
620
                paymentHandler.updatePayment(payment, attrMap);
621
                persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
622
            }
623
 
3010 chandransh 624
            return false;
625
        }else{
626
            //Success
3616 chandransh 627
            logger.info("Capture attempt successful for EBS payment with id: " + payment.getId());
3010 chandransh 628
            payment.setGatewayTxnStatus(captureStatus);
629
            payment.setStatus(PaymentStatus.SUCCESS.getValue());
630
            payment.setSuccessTimestamp(new Date());
631
 
632
            attrMap.put(IPaymentHandler.CAPTURE_TXN_ID, captureResult.get(IPaymentHandler.CAPTURE_TXN_ID));
633
            attrMap.put(IPaymentHandler.CAPTURE_TIME, captureResult.get(IPaymentHandler.CAPTURE_TIME));
634
            paymentHandler.updatePayment(payment, attrMap);
635
            return true;
636
        }
637
    }
638
 
6482 rajveer 639
 
3010 chandransh 640
    /**
6482 rajveer 641
     * Refund the HDFC payment represented by the given payment object. If the
642
     * refund attempt is not successful, will not any action.
643
     * 
644
     * @param payment The payment which has to be captured.
645
     * @amount amount to be refunded
646
     * @return True if the payment attempt is successful, false if not.
647
     * @throws PaymentException 
648
     */
649
    private boolean refundHdfcPayment(in.shop2020.payment.domain.Payment payment, double amount) throws PaymentException {
650
        long merchantPaymentId = payment.getId();
651
        logger.info("Refunding HDFC payment with id: " + merchantPaymentId);
652
        Map<String, String> refundResult = HdfcPaymentHandler.refundPayment(payment, amount);
6486 rajveer 653
        String refundStatus = refundResult.get(IPaymentHandler.STATUS);
6482 rajveer 654
        String gatewayStatus = refundResult.get(IPaymentHandler.GATEWAY_STATUS);
655
 
656
        Map<String, String> attrMap = new HashMap<String, String>();
6486 rajveer 657
        if (!refundStatus.trim().equals("0") 
6482 rajveer 658
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
6486 rajveer 659
 
660
        	logger.error("Refund attempt failed for HDFC payment with id: " + merchantPaymentId);
661
            String description = refundResult.get(IPaymentHandler.ERROR);
662
            String errorCode = refundResult.get(IPaymentHandler.ERR_CODE);
663
 
664
            payment.setDescription(description);
665
            payment.setErrorCode(errorCode);
666
            payment.setErrorTimestamp(new Date());
667
 
668
            if (IPaymentHandler.Errors.CONN_FAILURE.code.equals(errorCode)) {
669
                //payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());
670
                //paymentHandler.updatePayment(payment, attrMap);
671
                throw new PaymentException(106, "Could not capture due to connection issue. Try Later");
672
            }
673
            else {
6491 rajveer 674
//                payment.setStatus(PaymentStatus.FAILED.getValue());
675
//                paymentHandler.updatePayment(payment, attrMap);
6486 rajveer 676
                persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
677
            }
678
 
6482 rajveer 679
            return false;
680
        } else {
681
            // Success
682
            logger.info("Refund attempt successful for HDFC payment with id: " + merchantPaymentId);
683
            payment.setDescription("Payment Refunded");
684
            payment.setGatewayTxnStatus(gatewayStatus);
6503 rajveer 685
            payment.setStatus(PaymentStatus.REFUNDED.getValue());    
686
            payment.setRefundAmount(amount);
6482 rajveer 687
 
6486 rajveer 688
            attrMap.put(IPaymentHandler.REFUND_TXN_ID, refundResult.get(IPaymentHandler.REFUND_TXN_ID));
689
            attrMap.put(IPaymentHandler.REFUND_REF_ID, refundResult.get(IPaymentHandler.REFUND_REF_ID));
690
            attrMap.put(IPaymentHandler.REFUND_AUTH_ID, refundResult.get(IPaymentHandler.REFUND_AUTH_ID));
6503 rajveer 691
            attrMap.put(IPaymentHandler.REFUND_AMNT, refundResult.get(IPaymentHandler.REFUND_AMNT));
692
 
6482 rajveer 693
            SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
6486 rajveer 694
            attrMap.put(HdfcPaymentHandler.REFUND_TIME, captureTimeDateFormatter.format(new Date()));
6482 rajveer 695
 
696
            paymentHandler.updatePayment(payment, attrMap);
697
            return true;
698
          }
699
    }
700
 
701
 
6491 rajveer 702
    /**
703
     * Refund the HDFC EMI payment represented by the given payment object. If
704
     * the capture attempt is not successful, we will not do anything.
705
     * 
706
     * @param payment
707
     *            The payment which has to be captured.
708
     * @return True if the payment attempt is successful, false if not.
709
     * @throws PaymentException 
710
     */
711
    private boolean refundHdfcEmiPayment(in.shop2020.payment.domain.Payment payment, double amount) throws PaymentException{
712
        long merchantPaymentId = payment.getId();
713
        logger.info("Refunding HDFC payment with id: " + merchantPaymentId);
714
        Map<String, String> refundResult = HdfcEmiPaymentHandler.refundPayment(payment, amount);
715
        String refundStatus = refundResult.get(IPaymentHandler.STATUS);
716
        String gatewayStatus = refundResult.get(IPaymentHandler.GATEWAY_STATUS);
717
 
718
        Map<String, String> attrMap = new HashMap<String, String>();
719
        if (!refundStatus.trim().equals("0") 
720
                || !HdfcPaymentReturnStatus.CAPTURED.value().equals(gatewayStatus)) {
721
            // Failure
722
            logger.error("Refund attempt failed for HDFC payment with id: " + merchantPaymentId);
723
            String description = refundResult.get(IPaymentHandler.ERROR);
724
            String errorCode = refundResult.get(IPaymentHandler.ERR_CODE);
725
 
726
            payment.setDescription(description);
727
            payment.setErrorCode(errorCode);
728
            payment.setErrorTimestamp(new Date());                
729
 
730
            // Not marking payments as failed in case of connection issues
731
            if (IPaymentHandler.Errors.CONN_FAILURE.code.equals(errorCode)) {
732
             //   payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());
733
             //   paymentHandler.updatePayment(payment, attrMap);
734
                throw new PaymentException(106, "Could not capture due to connection issue");
735
            }
736
            else {
737
              //  payment.setStatus(PaymentStatus.FAILED.getValue());
738
              //  paymentHandler.updatePayment(payment, attrMap);
739
                persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
740
            }
741
 
742
            return false;
743
        } else {
744
            // Success
745
            logger.info("Refund attempt successful for HDFC payment with id: " + merchantPaymentId);
746
            payment.setDescription("Payment Refunded");
747
            payment.setGatewayTxnStatus(gatewayStatus);
748
            payment.setStatus(PaymentStatus.REFUNDED.getValue());           
6503 rajveer 749
            payment.setRefundAmount(amount);
6491 rajveer 750
 
751
            attrMap.put(IPaymentHandler.REFUND_TXN_ID, refundResult.get(IPaymentHandler.REFUND_TXN_ID));
752
            attrMap.put(IPaymentHandler.REFUND_REF_ID, refundResult.get(IPaymentHandler.REFUND_REF_ID));
753
            attrMap.put(IPaymentHandler.REFUND_AUTH_ID, refundResult.get(IPaymentHandler.REFUND_AUTH_ID));
6503 rajveer 754
            attrMap.put(IPaymentHandler.REFUND_AMNT, refundResult.get(IPaymentHandler.REFUND_AMNT));
755
 
6491 rajveer 756
            SimpleDateFormat captureTimeDateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
757
            attrMap.put(HdfcPaymentHandler.REFUND_TIME, captureTimeDateFormatter.format(new Date()));
758
 
759
            paymentHandler.updatePayment(payment, attrMap);
760
            return true;
761
          }
762
    }
6482 rajveer 763
 
764
    /**
6491 rajveer 765
     * Refund the EBS payment represented by the given payment object. If the
766
     * capture attempt is not successful, we will ignore. We don't retry or anything. 
767
     * We'll add the support of multiple attempts later on.
768
     * 
769
     * @param payment The payment which has to be captured.
770
     * @amount Amount to be refunded
771
     * @return True if the payment attempt is successful, false if not.
772
     * @throws PaymentException 
773
     */
774
    private boolean refundEbsPayment(in.shop2020.payment.domain.Payment payment, double amount) throws PaymentException{
775
        Map<String, String> refundResult = EbsPaymentHandler.refundPayment(payment, amount);
776
        String refundStatus = refundResult.get(EbsPaymentHandler.STATUS);
777
 
778
        Map<String, String> attrMap = new HashMap<String, String>();
779
        if("".equals(refundStatus)){
780
            //Failure
781
            logger.error("Refund attempt failed for EBS payment with id: " + payment.getId());
782
            String description = refundResult.get(EbsPaymentHandler.ERROR);
783
            String errorCode = refundResult.get(EbsPaymentHandler.ERR_CODE);
784
 
785
            payment.setDescription(description);
786
            payment.setErrorCode(errorCode);
787
            payment.setErrorTimestamp(new Date());
788
 
789
            if (IPaymentHandler.Errors.CONN_FAILURE.code.equals(errorCode)) {
790
//                payment.setStatus(PaymentStatus.CAPTURE_IN_PROCESS.getValue());            
791
//                paymentHandler.updatePayment(payment, attrMap);
792
                throw new PaymentException(106, "Could not capture due to connection issue");
793
            }
794
            else {
795
//                payment.setStatus(PaymentStatus.FAILED.getValue());            
796
//                paymentHandler.updatePayment(payment, attrMap);
797
                persistPaymentRequiringExtraProcessing(payment, ExtraPaymentProcessingType.FAILED_PAYMENTS);
798
            }
799
 
800
            return false;
801
        }else{
802
            //Success
803
            logger.info("Refund attempt successful for EBS payment with id: " + payment.getId());
804
            payment.setGatewayTxnStatus(refundStatus);
805
            payment.setStatus(PaymentStatus.REFUNDED.getValue());
6503 rajveer 806
            payment.setRefundAmount(amount);
6491 rajveer 807
 
808
            attrMap.put(IPaymentHandler.REFUND_TXN_ID, refundResult.get(IPaymentHandler.REFUND_TXN_ID));
809
            attrMap.put(IPaymentHandler.REFUND_TIME, refundResult.get(IPaymentHandler.REFUND_TIME));
810
            paymentHandler.updatePayment(payment, attrMap);
811
            return true;
812
        }
813
    }
814
 
815
 
816
    /**
3956 chandransh 817
     * Updates the settlement details of COD payments. Sets payment status as
818
     * either PARTIALLY CAPTURED or SUCCESS depending on whether the complete
819
     * amount has been captured. Other parameters are set as attributes.
820
     * 
821
     * @param payment
822
     *            The payment which needs to be updated.
823
     * @param amount
824
     *            Amount that has been captured.
825
     * @param xferBy
826
     *            Entity which transferred the money.
827
     * @param xferTxnId
828
     *            Transaction Id of the transfer.
829
     * @param xferDateStr
830
     *            Date on which the transfer took place.
831
     * @return true if the payment details were updated successfully.
832
     * @throws PaymentException
833
     *             if the captured amount will become more than the actual
834
     *             amount after this update.
835
     */
836
    private boolean settleAndUpdateCodPayment(in.shop2020.payment.domain.Payment payment, double amount, String xferBy, String xferTxnId, String xferDateStr) throws PaymentException{
837
        Map<String, String> attrMap = payment.getAttributeMap();
838
 
839
        double captureAmount = 0;
840
        String captureAmntStr = attrMap.get(IPaymentHandler.CAPTURE_AMNT);
841
        if(captureAmntStr != null)
842
            captureAmount = Double.parseDouble(captureAmntStr);
843
        captureAmount += amount;
5051 rajveer 844
        // If capture amount higher than payment amount by more than 50 paisa,
845
        // there is some issue and we should raise exception.
846
        if(captureAmount - payment.getAmount() > 0.5){
847
        	throw new PaymentException(105, "We've got a settlement request for an amount which is more than the transaction value.");
848
        }
3956 chandransh 849
 
5051 rajveer 850
        // If capture amount differs from payment amount by less than 50 paisa, lets mark the payment as successful. 
851
        // Else we can safely assume there will be some more orders for the payment, leading to make the payment as partially captured.
852
        if(Math.abs(captureAmount - payment.getAmount()) < 0.5){
853
        	payment.setStatus(PaymentStatus.SUCCESS.getValue());
854
        }else {
855
        	payment.setStatus(PaymentStatus.PARTIALLY_CAPTURED.getValue());   
3956 chandransh 856
        }
857
        payment.setSuccessTimestamp(new Date());
858
        attrMap.put(IPaymentHandler.CAPTURE_AMNT, captureAmount + "");
859
        attrMap.put(IPaymentHandler.XFER_TXN_ID, xferTxnId);
860
        attrMap.put(IPaymentHandler.XFER_TXN_DATE, xferDateStr);
861
        attrMap.put(IPaymentHandler.XFER_BY, xferBy);
862
        paymentHandler.updatePayment(payment, attrMap);
863
        return true;
864
    }
865
 
866
    /**
3010 chandransh 867
     * Creates a list of thrift payment objects corresponding to a list of
868
     * payment data objects.
869
     * 
870
     * @param daoPayments
871
     *            A list of payment DAO.
872
     * @return A list of Thrift payment objects.
873
     */
874
    private List<Payment> getThriftPayments(List<in.shop2020.payment.domain.Payment> daoPayments){
875
 
876
        List<Payment> payments = new ArrayList<Payment>();
877
        for(in.shop2020.payment.domain.Payment payment : daoPayments){
878
            payments.add(payment.getThriftPayment());
879
        }
880
        return payments;
881
    }
3375 rajveer 882
 
4600 varun.gupt 883
    /**
884
     * Creates a list of thrift payment gateway objects corresponding to a list of
885
     * payment gateway data objects.
886
     * 
887
     * @param daoPaymentGateways
888
     *            A list of payment gateway DAO.
889
     * @return A list of Thrift payment gateway objects.
890
     */
891
    private List<PaymentGateway> getThriftPaymentGateways(List<in.shop2020.payment.domain.PaymentGateway> daoPaymentGateways){
892
 
893
        List<PaymentGateway> paymentGateways = new ArrayList<PaymentGateway>();
894
        for(in.shop2020.payment.domain.PaymentGateway paymentGateway : daoPaymentGateways){
895
            paymentGateways.add(paymentGateway.getThriftPaymentGateway());
896
        }
897
        return paymentGateways;
898
    }
4619 mandeep.dh 899
 
3375 rajveer 900
	@Override
4619 mandeep.dh 901
	public boolean isAlive() {
902
	    try {
903
            return !paymentGatewayHandler.getActivePaymentGateways().isEmpty();
904
        } catch (Exception e) {
905
            logger.error("Could not fetch payment gateways", e);
906
        }
907
 
908
        return false;
3375 rajveer 909
	}
3956 chandransh 910
 
911
 
912
    @Override
913
    public void closeSession() throws TException {
914
        // TODO Auto-generated method stub      
915
    }
4008 mandeep.dh 916
 
917
    @Override
918
    public List<Long> getPaymentsRequiringExtraProcessing (
919
            ExtraPaymentProcessingType category) throws TException {
920
        return paymentRequiringExtraProcessingHandler.getPaymentIds(category);
921
    }
922
 
923
    @Override
924
    public void markPaymentAsProcessed(long paymentId,
925
            ExtraPaymentProcessingType category) throws TException {
926
        paymentRequiringExtraProcessingHandler.delete(paymentId, category);
927
    }
4141 chandransh 928
 
1946 chandransh 929
}