PgNotification Map(tblRequest request) { PgNotification note = new PgNotification(); if((PgMessageType)request.MessageType==PgMessageType.SMSCN) { note = new SmscNotification(); } if ((PgMessageType)request.MessageType == PgMessageType.SMSCP) { note = new SmscPaymentConfirmation(); } note.Amount = request.Amount; note.ApplicationId = request.ApplicationId; note.MessageType = (PgMessageType) request.MessageType; note.Payee = request.Payee; note.ReferenceNumber = request.ReferenceId; if(note.MessageType==PgMessageType.SMSCN) { var smscn = note as SmscNotification; smscn.OutletPhoneNumber = request.Smsc_PhoneNumber; smscn.TillNumber = request.Smsc_TillNumber; } return note; }
public int Save(PgNotification entity) { tblRequest toSave = new tblRequest(); toSave.Amount = entity.Amount; toSave.ApplicationId = entity.ApplicationId; toSave.DateCreated = DateTime.Now; toSave.Payee = entity.Payee; toSave.ReferenceId = entity.ReferenceNumber.ToString(); if (entity is SmscNotification) { SmscNotification smcs = entity as SmscNotification; toSave.Smsc_PhoneNumber = smcs.OutletPhoneNumber; toSave.Smsc_TillNumber = smcs.TillNumber; toSave.MessageType = (int)entity.MessageType; } if (entity is SmscPaymentConfirmation) { SmscPaymentConfirmation smcs = entity as SmscPaymentConfirmation; toSave.Smsc_PhoneNumber = smcs.OutletPhoneNumber; toSave.Smsc_TillNumber = smcs.TillNumber; toSave.MessageType = (int)entity.MessageType; } if (entity is Eazy247Notification) { Eazy247Notification smcs = entity as Eazy247Notification; toSave.Smsc_PhoneNumber = smcs.OutletPhoneNumber; toSave.Smsc_TillNumber = smcs.BillerNumber; toSave.MessageType = (int)entity.MessageType; } if (entity is Easy247Payment) { Easy247Payment smcs = entity as Easy247Payment; toSave.Smsc_PhoneNumber = smcs.OutletPhoneNumber; toSave.Smsc_TillNumber = smcs.BillerNumber; toSave.MessageType = (int)entity.MessageType; } _ctx.tblRequest.Add(toSave); _ctx.SaveChanges(); return toSave.Id; }
public void ProcessRequest(PgNotification notification, out RequestMessage sms) { string version = "1.0"; string password = "******"; string sourcesAddress = "hewani"; string AppID = "APP_000007"; string message = ""; sms = new RequestMessage(); if (notification is SmscNotification) { SmscNotification smsc = notification as SmscNotification; message= "Invoice Notification: Thank you for trans ref " + smsc.TransactionId + ". Please pay amount " + smsc.Amount.ToString("N2") + " to till No. " + smsc.TillNumber + ". " + smsc.Payee; var addr = new List<string>(); addr.Add("tel:" + smsc.OutletPhoneNumber); sms = new RequestMessage { applicationID = AppID, encoding = RequestEncoding.Text, message = message, address = addr, version = version, binaryHeader = "Content-Type:application/json", chargingAmount = smsc.Amount, password = password, sourceAddress = sourcesAddress, statusRequest = StatusRequest.DeliveryRequestNotRequired, }; } else if (notification is SmscPaymentConfirmation) { SmscPaymentConfirmation smscp = notification as SmscPaymentConfirmation; var addr = new List<string>(); addr.Add("tel:" + smscp.OutletPhoneNumber); message = "Payment Confirmation: Thank for your trans ref: " + smscp.TransactionId + ". Payment amount " + smscp.Amount.ToString("N2") + " to till No. " + smscp.TillNumber + " Received with thanks. " + smscp.Payee; sms = new RequestMessage { applicationID = AppID, encoding = RequestEncoding.Text, message = message, address = addr, version = version, binaryHeader = "Content-Type:application/json", chargingAmount = smscp.Amount, password = password, sourceAddress =sourcesAddress, statusRequest = StatusRequest.DeliveryRequestNotRequired, }; } else if (notification is Easy247Payment) { Easy247Payment payment = notification as Easy247Payment; var addr = new List<string>(); addr.Add("tel:" + payment.OutletPhoneNumber); message = "Payment Confirmation: Thank for your trans ref: " + payment.TransactionId + ". Payment amount " + payment.Amount.ToString("N2") + " to Biller No. " + payment.BillerNumber + " Received with thanks. " + payment.Payee; sms = new RequestMessage { applicationID = AppID, encoding = RequestEncoding.Text, message = message, address = addr, version = version, binaryHeader = "Content-Type:application/json", chargingAmount = payment.Amount, password = password, sourceAddress = sourcesAddress, statusRequest = StatusRequest.DeliveryRequestNotRequired, }; } else if (notification is Eazy247Notification) { Eazy247Notification easy = notification as Eazy247Notification; message = "Invoice Notification: Thank you for trans ref " + easy.TransactionId + ". Please pay amount " + easy.Amount.ToString("N2") + " to Biller No. " + easy.BillerNumber + ". " + easy.Payee; var addr = new List<string>(); addr.Add("tel:" + easy.OutletPhoneNumber); sms = new RequestMessage { applicationID = AppID, encoding = RequestEncoding.Text, message = message, address = addr, version = version, binaryHeader = "Content-Type:application/json", chargingAmount = easy.Amount, password = password, sourceAddress = sourcesAddress, statusRequest = StatusRequest.DeliveryRequestNotRequired, }; } }
private void SaveNSend(PgNotification notification, RequestMessage msg) { SendToHSenid(msg, notification.ReferenceNumber.ToString()); _smscRepository.Save(notification); }
public Thread StartTheSaveAndSendThread(PgNotification smsc, RequestMessage msg) { var t = new Thread(() => SaveNSend(smsc, msg)); t.Start(); return t; }