Subversion Repositories SmartDukaan

Rev

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

Rev 5945 Rev 6050
Line 2... Line 2...
2
 
2
 
3
import in.shop2020.model.v1.catalog.Item;
3
import in.shop2020.model.v1.catalog.Item;
4
import in.shop2020.model.v1.catalog.CatalogService.Client;
4
import in.shop2020.model.v1.catalog.CatalogService.Client;
5
import in.shop2020.model.v1.order.LineItem;
5
import in.shop2020.model.v1.order.LineItem;
6
import in.shop2020.model.v1.order.Order;
6
import in.shop2020.model.v1.order.Order;
-
 
7
import in.shop2020.model.v1.order.RechargeOrder;
7
import in.shop2020.model.v1.order.Transaction;
8
import in.shop2020.model.v1.order.Transaction;
8
import in.shop2020.model.v1.order.TransactionServiceException;
9
import in.shop2020.model.v1.order.TransactionServiceException;
9
import in.shop2020.model.v1.order.TransactionStatus;
10
import in.shop2020.model.v1.order.TransactionStatus;
10
import in.shop2020.model.v1.order.OrderType;
11
import in.shop2020.model.v1.order.OrderType;
11
import in.shop2020.model.v1.user.Cart;
12
import in.shop2020.model.v1.user.Cart;
Line 87... Line 88...
87
			log.error("Unable to fetch payment amount.", e1);
88
			log.error("Unable to fetch payment amount.", e1);
88
			return PAYMENT_NOT_CREATED;
89
			return PAYMENT_NOT_CREATED;
89
		}
90
		}
90
		
91
		
91
		try {
92
		try {
92
			paymentId = paymentServiceClient.getClient().createPayment(userId, amount, gatewayId, txnId);
93
			paymentId = paymentServiceClient.getClient().createPayment(userId, amount, gatewayId, txnId, false);
93
			// This is being done to ensure that the amount which we pass on to
94
			// This is being done to ensure that the amount which we pass on to
94
			// the PGs is same as what we have in the database.
95
			// the PGs is same as what we have in the database.
95
			Payment payment = paymentServiceClient.getClient().getPayment(paymentId);
96
			Payment payment = paymentServiceClient.getClient().getPayment(paymentId);
96
			amount = payment.getAmount();
97
			amount = payment.getAmount();
97
		} catch (PaymentException e1) {
98
		} catch (PaymentException e1) {
Line 337... Line 338...
337
            log.error("Transport from Promotion Service failed:", e);
338
            log.error("Transport from Promotion Service failed:", e);
338
        } catch (Exception e) {
339
        } catch (Exception e) {
339
            log.error("Unexpected exception:", e);
340
            log.error("Unexpected exception:", e);
340
        }
341
        }
341
	}
342
	}
-
 
343
 
-
 
344
    public boolean createPayment(RechargeOrder rechargeOrder, int gatewayId) {
-
 
345
        PaymentClient paymentServiceClient = null;
-
 
346
        try {
-
 
347
            paymentServiceClient = new PaymentClient();
-
 
348
        } catch (Exception e) {
-
 
349
            log.error("Error while getting payment client", e);
-
 
350
            return PAYMENT_NOT_CREATED;
-
 
351
        }
-
 
352
        
-
 
353
        
-
 
354
        /*******************IS THIS NECESSARY ????
-
 
355
         * 
-
 
356
         * 
-
 
357
         * 
-
 
358
         * try {
-
 
359
            amount = calculatePaymentAmount(currentCartId, sourceId);
-
 
360
        } catch (ShoppingCartException e1) {
-
 
361
            log.error("Unable to fetch payment amount from cart id.", e1);
-
 
362
            return PAYMENT_NOT_CREATED;
-
 
363
        } catch (TException e1) {
-
 
364
            log.error("Unable to fetch payment amount.", e1);
-
 
365
            return PAYMENT_NOT_CREATED;
-
 
366
        }
-
 
367
         * 
-
 
368
         */
-
 
369
        amount = rechargeOrder.getTotalAmount() - rechargeOrder.getWalletAmount();
-
 
370
        
-
 
371
        try {
-
 
372
            paymentId = paymentServiceClient.getClient().createPayment(rechargeOrder.getUserId(), amount, gatewayId, rechargeOrder.getTransactionId(), true);
-
 
373
            // This is being done to ensure that the amount which we pass on to
-
 
374
            // the PGs is same as what we have in the database.
-
 
375
            Payment payment = paymentServiceClient.getClient().getPayment(paymentId);
-
 
376
            amount = payment.getAmount();
-
 
377
        } catch (PaymentException e1) {
-
 
378
            log.error("Unable to create payment object.", e1);
-
 
379
            return PAYMENT_NOT_CREATED;
-
 
380
        } catch (TException e) {
-
 
381
            log.error("Not able to create payment object.", e);
-
 
382
            return PAYMENT_NOT_CREATED;
-
 
383
        }
-
 
384
        
-
 
385
        return true;
-
 
386
    
-
 
387
    }
342
}
388
}