Subversion Repositories SmartDukaan

Rev

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

Rev 517 Rev 555
Line 15... Line 15...
15
import in.shop2020.logistics.LogisticsInfo;
15
import in.shop2020.logistics.LogisticsInfo;
16
import in.shop2020.logistics.LogisticsServiceException;
16
import in.shop2020.logistics.LogisticsServiceException;
17
import in.shop2020.model.v1.catalog.InventoryServiceException;
17
import in.shop2020.model.v1.catalog.InventoryServiceException;
18
import in.shop2020.model.v1.catalog.Item;
18
import in.shop2020.model.v1.catalog.Item;
19
import in.shop2020.model.v1.order.BillingInfo;
19
import in.shop2020.model.v1.order.BillingInfo;
20
import in.shop2020.model.v1.order.LineItem;
-
 
21
import in.shop2020.model.v1.order.Order;
20
import in.shop2020.model.v1.order.Order;
-
 
21
import in.shop2020.model.v1.order.LineItem;
22
import in.shop2020.model.v1.order.OrderInfo;
22
import in.shop2020.model.v1.order.OrderInfo;
23
import in.shop2020.model.v1.order.OrderStatus;
23
import in.shop2020.model.v1.order.OrderStatus;
24
import in.shop2020.model.v1.order.Payment;
24
import in.shop2020.model.v1.order.Payment;
25
import in.shop2020.model.v1.order.PaymentInfo;
25
import in.shop2020.model.v1.order.PaymentInfo;
26
import in.shop2020.model.v1.order.PaymentStatus;
26
import in.shop2020.model.v1.order.PaymentStatus;
27
import in.shop2020.model.v1.order.Shipment;
27
import in.shop2020.model.v1.order.Shipment;
28
import in.shop2020.model.v1.order.ShipmentInfo;
28
import in.shop2020.model.v1.order.ShipmentInfo;
29
import in.shop2020.model.v1.order.Transaction;
29
import in.shop2020.model.v1.order.Transaction;
30
import in.shop2020.model.v1.order.TransactionServiceException;
30
import in.shop2020.model.v1.order.TransactionServiceException;
31
import in.shop2020.model.v1.order.TransactionStatus;
31
import in.shop2020.model.v1.order.TransactionStatus;
32
import in.shop2020.model.v1.shoppingcart.Cart;
32
import in.shop2020.model.v1.user.Cart;
33
import in.shop2020.model.v1.shoppingcart.Line;
-
 
34
import in.shop2020.model.v1.shoppingcart.LineStatus;
33
import in.shop2020.model.v1.user.LineStatus;
35
import in.shop2020.model.v1.shoppingcart.ShoppingCartException;
34
import in.shop2020.model.v1.user.ShoppingCartException;
36
import in.shop2020.model.v1.user.Address;
35
import in.shop2020.model.v1.user.Address;
37
import in.shop2020.model.v1.user.UserContext;
36
import in.shop2020.model.v1.user.User;
38
import in.shop2020.model.v1.user.UserContextException;
37
import in.shop2020.model.v1.user.UserContextException;
39
import in.shop2020.payments.PaymentException;
38
import in.shop2020.payments.PaymentException;
40
import in.shop2020.thrift.clients.CatalogServiceClient;
39
import in.shop2020.thrift.clients.CatalogServiceClient;
41
import in.shop2020.thrift.clients.LogisticsServiceClient;
40
import in.shop2020.thrift.clients.LogisticsServiceClient;
42
import in.shop2020.thrift.clients.PaymentServiceClient;
41
import in.shop2020.thrift.clients.PaymentServiceClient;
43
import in.shop2020.thrift.clients.ShoppingCartClient;
-
 
44
import in.shop2020.thrift.clients.TransactionServiceClient;
42
import in.shop2020.thrift.clients.TransactionServiceClient;
45
import in.shop2020.thrift.clients.UserContextServiceClient;
43
import in.shop2020.thrift.clients.UserContextServiceClient;
46
import in.shop2020.utils.Logger;
44
import in.shop2020.utils.Logger;
47
 
45
 
48
public class PayResponseController extends BaseController{
46
public class PayResponseController extends BaseController{
Line 59... Line 57...
59
	public static String APPROVED = "APPROVED";
57
	public static String APPROVED = "APPROVED";
60
	public static String CAPTURED = "CAPTURED";
58
	public static String CAPTURED = "CAPTURED";
61
 
59
 
62
	PaymentServiceClient pclient = null;
60
	PaymentServiceClient pclient = null;
63
	LogisticsServiceClient lsc = null;
61
	LogisticsServiceClient lsc = null;
64
	ShoppingCartClient cl = null;
-
 
65
	UserContextServiceClient usc = null;
62
	UserContextServiceClient usc = null;
66
	CatalogServiceClient csc = null;
63
	CatalogServiceClient csc = null;
67
	TransactionServiceClient tsc = null;
64
	TransactionServiceClient tsc = null;
68
	
65
	
69
	String amount;
66
	String amount;
Line 82... Line 79...
82
	public PayResponseController(){
79
	public PayResponseController(){
83
		super();
80
		super();
84
		try {
81
		try {
85
			pclient = new PaymentServiceClient();
82
			pclient = new PaymentServiceClient();
86
			lsc = new LogisticsServiceClient();
83
			lsc = new LogisticsServiceClient();
87
			cl = new ShoppingCartClient();
-
 
88
			usc = new UserContextServiceClient();
84
			usc = new UserContextServiceClient();
89
			csc = new CatalogServiceClient();
85
			csc = new CatalogServiceClient();
90
			tsc = new TransactionServiceClient();
86
			tsc = new TransactionServiceClient();
91
			
87
			
92
		} catch (Exception e) {
88
		} catch (Exception e) {
Line 115... Line 111...
115
			pclient.getClient().addBankDetails(Long.parseLong(trackId), paymentId, tranId, "", "", postdate, auth, ref);
111
			pclient.getClient().addBankDetails(Long.parseLong(trackId), paymentId, tranId, "", "", postdate, auth, ref);
116
			message = "Payment processed. Creating transaction. In case you see this message, please call us with ref no "+ trackId;
112
			message = "Payment processed. Creating transaction. In case you see this message, please call us with ref no "+ trackId;
117
			Transaction t = getTransaction();
113
			Transaction t = getTransaction();
118
			transaction_id = tsc.getClient().createTransaction(t);
114
			transaction_id = tsc.getClient().createTransaction(t);
119
			message = "Your order id is "+ transaction_id;
115
			message = "Your order id is "+ transaction_id;
120
			cl.getClient().commitCart(pmnt.getCart_id());
116
			usc.getClient().commitCart(pmnt.getCart_id());
121
			message = "Error commiting the cart, but your order has been placed. Please refer to "+ transaction_id;
117
			message = "Error commiting the cart, but your order has been placed. Please refer to "+ transaction_id;
122
			
118
			
123
		} catch (NumberFormatException e) {
119
		} catch (NumberFormatException e) {
124
			
120
			
125
			Logger.log(e.toString(), this);
121
			Logger.log(e.toString(), this);
Line 184... Line 180...
184
private List<Order> getOrders(){
180
private List<Order> getOrders(){
185
	List<Order> orders = new ArrayList<Order>();
181
	List<Order> orders = new ArrayList<Order>();
186
	
182
	
187
	Cart c = null;
183
	Cart c = null;
188
	try {
184
	try {
189
		c = cl.getClient().getCart(pmnt.getCart_id());
185
		c = usc.getClient().getCart(pmnt.getCart_id());
190
	} catch (ShoppingCartException e) {
186
	} catch (ShoppingCartException e) {
191
		// TODO Auto-generated catch block
187
		// TODO Auto-generated catch block
192
		e.printStackTrace();
188
		e.printStackTrace();
193
	} catch (TException e) {
189
	} catch (TException e) {
194
		// TODO Auto-generated catch block
190
		// TODO Auto-generated catch block
195
		e.printStackTrace();
191
		e.printStackTrace();
196
	} catch (Exception e) {
192
	} catch (Exception e) {
197
		// TODO Auto-generated catch block
193
		// TODO Auto-generated catch block
198
		e.printStackTrace();
194
		e.printStackTrace();
199
	}
195
	}
200
	List<Line> lines = c.getLines();
196
	List<in.shop2020.model.v1.user.Line> lines = c.getLines();
201
	
197
	
202
	for(Line line : lines){
198
	for(in.shop2020.model.v1.user.Line line : lines){
203
		if(line.getLineStatus() == LineStatus.LINE_ACTIVE){
199
		if(line.getLineStatus() == LineStatus.LINE_ACTIVE){
204
			//line is active
200
			//line is active
205
			LineItem lineItem = getLineItem(line.getItemId());
201
			LineItem lineItem = getLineItem(line.getItemId());
206
			// create orders equivalent to quantity. Create one order per item.
202
			// create orders equivalent to quantity. Create one order per item.
207
			for(int i= 0; i<line.getQuantity(); i++){
203
			for(int i= 0; i<line.getQuantity(); i++){
Line 278... Line 274...
278
}
274
}
279
 
275
 
280
private String getEmail(long userId){
276
private String getEmail(long userId){
281
	String email = null;
277
	String email = null;
282
	try {
278
	try {
283
		email = usc.getClient().getPrimaryInfo(userId, false).getEmail();
279
		email = usc.getClient().getUserById(userId).getEmail();
284
	} catch (UserContextException e) {
280
	} catch (UserContextException e) {
285
		// TODO Auto-generated catch block
281
		// TODO Auto-generated catch block
286
		e.printStackTrace();
282
		e.printStackTrace();
287
	} catch (TException e) {
283
	} catch (TException e) {
288
		// TODO Auto-generated catch block
284
		// TODO Auto-generated catch block
Line 292... Line 288...
292
}
288
}
293
 
289
 
294
private Address getAddress(long addressId){
290
private Address getAddress(long addressId){
295
	List<Address> addresses = null;
291
	List<Address> addresses = null;
296
	try {
292
	try {
297
		addresses = usc.getClient().getPrimaryInfo(pmnt.getUser_id(), false).getAddresses();
293
		addresses = usc.getClient().getUserById(pmnt.getUser_id()).getAddresses();
298
	} catch (UserContextException e) {
294
	} catch (UserContextException e) {
299
		// TODO Auto-generated catch block
295
		// TODO Auto-generated catch block
300
		e.printStackTrace();
296
		e.printStackTrace();
301
	} catch (TException e) {
297
	} catch (TException e) {
302
		// TODO Auto-generated catch block
298
		// TODO Auto-generated catch block
Line 463... Line 459...
463
		
459
		
464
		
460
		
465
		OrderInfo orderInfo = new OrderInfo();
461
		OrderInfo orderInfo = new OrderInfo();
466
		t.setOrderInfo(orderInfo);
462
		t.setOrderInfo(orderInfo);
467
		
463
		
468
		List<Line> lines = c.getLines();
464
		List<LineItem> lines = c.getLines();
469
		
465
		
470
		for(Line line : lines){
466
		for(in.shop2020.model.v1.user.LineItem line : lines){
471
			if(line.getLineStatus() == LineStatus.LINE_ACTIVE){
467
			if(line.getLineStatus() == LineStatus.LINE_ACTIVE){
472
				//line is active
468
				//line is active
473
				LineItem lineItem = new LineItem();
469
				LineItem lineItem = new LineItem();
474
				Item item = null;
470
				Item item = null;
475
				try {
471
				try {