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.

68 lines
2.3 KiB

8 months ago
  1. using GMEStatusSync.Common;
  2. using GMEStatusSync.Dao.KoronaPay;
  3. using GMEStatusSync.Helper;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Data;
  7. namespace GMEStatusSync.Business.KoronaPay
  8. {
  9. public class KoronaPayBusiness
  10. {
  11. private KoronaPayDao koronapay;
  12. public KoronaPayBusiness()
  13. {
  14. koronapay = new KoronaPayDao();
  15. }
  16. public void SynchronizeTran()
  17. {
  18. GetStatic.WriteLog("Koronapay Status Checking Started on :");
  19. var dt = koronapay.GetTransactions();
  20. if (dt == null || dt.Rows.Count == 0)
  21. {
  22. return;
  23. }
  24. foreach (DataRow row in dt.Rows)
  25. {
  26. try
  27. {
  28. var json = new {oId= row["oId"]};
  29. GMECoreAPIRequest req = new GMECoreAPIRequest();
  30. req.provider = "koronapay";
  31. req.processId = Guid.NewGuid().ToString();
  32. req.requestJSON = JsonConvert.SerializeObject(json);
  33. var res = ThirdPartyApi.GetStatus(req);
  34. if (res != null)
  35. {
  36. var st = JsonConvert.DeserializeObject<GetStatusResponseModel>(res);
  37. if (st.TpStatus.ToUpper() == "PAIDOUT" && st.ErrorCode=="0")
  38. {
  39. GetStatic.WriteLog(row["ControlNo"] + " updating as paid");
  40. koronapay.SynchronizePaid(Convert.ToString(row["TranId"]));
  41. }
  42. else if (st.ErrorCode == "0" && (st.TpStatus.ToUpper() == "REFUNDED" || st.TpStatus.ToUpper() =="CANCELED"))
  43. {
  44. GetStatic.WriteLog(row["ControlNo"] + " updating as cancel");
  45. koronapay.SynchronizeCancel(Convert.ToString(row["TranId"]));
  46. }
  47. }
  48. else
  49. {
  50. GetStatic.WriteLog("Null from Third party api call :");
  51. }
  52. }
  53. catch (Exception ex)
  54. {
  55. GetStatic.WriteLog(ex.ToString());
  56. continue;
  57. }
  58. GetStatic.WriteLog("Koronapay Status Checking Ended on :");
  59. }
  60. }
  61. }
  62. }