Ejemplo n.º 1
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");
            }
        }
 public MPesaSapamaButtonGenerationStrategy(MPesaSapamaAccountDetails mPesa)
 {
     account = mPesa;
 }