You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

354 lines
17 KiB

  1. using Newtonsoft.Json;
  2. using Swift.API.Common;
  3. using Swift.DAL.Common;
  4. using Swift.DAL.OnlineAgent;
  5. using Swift.DAL.SwiftDAL;
  6. using Swift.web.Library;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Threading.Tasks;
  10. using System.Web.Script.Serialization;
  11. namespace Swift.web.AgentPanel.OnlineAgent.CustomerSetup
  12. {
  13. public partial class DirectApprove : System.Web.UI.Page
  14. {
  15. private readonly RemittanceLibrary _sl = new RemittanceLibrary();
  16. private readonly OnlineCustomerDao _cd = new OnlineCustomerDao();
  17. private string GMEWalletApiBaseUrl = GetStatic.ReadWebConfig("KJURL", "");
  18. private string secretKey = GetStatic.ReadWebConfig("KJsecretKey", "");
  19. private const string ContentType = "application/json";
  20. private const string ViewFunctionId = "40120000";
  21. private const string PartnerServiceKey = "1234";
  22. private string m = GetStatic.ReadQueryString("m", "");
  23. private string id = GetStatic.ReadQueryString("customerId", "");
  24. protected void Page_Load(object sender, EventArgs e)
  25. {
  26. //SendEmail("Test", "this is test<br><br><br>We look forward to provide you excellent service.", "pralhad@swifttech.com.np");
  27. //return;
  28. //KJBankAPIConnection.GetAccountDetailKJBank("0001107000816", "034");
  29. _sl.CheckSession();
  30. btnApprove.Visible = false;
  31. if (!IsPostBack)
  32. {
  33. Authenticate();
  34. if (id != "")
  35. {
  36. if (m != "")
  37. {
  38. btnApprove.Visible = true;
  39. }
  40. PopulateCustomerDetails(id);
  41. }
  42. }
  43. }
  44. private void Authenticate()
  45. {
  46. _sl.CheckAuthentication(ViewFunctionId);
  47. }
  48. private void PopulateCustomerDetails(string id)
  49. {
  50. btnApprove.Visible = false;
  51. var dr = _cd.GetVerifyCustomerDetails(id, GetStatic.GetUser());
  52. hdnCustomerId.Value = dr["customerId"].ToString();
  53. fullName.Text = dr["fullName"].ToString();
  54. hdnAccountName.Value = fullName.Text;
  55. genderList.Text = dr["gender"].ToString();
  56. countryList.Text = dr["country"].ToString();
  57. addressLine1.Text = dr["address"].ToString();
  58. postalCode.Text = dr["postalCode"].ToString();
  59. city.Text = dr["city"].ToString();
  60. email.Text = dr["email"].ToString();
  61. phoneNumber.Text = dr["telNo"].ToString();
  62. mobile.Text = dr["mobile"].ToString();
  63. nativeCountry.Text = dr["nativeCountry"].ToString();
  64. dob.Text = dr["dob"].ToString();
  65. occupation.Text = dr["occupation"].ToString();
  66. IssueDate.Text = dr["idIssueDate"].ToString();
  67. ExpireDate.Text = dr["idExpiryDate"].ToString();
  68. idType.Text = dr["idType"].ToString();
  69. verificationTypeNo.Text = dr["idNumber"].ToString();
  70. bankName.Text = dr["bankName"].ToString();
  71. accountNumber.Text = dr["bankAccountNo"].ToString();
  72. hdnAccountNumber.Value = accountNumber.Text;
  73. hdnVirtualAccountNo.Value = dr["walletAccountNo"].ToString();
  74. walletNumber.InnerText = dr["walletAccountNo"].ToString();
  75. /*
  76. * @Max- 2018.09
  77. * -
  78. * */
  79. hdnIdTypeCode.Value = dr["idTypeCode"].ToString();
  80. hdnGenderCode.Value = dr["genderCode"].ToString();
  81. hdnNativeCountryCode.Value = dr["nativeCountryCode"].ToString();
  82. hdnDobYmd.Value = dr["dobYMD"].ToString();
  83. //var response = KJBankAPIConnection.GetAccountDetailKJBank(accountNumber.Text, dr["bankCode"].ToString());
  84. var request = new RealNameRequest();
  85. request.institution = dr["bankCode"].ToString();
  86. request.no = accountNumber.Text;
  87. var idNumber = verificationTypeNo.Text.Replace("-", "");
  88. //주민번호
  89. if (hdnIdTypeCode.Value == "8008")
  90. {
  91. request.realNameDivision = "01";
  92. request.realNameNo = idNumber;
  93. }
  94. //외국인등록번호
  95. else if (hdnIdTypeCode.Value == "1302")
  96. {
  97. request.realNameDivision = "02";
  98. request.realNameNo = idNumber;
  99. }
  100. //여권번호는 조합주민번호로 변경
  101. else if (hdnIdTypeCode.Value == "10997")
  102. {
  103. request.realNameDivision = "04";
  104. //조합주민번호(생년월일-성별-국적-여권번호(마지막5자리))
  105. request.realNameNo = String.Format("{0}{1}{2}{3}",
  106. hdnDobYmd.Value,
  107. hdnGenderCode.Value,
  108. hdnNativeCountryCode.Value,
  109. idNumber.Substring(idNumber.Length - 5));
  110. }
  111. string requestBody = JsonConvert.SerializeObject(request);
  112. var response = KJBankAPIConnection.GetRealNameCheck(requestBody);
  113. if (response.ErrorCode == "0")
  114. {
  115. response.Msg = response.Msg.Split(':')[1];
  116. response.Msg = response.Msg.Replace("}", "");
  117. response.Msg = response.Msg.Trim();
  118. lblBankAcName.Text = response.Msg;
  119. if (!string.IsNullOrWhiteSpace(lblBankAcName.Text))
  120. {
  121. btnApprove.Visible = true;
  122. }
  123. }
  124. else
  125. {
  126. GetStatic.AlertMessage(this, "Account Name in Bank is required");
  127. }
  128. //AcBankName.Text = KJBankAPIConnection.GetAccountDetailKJBank(accountNumber.Text, dr["bankCode"].ToString()).Msg;
  129. //AcBankName.Text = AcBankName.Text.Replace("\"", "");
  130. if (dr["verifyDoc1"].ToString() != "")
  131. verfDoc1.ImageUrl = "GetDocumentView.ashx?imageName=" + dr["verifyDoc1"] + "&idNumber=" + dr["homePhone"];
  132. if (dr["verifyDoc2"].ToString() != "")
  133. verfDoc2.ImageUrl = "GetDocumentView.ashx?imageName=" + dr["verifyDoc2"] + "&idNumber=" + dr["homePhone"];
  134. if (dr["verifyDoc3"].ToString() != "")
  135. verfDoc3.ImageUrl = "GetDocumentView.ashx?imageName=" + dr["verifyDoc3"] + "&idNumber=" + dr["homePhone"];
  136. if (dr["verifyDoc4"].ToString() != "")
  137. verifyDoc4.ImageUrl = "GetDocumentView.ashx?imageName=" + dr["verifyDoc4"] + "&idNumber=" + dr["homePhone"];
  138. }
  139. protected void approve_Click(object sender, EventArgs e)
  140. {
  141. if (string.IsNullOrWhiteSpace(lblBankAcName.Text))
  142. {
  143. btnApprove.Visible = false;
  144. GetStatic.AlertMessage(this, "Account Name in Bank is required");
  145. return;
  146. }
  147. var dbResult = _cd.ApprovePending(id, GetStatic.GetUser(), lblBankAcName.Text);
  148. if (dbResult.Tables.Count == 1)
  149. {
  150. if (dbResult.Tables[0].Rows[0]["ErrorCode"].ToString() == "1")
  151. {
  152. msg.InnerText = dbResult.Tables[0].Rows[0]["Msg"].ToString();
  153. msg.Visible = true;
  154. }
  155. }
  156. else if (dbResult.Tables.Count == 2)
  157. {
  158. msg.Visible = false;
  159. if (dbResult.Tables[1].Rows[0]["ErrorCode"].Equals("0"))
  160. {
  161. if (dbResult.Tables[0].Rows[0]["username"] != null)
  162. {
  163. string channel = dbResult.Tables[0].Rows[0]["channel"].ToString();
  164. string username = dbResult.Tables[0].Rows[0]["username"].ToString();
  165. string pwd = dbResult.Tables[0].Rows[0]["password"].ToString();
  166. string walletAccountNo = dbResult.Tables[0].Rows[0]["walletAccountNo"].ToString();
  167. string bankAccountNo = dbResult.Tables[0].Rows[0]["bankAccountNo"].ToString();
  168. string fullName = dbResult.Tables[0].Rows[0]["fullName"].ToString();
  169. string CustomerBankName = dbResult.Tables[0].Rows[0]["CustomerBankName"].ToString();
  170. if (string.IsNullOrWhiteSpace(CustomerBankName))
  171. {
  172. btnApprove.Visible = false;
  173. GetStatic.AlertMessage(this, "Account Name in Bank is required");
  174. return;
  175. }
  176. string msgBody = GetApprovedCustomerMsgBody(channel, username, pwd, walletAccountNo);
  177. string msgSubject = "Customer verification approved";
  178. /*
  179. * @Max - 2018.09
  180. * -
  181. * */
  182. var requestObj = new PartnerServiceAccountRequest()
  183. {
  184. processDivision = "01",
  185. institution = dbResult.Tables[0].Rows[0]["bankCode"].ToString(),
  186. depositor = CustomerBankName,
  187. no = bankAccountNo,
  188. virtualAccountNo = walletAccountNo,
  189. obpId = ""
  190. };
  191. var idNumber = dbResult.Tables[0].Rows[0]["idNumber"].ToString().Replace("-", "");
  192. //주민번호
  193. if (dbResult.Tables[0].Rows[0]["idType"].ToString() == "8008")
  194. {
  195. requestObj.realNameDivision = "01";
  196. requestObj.realNameNo = idNumber;
  197. }
  198. //외국인등록번호
  199. else if (dbResult.Tables[0].Rows[0]["idType"].ToString() == "1302")
  200. {
  201. requestObj.realNameDivision = "02";
  202. requestObj.realNameNo = idNumber;
  203. }
  204. //여권번호는 조합주민번호로 변경
  205. else if (dbResult.Tables[0].Rows[0]["idType"].ToString() == "10997")
  206. {
  207. requestObj.realNameDivision = "04";
  208. //조합주민번호(생년월일-성별-국적-여권번호(마지막5자리))
  209. requestObj.realNameNo = String.Format("{0}{1}{2}{3}",
  210. dbResult.Tables[0].Rows[0]["dobYMD"].ToString(),
  211. dbResult.Tables[0].Rows[0]["genderCode"].ToString(),
  212. dbResult.Tables[0].Rows[0]["nativeCountryCode"].ToString(),
  213. idNumber.Substring(idNumber.Length - 5));
  214. }
  215. //var response = SendNotificationToKjBank(CustomerBankName, bankAccountNo, walletAccountNo, dbResult.Tables[0].Rows[0]["bankCode"].ToString());
  216. var response = SendNotificationToKjBank(requestObj);
  217. if (response.ErrorCode == "0")
  218. {
  219. Task.Factory.StartNew(() => { SendEmail(msgSubject, msgBody, username); });
  220. }
  221. }
  222. GetStatic.SetMessage(dbResult.Tables[1].Rows[0]["ErrorCode"].ToString(), dbResult.Tables[1].Rows[0]["Msg"].ToString());
  223. //var url = "~/GMEAPI/GMERegistrationForDepositVerification.aspx?processDivision=" + ProcessDivision + "&institution=" + hdninstitution.Value + "&AccountName=" + hdnAccountName.Value + "&AccountNumber=" + hdnAccountNumber.Value + "&VirtualAccountNo=" + hdnVirtualAccountNo.Value + "&partnerServiceKey=" + PartnerServiceKey + "&id=" + id;
  224. //Response.Redirect(url);
  225. Response.Redirect("List.aspx");
  226. }
  227. }
  228. GetStatic.AlertMessage(Page, dbResult.Tables[0].Rows[0]["msg"].ToString());
  229. }
  230. /*
  231. * @Max - 2018.09
  232. * KJBank -
  233. * */
  234. // private DbResult SendNotificationToKjBank(string AccountName, string AccountNumber, string
  235. // VirtualAccountNo, string bankCode)
  236. private DbResult SendNotificationToKjBank(PartnerServiceAccountRequest reqObject)
  237. {
  238. //var reqObject = new PartnerServiceAccountRequest();
  239. //reqObject.processDivision = "01";
  240. //reqObject.institution = bankCode;
  241. //reqObject.depositor = AccountName;
  242. //reqObject.no = AccountNumber;
  243. //reqObject.virtualAccountNo = VirtualAccountNo;
  244. string body = new JavaScriptSerializer().Serialize((reqObject));
  245. var response = KJBankAPIConnection.CustomerRegistration(body);
  246. if (response.ErrorCode == "0")
  247. {
  248. var dbresult = _cd.UpdateObpId(id, GetStatic.GetUser(), response.Id);
  249. response = dbresult;
  250. if (dbresult.ErrorCode == "0")
  251. {
  252. GetStatic.CallBackJs1(Page, "Show Alert", "ShowAlert('Virtual Account registration successfully');");
  253. }
  254. }
  255. else
  256. {
  257. GetStatic.CallBackJs1(Page, "Show Alert", "ShowAlert('Fail to register customer through API');");
  258. }
  259. return response;
  260. }
  261. private void SendEmail(string msgSubject, string msgBody, string toEmailId)
  262. {
  263. SmtpMailSetting mail = new SmtpMailSetting
  264. {
  265. MsgBody = msgBody,
  266. MsgSubject = msgSubject,
  267. ToEmails = toEmailId
  268. };
  269. List<AttachmentModel> attachmentList = new List<AttachmentModel>();
  270. attachmentList.Add(new AttachmentModel
  271. {
  272. FileName = "GME-TermsAndConditions.pdf",
  273. FilePath = GetStatic.ReadWebConfig("defaultDocPath") + "/SampleFile/GME-TermsAndConditions.pdf",
  274. FileType = "application/pdf"
  275. });
  276. mail.SendSmtpMail(mail, attachmentList);
  277. }
  278. public string GetApprovedCustomerMsgBody(string channel, string username, string pwd, string account)
  279. {
  280. var mailBody = "Dear Mr./Ms./Mrs. " + fullName.Text + ",";
  281. if (channel == "online")
  282. {
  283. mailBody +=
  284. "<br><br>Thank you for registering with JME Online Remittance.";
  285. }
  286. else
  287. {
  288. mailBody +=
  289. "<br><br>Thank you for registering with JME Online Remittance. Please find your username below:";
  290. mailBody += "<br><br>Username: " + username;
  291. mailBody += "<br>Password: " + pwd;
  292. }
  293. mailBody +=
  294. "<br><br>Your login with JMERemit is checked and validated. You can now start sending remittance to your desired country.";
  295. mailBody +=
  296. "<br><br><br>PROCESS TO TRANSFER FUNDS:";
  297. mailBody += "<br>• Your unique account number with JME is " + account + ", it is displayed in your login window all the time";
  298. mailBody += "<br>• Please make your desired transfer in your JME account through your nearest ATM or ebanking";
  299. mailBody += "<br>• Login to <a href=\"http://www.gmeremit.com\"> www.gmeremit.com </a> and click send money. Please enter your beneficiary details to transfer funds";
  300. mailBody += "<br>• For cash transfers, you will receive a PIN Code after successfully submitting your details. For account transfers to your desired country, JME will process the transactions to be deposited within 24 hours (deposit time may vary where beneficiary banks are not easily accessible)";
  301. mailBody += "<br>• All cash transfers has to be verified by JME and are ready to collect at your location within an hour";
  302. mailBody += "<br><br>Note: *All Receipts generated after successful transfers are also sent to your registered email.";
  303. mailBody += "<br><br><br>*Money transfer limit per transaction is USD 3,000 and USD 20,000 for 1 year.";
  304. mailBody +=
  305. "<br><br>If you need further assistance kindly reply this email or call us at 02-3673-5559. or visit our website <a href=\"http://www.gmeremit.com\"> www.gmeremit.com </a>";
  306. mailBody +=
  307. "<br><br><br>We look forward to provide you excellent service.";
  308. mailBody +=
  309. "<br><br>Thank You.";
  310. mailBody +=
  311. "<br><br><br>Regards,";
  312. mailBody +=
  313. "<br>JME Online Team";
  314. mailBody +=
  315. "<br>Head Office";
  316. mailBody +=
  317. "<br>325, Jong-ro, ";
  318. mailBody +=
  319. "<br>Jongno-gu, 03104 Seoul, Korea ";
  320. mailBody +=
  321. "<br>Phone number 02-3673-5559 ";
  322. return mailBody;
  323. }
  324. }
  325. }