Subversion Repositories SmartDukaan

Rev

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

Rev 12616 Rev 12978
Line 12... Line 12...
12
import in.shop2020.thrift.clients.PromotionClient;
12
import in.shop2020.thrift.clients.PromotionClient;
13
import in.shop2020.thrift.clients.TransactionClient;
13
import in.shop2020.thrift.clients.TransactionClient;
14
import in.shop2020.utils.DataLogger;
14
import in.shop2020.utils.DataLogger;
15
 
15
 
16
import java.text.SimpleDateFormat;
16
import java.text.SimpleDateFormat;
-
 
17
import java.util.Arrays;
17
import java.util.Date;
18
import java.util.Date;
18
import java.util.HashMap;
19
import java.util.HashMap;
-
 
20
import java.util.List;
19
import java.util.Map;
21
import java.util.Map;
20
 
22
 
21
import org.apache.log4j.Logger;
23
import org.apache.log4j.Logger;
22
import org.apache.thrift.TException;
24
import org.apache.thrift.TException;
23
import org.apache.thrift.transport.TTransportException;
25
import org.apache.thrift.transport.TTransportException;
Line 31... Line 33...
31
    private FormattingUtils formattingUtils = new FormattingUtils();
33
    private FormattingUtils formattingUtils = new FormattingUtils();
32
 
34
 
33
    //private boolean isShooglooAff  = false;
35
    //private boolean isShooglooAff  = false;
34
    
36
    
35
    private static Map<Long,String> allProviders;
37
    private static Map<Long,String> allProviders;
-
 
38
    private static List<Long> asyncOperators = Arrays.asList(9l);
-
 
39
    private boolean rechargeModeSynchronous = false;
-
 
40
    private String rechargeOrderId;
-
 
41
    private String isFinal;
-
 
42
    private String newStatus;
-
 
43
 
-
 
44
    public String getIsFinal() {
-
 
45
        return isFinal;
-
 
46
    }
-
 
47
 
-
 
48
    public void setIsFinal(String isFinal) {
-
 
49
        this.isFinal = isFinal;
-
 
50
    }
-
 
51
 
36
    static {
52
    static {
37
    	try {
53
    	try {
38
			allProviders = new TransactionClient().getClient().getServiceProviders(RechargeType.DTH, true);
54
			allProviders = new TransactionClient().getClient().getServiceProviders(RechargeType.DTH, true);
39
			allProviders.putAll(new TransactionClient().getClient().getServiceProviders(RechargeType.MOBILE, true));
55
			allProviders.putAll(new TransactionClient().getClient().getServiceProviders(RechargeType.MOBILE, true));
40
		} catch (TTransportException e) {
56
		} catch (TTransportException e) {
Line 178... Line 194...
178
//    				Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
194
//    				Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
179
//                    rechargeOrder.getRechargeType().toString());
195
//                    rechargeOrder.getRechargeType().toString());
180
    		return new String[]{"red", "PAYMENT FAILED", "Payment failed at the payment gateway. Try to <a href='/recharge'>recharge again</a>"};
196
    		return new String[]{"red", "PAYMENT FAILED", "Payment failed at the payment gateway. Try to <a href='/recharge'>recharge again</a>"};
181
    	}
197
    	}
182
    	else if(status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL) || status.equals(RechargeOrderStatus.RECHARGE_UNKNOWN)) {
198
    	else if(status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL) || status.equals(RechargeOrderStatus.RECHARGE_UNKNOWN)) {
-
 
199
    	    if (status.equals(RechargeOrderStatus.PAYMENT_SUCCESSFUL)){
183
//    	    DataLogger.logData(EventType.RECHARGE_PAYMENT_SUCCESSFUL, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
200
//    	    DataLogger.logData(EventType.RECHARGE_PAYMENT_SUCCESSFUL, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
184
//                    Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
201
//                    Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
185
//                    rechargeOrder.getRechargeType().toString());
202
//                    rechargeOrder.getRechargeType().toString());
186
    	    return new String[]{"red", "RECHARGE IN PROCESS", "Your Payment was successful but due to some internal error with the operator's system we are not sure if the recharge was successful.<br>" +
203
    	    return new String[]{"red", "RECHARGE IN PROCESS", "Your Payment was successful but due to some internal error with the operator's system we are not sure if the recharge was successful.<br>" +
187
                    "We have put your recharge under process. As soon as we get a confirmation on this transaction, we will notify you.<br>" +
204
                    "We have put your recharge under process. As soon as we get a confirmation on this transaction, we will notify you.<br>" +
Line 189... Line 206...
189
                    "<a href='/my-wallet'>recharge wallet</a>.<br><br> You " +
206
                    "<a href='/my-wallet'>recharge wallet</a>.<br><br> You " +
190
                    "will need to <a href='/login?redirectUrl=/recharge'>login</a> to use your Wallet.<br> If you are registered on" + 
207
                    "will need to <a href='/login?redirectUrl=/recharge'>login</a> to use your Wallet.<br> If you are registered on" + 
191
                    " Saholic.com please use your username and password to Login.<br> In case you are " +
208
                    " Saholic.com please use your username and password to Login.<br> In case you are " +
192
                    "a first time user, we have sent your login details on the emailId you gave us. " +
209
                    "a first time user, we have sent your login details on the emailId you gave us. " +
193
                    "<br>For more information <a href='/static/recharge-faq'>click here</a>"};
210
                    "<br>For more information <a href='/static/recharge-faq'>click here</a>"};
-
 
211
    	    }
-
 
212
    	    else{
-
 
213
    	        setRechargeModeSynchronous(true);
-
 
214
    	        return new String[]{"green", "RECHARGE IN PROCESS", "Your Payment is successful.We have put your recharge under process." +
-
 
215
                        "Please wait while we check with the operator.<b>Please do not close</b> this window or click the Back button on your browser.<br>"};
-
 
216
    	    }
194
    	}
217
    	}
195
    	else if (status.equals(RechargeOrderStatus.RECHARGE_FAILED) || status.equals(RechargeOrderStatus.RECHARGE_FAILED_REFUNDED)){
218
    	else if (status.equals(RechargeOrderStatus.RECHARGE_FAILED) || status.equals(RechargeOrderStatus.RECHARGE_FAILED_REFUNDED)){
196
//    		DataLogger.logData(EventType.RECHARGE_PAYMENT_SUCCESSFUL, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
219
//    		DataLogger.logData(EventType.RECHARGE_PAYMENT_SUCCESSFUL, getSessionId(), userinfo.getUserId(), userinfo.getEmail(),
197
//    				Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
220
//    				Long.toString(rechargeOrder.getOperatorId()), Long.toString(rechargeOrder.getTotalAmount()), Long.toString(rechargeOrder.getWalletAmount()),
198
//    				rechargeOrder.getRechargeType().toString());
221
//    				rechargeOrder.getRechargeType().toString());
Line 245... Line 268...
245
                    "<a href='/my-recharges'>clicking here</a>.<br><br>"};
268
                    "<a href='/my-recharges'>clicking here</a>.<br><br>"};
246
    	} else {
269
    	} else {
247
    	    return new String[]{"red", "ERROR", "INVALID INPUT"};
270
    	    return new String[]{"red", "ERROR", "INVALID INPUT"};
248
    	}
271
    	}
249
    }
272
    }
-
 
273
    
-
 
274
    public String getRechargeStatus() throws NumberFormatException, TException{
-
 
275
        TransactionClient transactionServiceClient = null;
-
 
276
        transactionServiceClient = new TransactionClient();
-
 
277
        RechargeOrder t_rechargeOrder = transactionServiceClient.getClient().getRcgOrderStatus(Long.valueOf(rechargeOrderId), Boolean.valueOf(isFinal));
-
 
278
        setNewStatus(t_rechargeOrder.getStatus().name());
-
 
279
        return "recharge-status";
-
 
280
    }
-
 
281
 
-
 
282
    public void setRechargeModeSynchronous(boolean rechargeModeSynchronous) {
-
 
283
        this.rechargeModeSynchronous = rechargeModeSynchronous;
-
 
284
    }
-
 
285
 
-
 
286
    public boolean isRechargeModeSynchronous() {
-
 
287
        return rechargeModeSynchronous;
-
 
288
    }
-
 
289
    
-
 
290
    public String getRechargeOrderId() {
-
 
291
        return rechargeOrderId;
-
 
292
    }
-
 
293
 
-
 
294
    public void setRechargeOrderId(String rechargeOrderId) {
-
 
295
        this.rechargeOrderId = rechargeOrderId;
-
 
296
    }
-
 
297
 
-
 
298
    public void setNewStatus(String newStatus) {
-
 
299
        this.newStatus = newStatus;
-
 
300
    }
-
 
301
 
-
 
302
    public String getNewStatus() {
-
 
303
        return newStatus;
-
 
304
    }
250
}
305
}
251
306