Ejemplo n.º 1
0
 PgNotification DeserializeCommand(PgMessageType ct, string jsonNotification)
 {
     switch (ct)
     {
             
         case PgMessageType.SMSCN:
             SmscNotification note = null;
             _notificationValidation.CanDeserializeNotification(jsonNotification, out note);
             return note;
         case PgMessageType.SMSCP:
             SmscPaymentConfirmation smscp = null;
             _notificationValidation.CanDeserializeNotification(jsonNotification, out smscp);
             return smscp;
         case PgMessageType.Eazy247N:
             Eazy247Notification easyn = null;
             _notificationValidation.CanDeserializeNotification(jsonNotification, out easyn);
             return easyn;
         case PgMessageType.Eazy247P:
             Easy247Payment easyp = null;
             _notificationValidation.CanDeserializeNotification(jsonNotification, out easyp);
             return easyp;
         default:
             throw new Exception("Failed to deserialize Notifiaction in Notification deserializer");
     }
     return null;
 }
Ejemplo n.º 2
0
        private void SendTest (PgMessageType type)
        {
            string mssg = "";
            NameValueCollection param = new NameValueCollection();
            if (type == PgMessageType.SMSCN)
            {
                mssg = JsonConvert.SerializeObject(new SmscNotification
                                                              {
                                                                  Amount = 100,
                                                                  ApplicationId = Guid.Parse("36EDE98E-714D-4E8E-88E1-5E96A9B2EF67"),
                                                                  MessageType = PgMessageType.SMSCN,
                                                                  Payee = "Mburu",
                                                                  ReferenceNumber = Guid.NewGuid().ToString(),
                                                                  TillNumber = "200000",
                                                                  OutletPhoneNumber = "254724552471",
                                                                  TransactionId = "Order_323_34234_434"
                                                              }
                    );
                param.Add("messageType", "SMSCN");
            }
            if (type == PgMessageType.SMSCP)
            {
                mssg = JsonConvert.SerializeObject(new SmscPaymentConfirmation
                                                       {
                                                           Amount = 100,
                                                           ApplicationId = Guid.Parse("36EDE98E-714D-4E8E-88E1-5E96A9B2EF67"),
                                                           MessageType = PgMessageType.SMSCP, 
                                                           Payee = "Mburu",
                                                           ReferenceNumber = Guid.NewGuid().ToString(),
                                                           TillNumber = "200000",
                                                           OutletPhoneNumber = "254722557538",
                                                           TransactionId = "Order_323_34234_434"
                                                       }
                    );
                param.Add("messageType", "SMSCP");
            }
            if (type == PgMessageType.Eazy247N)
            {
                mssg = JsonConvert.SerializeObject(new Eazy247Notification
                {
                    Amount = 100,
                    ApplicationId = Guid.Parse("36EDE98E-714D-4E8E-88E1-5E96A9B2EF67"),
                    MessageType = PgMessageType.Eazy247N,
                    Payee = "Mburu",
                    ReferenceNumber = Guid.NewGuid().ToString(),
                    BillerNumber = "200000",
                    OutletPhoneNumber = "254722557538",
                    TransactionId = "Order_323_34234_434"
                }
                    );
                param.Add("messageType", "Eazy247N");
            }
            if (type == PgMessageType.Eazy247P)
            {
                mssg = JsonConvert.SerializeObject(new Easy247Payment
                {
                    Amount = 100,
                    ApplicationId = Guid.Parse("36EDE98E-714D-4E8E-88E1-5E96A9B2EF67"),
                    MessageType = PgMessageType.Eazy247P,
                    Payee = "Mburu",
                    ReferenceNumber = Guid.NewGuid().ToString(),
                    BillerNumber = "200000",
                    OutletPhoneNumber = "254722557538",
                    TransactionId = "Order_323_34234_434"
                }
                    );
                param.Add("messageType", "Eazy247P");
            }
           // Dictionary<string, string> param = new Dictionary<string, string>();
           
            param.Add("jsonMessage", mssg);
            WebClient wc = new WebClient();
            wc.Encoding = Encoding.UTF8;
            string hsenidUrl = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"));
            Uri uri = new Uri(hsenidUrl + "Notification/Msend", UriKind.Absolute);
         
            wc.UploadValues(uri, "POST", param);//.UploadStringAsync(uri, "POST", param.ToString());
            wc.UploadStringCompleted += (sender, e) =>
                                            {
                                                try
                                                {
                                                    if (e.Error != null)
                                                    {
                                                        string error = e.Error.Message;
                                                        return;
                                                    }
                                                    string jsonResult = e.Result;

                                                }
                                                catch (Exception ex)
                                                {

                                                }
                                            };
           
            //new UploadStringCompletedEventHandler(wc_UploadStringCompleted);
        
           
        }