|
|
@@ -15,6 +15,7 @@ import org.wildfly.security.auth.client.MatchRule;
|
|
|
|
|
|
import com.psi.applicationmanager.AppManagerFunction;
|
|
|
import com.psi.applicationmanager.AppMessage;
|
|
|
+import com.psi.common.db.DbWrapper;
|
|
|
import com.psi.common.transactions.McomSubscriber;
|
|
|
import com.psi.common.transactions.Message;
|
|
|
import com.psi.common.transactions.MessageId;
|
|
|
@@ -25,12 +26,23 @@ import com.psi.common.util.StringUtil;
|
|
|
@Stateless
|
|
|
@Remote(AppManagerFunction.class)
|
|
|
public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
+ static DbWrapper db = new DbWrapper("java:jboss/datasources/UssdDbClient");
|
|
|
private static final Logger log = Logger.getLogger(MobileAppThirdPartyHelper.class);
|
|
|
private int code = 0;
|
|
|
|
|
|
@Override
|
|
|
public String processTransaction(String refid, String msisdn, String message, Map<String, String> syntax) {
|
|
|
- return manageTransaction(refid, msisdn, message, syntax).getMessage();
|
|
|
+ String ret = "";
|
|
|
+ try {
|
|
|
+ ret = manageTransaction(refid, msisdn, message, syntax).getMessage();
|
|
|
+ log.info(ret);
|
|
|
+ }catch(Exception e) {
|
|
|
+ if(message.contains("ubagetaccount")) {
|
|
|
+ ret = "Veuillez d abord enregistrer votre compte bancaire ou votre carte prepaydans une agence UBA, pour bénéficier du service MoovMoney Banking. Service client 500.";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("final return : "+ ret);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -139,13 +151,28 @@ public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
//newly added for Ecobank
|
|
|
else if(method.equals("ecobankgetaccount")) {
|
|
|
String[] ecobankgetaccountdata = mparam.split("\\|");
|
|
|
+
|
|
|
+ if(!validateBankAccount(msisdn,mparam)) {
|
|
|
+ finalmessage = "Veuillez d abord enregistrer votre compte bancaire ou votre carte prepaydans une agence ECOBANK, pour bénéficier du service MoovMoney Banking. Service client 500.";
|
|
|
+ log.info("finalmessage: "+finalmessage);
|
|
|
+ return new Message(0,0,finalmessage);
|
|
|
+ }
|
|
|
+
|
|
|
appmanresponse = callUssd("ecobankgetaccount", ecobankgetaccountdata).toString();
|
|
|
}
|
|
|
//newly added for UBA
|
|
|
else if(method.equals("ubagetaccount")) {
|
|
|
String[] ubagetaccountdata = mparam.split("\\|");
|
|
|
+
|
|
|
+ if(!validateBankAccount(msisdn,mparam)) {
|
|
|
+ finalmessage = "Veuillez d abord enregistrer votre compte bancaire ou votre carte prepaydans une agence UBA, pour bénéficier du service MoovMoney Banking. Service client 500.";
|
|
|
+ log.info("finalmessage: "+finalmessage);
|
|
|
+ return new Message(0,0,finalmessage);
|
|
|
+ }
|
|
|
+
|
|
|
appmanresponse = callUssd("ubagetaccount", ubagetaccountdata).toString();
|
|
|
log.info("APPMANRESPONSE: "+appmanresponse);
|
|
|
+
|
|
|
}
|
|
|
else if(method.equals("ussd")) {
|
|
|
if(isfinal) {
|
|
|
@@ -165,6 +192,8 @@ public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
}
|
|
|
log.error("Error: Refid:"+refid+"|method not found!");
|
|
|
}catch(Exception e) {
|
|
|
+ response = StringUtil.base64Encode(new JsonResponse(code,"").toString().getBytes());
|
|
|
+ finalmessage = respmessage + response;
|
|
|
log.error("Error: Refid:"+refid+"|" ,e);
|
|
|
}
|
|
|
if(!isfinal) {
|
|
|
@@ -176,6 +205,20 @@ public class MobileAppThirdPartyHelper implements AppManagerFunction {
|
|
|
private static boolean containsKey(String key) {
|
|
|
return InitializerBean.getUssdgwmenuejb().containsKey(key);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private static boolean validateBankAccount(String msisdn,String mparam) {
|
|
|
+ String[] ubagetaccountdata = mparam.split("\\|");
|
|
|
+
|
|
|
+ String records = (String)db.QueryScalar("SELECT BANKACCOUNTNUMBER FROM TBLMOBILEBANKACCOUNTS WHERE MSISDN = ? AND BANKCODE = ? AND EXTDATA = ?", "", new Object[] { msisdn, ubagetaccountdata[1] , ubagetaccountdata[2]});
|
|
|
+
|
|
|
+ if(StringUtil.isNullOrEmpty(records)) {
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
private String callUssd(final String key, final String ... params) {
|
|
|
String response = "";
|