Beispiel #1
0
        public static void Create(Money amount, string code, string phone)
        {
            MPesaSapamaCode order = new MPesaSapamaCode();

            order.Amount    = amount;
            order.Code      = code;
            order.Phone     = phone;
            order.IsProceed = false;
            order.Save();
        }
Beispiel #2
0
        public override void ProcessRequest()
        {
            var request = context.Request.QueryString;

            //Set variables
            TransactionID = HttpUtility.UrlDecode(request["proxy_trans_id"]);

            Amount   = HttpUtility.UrlDecode(request["trans_amount"]);
            Merchant = HttpUtility.UrlDecode(request["location_id"]);

            PhoneNumber = HttpUtility.UrlDecode(request["phone"]);
            Code        = HttpUtility.UrlDecode(request["trans_id"]);

            try
            {
                //Check IPs
                CheckIP("192.241.213.216");

                //Check duplicated transactions
                CheckIfNotDoneYet(TransactionID);

                //Check if we are the merchant
                CheckMerchant(MPesaSapamaAccountDetails.Exists(Convert.ToInt32(Merchant)));

                //Amount from KES to USD
                Money money          = Money.Parse(Amount); //in KES
                var   ConvertedMoney = CurrencyExchangeHelper.FromCalculate(money, "KES");

                //All OK, let's proceed
                MPesaSapamaCode.Create(ConvertedMoney, Code, PhoneNumber);

                context.Response.Write("OK");
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                context.Response.Write("ERROR");
            }
        }