Subversion Repositories SmartDukaan

Rev

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

Rev 3721 Rev 3830
Line 30... Line 30...
30
    @InterceptorRef("login")
30
    @InterceptorRef("login")
31
})
31
})
32
 
32
 
33
public class PaySuccessController extends BaseController{
33
public class PaySuccessController extends BaseController{
34
	private static final long serialVersionUID = 1L;
34
	private static final long serialVersionUID = 1L;
-
 
35
	
-
 
36
	private static final String ITEM = "ITEM";
-
 
37
	private static final String ITEMS = "ITEMS";
35
 
38
	
36
	private static Logger log = Logger.getLogger(Class.class);
39
	private static Logger log = Logger.getLogger(Class.class);
37
	private FormattingUtils formattingUtils = new FormattingUtils();
40
	private FormattingUtils formattingUtils = new FormattingUtils();
38
    
41
    
39
	
42
	
40
	long merchantPaymentId;
43
	long merchantPaymentId;
Line 66... Line 69...
66
		long txnId;
69
		long txnId;
67
		try {
70
		try {
68
			txnId = paymentServiceClient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
71
			txnId = paymentServiceClient.getClient().getPayment(merchantPaymentId).getMerchantTxnId();
69
			orders = transactionServiceClient.getClient().getOrdersForTransaction(txnId, userinfo.getUserId());
72
			orders = transactionServiceClient.getClient().getOrdersForTransaction(txnId, userinfo.getUserId());
70
			Cart cart = userServiceClient.getClient().getCart(userinfo.getCartId());
73
			Cart cart = userServiceClient.getClient().getCart(userinfo.getCartId());
71
			int totalItems = 0;
-
 
72
			if(cart != null){
74
			if(cart != null){
73
				totalItems = cart.getLinesSize();
75
				userinfo.setTotalItems(cart.getLinesSize());
-
 
76
				userinfo.setTotalAmount(cart.getTotalPrice());
-
 
77
			}else{
-
 
78
				userinfo.setTotalItems(0);
-
 
79
				userinfo.setTotalAmount(0);
74
			}
80
			}
75
			userinfo.setTotalItems(totalItems);
81
			
76
			if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
82
			if (cookiesMap.containsKey(TrackingInterceptor.AFF_COOKIE)) {
77
	            long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
83
	            long affId = Long.parseLong(cookiesMap.get(TrackingInterceptor.AFF_COOKIE).getValue());
78
	            userServiceClient.getClient().addTrackLog(affId, userinfo.getUserId(), TrackLogType.PAYMENT_SUCCESS, "",
84
	            userServiceClient.getClient().addTrackLog(affId, userinfo.getUserId(), TrackLogType.PAYMENT_SUCCESS, "",
79
                        Long.toString(merchantPaymentId), (new Date()).getTime());
85
                        Long.toString(merchantPaymentId), (new Date()).getTime());
80
	        }
86
	        }
-
 
87
			
-
 
88
			String suffix = ITEM;
-
 
89
			if(orders.size() > 1)
-
 
90
			    suffix = ITEMS;
-
 
91
			
81
			if(orders.get(0).isCod())
92
			if(orders.get(0).isCod())
82
			    this.message = "Order placed successfully";
93
			    this.message = "You have successfully ordered <span class=\"orange\">" + orders.size() + " " + suffix + ".</span>";
83
			else
94
			else
84
				{
-
 
85
			    	this.message = "Payment completed successfully. <br/>" + 
95
				this.message = "You have successfully ordered <span class=\"orange\">" + orders.size() + " " + suffix + ".</span>" + 
86
			    	"Congratulations! Your order qualifies for the 100% Cashback Offer. <br/>" +
96
				" <br/> Congratulations! Your order qualifies for the 100% Cashback Offer. <br/>" +
87
			    	"We will get in touch with you if you are the lucky winner. <br/>" +
97
				"We will get in touch with you if you are the lucky winner. <br/>" +
88
			    	"Meanwhile you can check out all our winners on our <a href='http://www.facebook.com/mysaholic'>Facebook Page</a> .";
98
				"Meanwhile you can check out all our winners on our <a href='http://www.facebook.com/mysaholic'>Facebook Page</a> .";
89
				}
-
 
90
			
-
 
91
		} catch (PaymentException e) {
99
		} catch (PaymentException e) {
92
			log.error("Payment service not responding. Payment id is" + merchantPaymentId, e);
100
			log.error("Payment service not responding. Payment id is" + merchantPaymentId, e);
93
		} catch (TException e) {
101
		} catch (TException e) {
94
			log.error("Thrift service exception. Payment id is" + merchantPaymentId, e);
102
			log.error("Thrift service exception. Payment id is" + merchantPaymentId, e);
95
		} catch (TransactionServiceException e) {
103
		} catch (TransactionServiceException e) {
Line 115... Line 123...
115
	}
123
	}
116
	
124
	
117
	public String getMessage(){
125
	public String getMessage(){
118
		return this.message;
126
		return this.message;
119
	}	
127
	}	
120
}
-
 
121
128
}
-
 
129