| Line 5... |
Line 5... |
| 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.Transaction;
|
7 |
import in.shop2020.model.v1.order.Transaction;
|
| 8 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
8 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
| 9 |
import in.shop2020.model.v1.order.TransactionStatus;
|
9 |
import in.shop2020.model.v1.order.TransactionStatus;
|
| - |
|
10 |
import in.shop2020.model.v1.order.OrderType;
|
| 10 |
import in.shop2020.model.v1.user.Cart;
|
11 |
import in.shop2020.model.v1.user.Cart;
|
| 11 |
import in.shop2020.model.v1.user.Line;
|
12 |
import in.shop2020.model.v1.user.Line;
|
| 12 |
import in.shop2020.model.v1.user.PromotionException;
|
13 |
import in.shop2020.model.v1.user.PromotionException;
|
| 13 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
14 |
import in.shop2020.model.v1.user.ShoppingCartException;
|
| - |
|
15 |
import in.shop2020.logistics.PickUpType;
|
| 14 |
import in.shop2020.payments.Payment;
|
16 |
import in.shop2020.payments.Payment;
|
| 15 |
import in.shop2020.payments.PaymentException;
|
17 |
import in.shop2020.payments.PaymentException;
|
| 16 |
import in.shop2020.thrift.clients.CatalogClient;
|
18 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 17 |
import in.shop2020.thrift.clients.PaymentClient;
|
19 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 18 |
import in.shop2020.thrift.clients.PromotionClient;
|
20 |
import in.shop2020.thrift.clients.PromotionClient;
|
| Line 34... |
Line 36... |
| 34 |
*
|
36 |
*
|
| 35 |
*/
|
37 |
*/
|
| 36 |
public class CommonPaymentService {
|
38 |
public class CommonPaymentService {
|
| 37 |
|
39 |
|
| 38 |
private static final boolean PAYMENT_NOT_CREATED = false;
|
40 |
private static final boolean PAYMENT_NOT_CREATED = false;
|
| 39 |
private static final boolean selfPickupFlag = false;
|
- |
|
| 40 |
|
41 |
|
| 41 |
private static Logger log = Logger.getLogger(Class.class);
|
42 |
private static Logger log = Logger.getLogger(Class.class);
|
| 42 |
|
43 |
|
| 43 |
private long paymentId;
|
44 |
private long paymentId;
|
| 44 |
private double amount;
|
45 |
private double amount;
|
| Line 143... |
Line 144... |
| 143 |
tStatus = TransactionStatus.FLAGGED;
|
144 |
tStatus = TransactionStatus.FLAGGED;
|
| 144 |
description = "Payment flagged for the order";
|
145 |
description = "Payment flagged for the order";
|
| 145 |
}
|
146 |
}
|
| 146 |
try {
|
147 |
try {
|
| 147 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
148 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
| 148 |
transactionClient.changeTransactionStatus(txnId, tStatus, description, selfPickupFlag);
|
149 |
transactionClient.changeTransactionStatus(txnId, tStatus, description, PickUpType.COURIER.getValue(), OrderType.B2C);
|
| 149 |
transaction = transactionClient.getTransaction(txnId);
|
150 |
transaction = transactionClient.getTransaction(txnId);
|
| 150 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
151 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
| 151 |
} catch (TException e1) {
|
152 |
} catch (TException e1) {
|
| 152 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
153 |
log.error("Unable to update status of transaction. Thrift Exception:", e1);
|
| 153 |
} catch (TransactionServiceException e) {
|
154 |
} catch (TransactionServiceException e) {
|
| Line 165... |
Line 166... |
| 165 |
* @param transactionServiceClient
|
166 |
* @param transactionServiceClient
|
| 166 |
*/
|
167 |
*/
|
| 167 |
public static void processFailedTxn(long txnId, TransactionClient transactionServiceClient) {
|
168 |
public static void processFailedTxn(long txnId, TransactionClient transactionServiceClient) {
|
| 168 |
try {
|
169 |
try {
|
| 169 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
170 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
| 170 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.FAILED, "Payment failed for the transaction.", selfPickupFlag);
|
171 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.FAILED, "Payment failed for the transaction.", PickUpType.COURIER.getValue(), OrderType.B2C);
|
| 171 |
} catch(TException e){
|
172 |
} catch(TException e){
|
| 172 |
log.error("Thrift exception while getting information from transaction service.", e);
|
173 |
log.error("Thrift exception while getting information from transaction service.", e);
|
| 173 |
} catch (TransactionServiceException e) {
|
174 |
} catch (TransactionServiceException e) {
|
| 174 |
log.error("Error while updating status information in transaction database.", e);
|
175 |
log.error("Error while updating status information in transaction database.", e);
|
| 175 |
}
|
176 |
}
|
| Line 198... |
Line 199... |
| 198 |
*/
|
199 |
*/
|
| 199 |
public static void processCodTxn(long txnId){
|
200 |
public static void processCodTxn(long txnId){
|
| 200 |
try {
|
201 |
try {
|
| 201 |
TransactionClient transactionServiceClient = new TransactionClient();
|
202 |
TransactionClient transactionServiceClient = new TransactionClient();
|
| 202 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
203 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
| 203 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", selfPickupFlag);
|
204 |
transactionClient.changeTransactionStatus(txnId, TransactionStatus.COD_IN_PROCESS, "COD payment awaited", PickUpType.COURIER.getValue(), OrderType.B2C);
|
| 204 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
205 |
Transaction transaction = transactionClient.getTransaction(txnId);
|
| 205 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
206 |
transactionClient.enqueueTransactionInfoEmail(txnId);
|
| 206 |
|
207 |
|
| 207 |
UserClient userServiceClient = new UserClient();
|
208 |
UserClient userServiceClient = new UserClient();
|
| 208 |
trackCouponUsage(transaction);
|
209 |
trackCouponUsage(transaction);
|