예제 #1
0
        /// <summary>
        /// Creates some general payza button
        /// </summary>
        /// <param name="itemName">Name describing the item or service. Max Length: 50 characters</param>
        /// <param name="amount">The price or cost of the product or service. The value for
        /// amount must be positive. Null or negative numbers are not allowed.</param>
        /// <param name="command">Describes how handler should handle IPN request.
        /// Stored in field apc_1. Max Length: 100 characters</param>
        /// <param name="args">
        /// Custom values you can pass along with the payment button.
        /// The values are not displayed to the payer on our Pay Process page.
        /// Payza returns these fields back in the IPN.
        /// Used by IIpnHandler ('command')
        /// Stored in fields apc_2 - apc_6. Max Length: 100 characters
        /// </param>
        /// <returns>Http address where member should be redirected after clicking button.</returns>
        protected override string generate(string itemName, Money amount, string command, object[] args)
        {
            string orderId = HashingManager.GenerateMD5(AppSettings.Site.Name + DateTime.Now).ToLower();

            string signature = String.Format("{0}:{1}:{2}:{3}:{4}:{5}", account.AccountEmail,
                                             account.SCIName, amount.ToShortClearString(), AppSettings.Site.CurrencyCode,
                                             AdvCashAccount.APIPassword, orderId);

            signature = HashingManager.SHA256(signature).ToLower();

            NVPStringBuilder nvps = new NVPStringBuilder();

            nvps.Append("ac_account_email", account.AccountEmail)
            .Append("ac_sci_name", account.SCIName)
            .Append("ac_comments", itemName.Substring(0, Math.Min(itemName.Length, ItemNameMaxLength)))
            .Append("ac_amount", amount.ToShortClearString())
            .Append("ac_currency", AppSettings.Site.CurrencyCode)

            .Append("ac_status_url", AppSettings.Site.Url + "Handlers/Payment/AdvCash.ashx")
            .Append("ac_success_url ", ButtonGenerationStrategy.SUCCESS_URL)
            .Append("ac_fail_url", ButtonGenerationStrategy.FAILURE_URL)

            .Append("ac_sign", signature)
            .Append("ac_order_id", orderId)
            .Append("acm_command", command)
            .Append("acm_args", String.Join(ArgsDelimeter + "", args));

            return(Handler + '?' + nvps.Build());
        }
    protected void ProcessorLogoImage_UploadSubmit_Click(object sender, EventArgs e)
    {
        var          fileName = HashingManager.GenerateMD5(DateTime.Now + "paymentLogoImg");
        const string filePath = "~/Images/RepPaymentsLogos/";

        ErrorMessagePanel.Visible = false;
        try
        {
            if (!Page.IsValid)
            {
                return;
            }

            Banner logoImage;
            var    inputStream = ProcessorLogoImage_Upload.PostedFile.InputStream;

            if (!Banner.TryFromStream(inputStream, out logoImage) || logoImage.Width > ImagesHelper.RepresentativesPaymentsLogo.LogoImageMaxWidth ||
                logoImage.Height > ImagesHelper.RepresentativesPaymentsLogo.LogoImageMaxHeight)
            {
                throw new MsgException(string.Format(U6003.INVALIDIMAGEORDIMENSION, ImagesHelper.RepresentativesPaymentsLogo.LogoImageMaxWidth, ImagesHelper.RepresentativesPaymentsLogo.LogoImageMaxHeight));
            }

            logoImage.Save(filePath, fileName);
            ProcessorLogoImage.ImageUrl       = Banner.GetTemporaryBannerPath(logoImage);
            ProcessorLogoImage.DescriptionUrl = logoImage.Path;
            ProcessorLogoImage.Dispose();
        }
        catch (Exception ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
        }
    }
예제 #3
0
    protected void Check2Activate()
    {
        //Disable the refreshbutton
        var refreshbutton = (Button)InstallWizard.FindControl("StepNavigationTemplateContainerID").FindControl("RefreshButton");

        refreshbutton.Visible = true;
        //Disable skip button
        var skipButton = (Button)InstallWizard.FindControl("StepNavigationTemplateContainerID").FindControl("SkipButton");

        skipButton.Visible = false;

        //CRON

        if (File.Exists(Server.MapPath("~/Handlers/RENAME_ME_SCHEDULED_TASK.ashx")))
        {
            string newlocation = HashingManager.GenerateMD5(DateTime.Now + DomainName + BaseUrl);
            File.Move(Server.MapPath("~/Handlers/RENAME_ME_SCHEDULED_TASK.ashx"), Server.MapPath("~/Handlers/cron" + newlocation + ".ashx"));
        }

        string[] files = System.IO.Directory.GetFiles(Server.MapPath("~/Handlers/"), "*.ashx");

        foreach (var file in files)
        {
            if (Path.GetFileName(file).StartsWith("cron"))
            {
                CRONFile.Text = BaseUrl + "Handlers/" + Path.GetFileName(file);
            }
        }
    }
예제 #4
0
    protected void VideoImageButton_Click(object sender, EventArgs e)
    {
        var          fileName = HashingManager.GenerateMD5(DateTime.Now + "miniVideoImg");
        const string filePath = "~/Images/b_ads/";

        try
        {
            Banner videoImage;
            var    inputStream = ImageFileUpload.PostedFile.InputStream;

            if (!Banner.TryFromStream(inputStream, out videoImage) || videoImage.Width > MiniVideoManager.VideoImageMaxWidth ||
                videoImage.Height > MiniVideoManager.VideoImageImageMaxHeight)
            {
                throw new MsgException(string.Format(U6003.INVALIDIMAGEORDIMENSION, MiniVideoManager.VideoImageMaxWidth, MiniVideoManager.VideoImageImageMaxHeight));
            }

            videoImage.Save(filePath, fileName);
            VideoImage.ImageUrl       = Banner.GetTemporaryBannerPath(videoImage);
            VideoImage.DescriptionUrl = videoImage.Path;
            ImageFileUpload.Dispose();
        }
        catch (Exception ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
        }
    }
예제 #5
0
        protected override string generate(string itemName, Money amount, string command, object[] args)
        {
            NVPStringBuilder nvps = new NVPStringBuilder();

            string orderId = HashingManager.GenerateMD5(AppSettings.Site.Name + DateTime.Now).ToLower();

            orderId = orderId.Substring(0, Math.Min(orderId.Length, 31));

            string description = command + "#" + String.Join(ArgsDelimeter + "", args);

            description = itemName + " **" + description;

            string toHash = account.MerchantID + ":" + orderId + ":" + amount.ToShortClearString() + ":" + AppSettings.Site.CurrencyCode
                            + ":" + HashingManager.Base64Encode(description) + ":" + account.SecretKey;
            string hash = HashingManager.SHA256(toHash).ToUpper();

            nvps.Append("m_shop", account.MerchantID)
            .Append("m_orderid", orderId)
            .Append("m_amount", amount.ToShortClearString())
            .Append("m_curr", AppSettings.Site.CurrencyCode)
            .Append("m_desc", HashingManager.Base64Encode(description))
            .Append("m_sign", hash);

            return(HandlerUrl + '?' + nvps.Build());
        }
예제 #6
0
    protected void createPTCImage_UploadSubmit_Click(object sender, EventArgs e)
    {
        var          fileName = HashingManager.GenerateMD5(DateTime.Now + "ptcImg");
        const string filePath = "~/Images/b_ads/";

        try
        {
            Banner ptcImage;
            var    inputStream = PTCImage_Upload.PostedFile.InputStream;

            if (!Banner.TryFromStream(inputStream, out ptcImage) || ptcImage.Width > ImagesHelper.PTC.ImageWidth ||
                ptcImage.Height > ImagesHelper.PTC.ImageHeight)
            {
                throw new MsgException(string.Format(U6003.INVALIDIMAGEORDIMENSION, ImagesHelper.PTC.ImageWidth, ImagesHelper.PTC.ImageHeight));
            }

            ptcImage.Save(filePath, fileName);
            PTCImage_Image.ImageUrl       = Banner.GetTemporaryBannerPath(ptcImage);
            PTCImage_Image.DescriptionUrl = ptcImage.Path;
            PTCImage_Upload.Dispose();
        }
        catch (Exception ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
        }
    }
예제 #7
0
        public override void ProcessRequest()
        {
            string pre1 = context.Request["pre1"];
            string pre2 = context.Request["pre2"];

            pre1 = HashingManager.Base64Decode(pre1);
            string orderId    = pre1.Split('+')[0];
            string statusCode = pre1.Split('+')[1];

            string key = orderId + "+" + statusCode;

            key = HashingManager.Base64Encode(key);
            string md5String = HashingManager.GenerateMD5(key + PaparaAccountDetails.GetSecretKey());

            //Papara transaction OK check
            if (md5String == pre2)
            {
                //Set variables
                OrderID = orderId;

                try
                {
                    PaparaOrder Order = PaparaOrder.Get(Convert.ToInt32(OrderID));

                    Args          = Order.Args;
                    TransactionID = OrderID;
                    Amount        = Order.Amount.ToShortClearString();
                    CommandName   = Order.CommandName;

                    //Check duplicated transactions
                    CheckIfNotDoneYet(OrderID);

                    //All OK, let's proceed
                    Assembly    assembly = Assembly.GetAssembly(typeof(IIpnHandler));
                    var         type     = assembly.GetType(CommandName, true, true);
                    IIpnHandler command  = Activator.CreateInstance(type) as IIpnHandler;

                    command.HandlePapara(Args, TransactionID, Amount);

                    Order.IsPaid = true;
                    Order.Save();

                    context.Response.Redirect(ButtonGenerationStrategy.SUCCESS_URL);
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex);
                    context.Response.Redirect(ButtonGenerationStrategy.FAILURE_URL);
                }
            }
            else
            {
                context.Response.Redirect(ButtonGenerationStrategy.FAILURE_URL);
            }
        }
예제 #8
0
 private string buildTransactionRequestString(TransactionRequest request)
 {
     return(new NVPStringBuilder()
            .Append("api_id", accountDetails.ApiUsername)
            .Append("api_pwd", HashingManager.GenerateMD5(accountDetails.ApiPassword + "s+E_a*"))
            .Append("currency", CurrencyCode)
            .Append("item_id", AppSettings.Payments.TransactionNote)
            .Append("amount", request.Payment.ToShortClearString())
            .Append("user", request.PayeeId)
            .Build());
 }
예제 #9
0
        public static void GetTokenAndLogin(string code, string state)
        {
            if (HttpContext.Current.Session != null && HttpContext.Current.Session[SessionStateKey] != null &&
                HttpContext.Current.Session[SessionStateKey].ToString() != state)
            {
                throw new Exception("Invalid OAuth state.");
            }

            string accessToken =
                OAuth2.AuthenticateByCode(GetProvider(state), HandlerUrl, code).AccessToken;

            string userInfoString = OAuth2.GetUserInfo(GetProvider(state), accessToken);

            JObject UserInfo   = JObject.Parse(userInfoString);
            JToken  UserObject = UserInfo["userObj"];

            string username = UserObject["id"].ToString();

            if (!Member.Exists(username))
            {
                //Register

                string   email     = UserObject["email"].ToString();
                DateTime birthYear = new DateTime((int)UserObject["birth"]["year"], 1, 1);

                TitanRegisterService.Register(username, email, 1234, birthYear,
                                              HashingManager.GenerateMD5(DateTime.Now + username), String.Empty, Gender.Male, null, String.Empty,
                                              String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, true, false, false, null, true);
            }

            Member member = new Member(username);

            member = MemberAuthenticationService.CreateAuthCredentials(member);

            member.BirthYear  = new DateTime((int)UserObject["birth"]["year"], 1, 1);
            member.FirstName  = UserObject["first_name"].ToString();
            member.SecondName = UserObject["last_name"].ToString();
            member.AvatarUrl  = UserObject["avatar_url"].ToString();

            NotNullNameValuePairs nvp = new NotNullNameValuePairs();

            nvp.Add("adzbuzz_affid", UserObject["affid"].ToString());
            nvp.Add("adzbuzz_userid", UserObject["id"].ToString());

            member.Custom = nvp;

            member.Save();

            TitanAuthService.AuthenticateWithChecks(member, false, true);
        }
예제 #10
0
        /// <summary>
        /// Creates some general payza button
        /// </summary>
        /// <param name="itemName">Name describing the item or service. Max Length: 50 characters</param>
        /// <param name="amount">The price or cost of the product or service. The value for
        /// amount must be positive. Null or negative numbers are not allowed.</param>
        /// <param name="command">Describes how handler should handle IPN request.
        /// Stored in field apc_1. Max Length: 100 characters</param>
        /// <param name="args">
        /// Custom values you can pass along with the payment button.
        /// The values are not displayed to the payer on our Pay Process page.
        /// Payza returns these fields back in the IPN.
        /// Used by IIpnHandler ('command')
        /// Stored in fields apc_2 - apc_6. Max Length: 100 characters
        /// </param>
        /// <returns>Http address where member should be redirected after clicking button.</returns>
        protected override string generate(string itemName, Money amount, string command, object[] args)
        {
            string orderId = HashingManager.GenerateMD5(AppSettings.Site.Name + DateTime.Now).ToLower();

            NVPStringBuilder nvps = new NVPStringBuilder();

            nvps.Append("ok_receiver", account.Username)
            .Append("ok_item_1_name", itemName)
            .Append("ok_item_1_price", amount.ToShortClearString())
            .Append("ok_currency", AppSettings.Site.CurrencyCode)
            .Append("ok_fees", "1")
            .Append("ok_invoice", orderId)
            .Append("ok_item_1_custom_1_title", "command")
            .Append("ok_item_1_custom_1_value", command)
            .Append("ok_item_1_custom_2_title", "args")
            .Append("ok_item_1_custom_2_value", HashingManager.Base64Encode(String.Join(ArgsDelimeter + "", args)));

            return(Handler + '?' + nvps.Build());
        }
예제 #11
0
    protected void WizardStep8_Activate(object sender, EventArgs e)
    {
        //Disable the refreshbutton
        var refreshbutton = (Button)InstallWizard.FindControl("StepNavigationTemplateContainerID").FindControl("RefreshButton");

        refreshbutton.Visible = false;

        var configuration = WebConfigurationManager.OpenWebConfiguration("~");
        var section       = (ConnectionStringsSection)configuration.GetSection("connectionStrings");

        FinalCS.Text  = section.ConnectionStrings["ClientDbString"].ConnectionString;
        FinalFCS.Text = section.ConnectionStrings["yafnet"].ConnectionString;

        //Forum config setup
        var section2 = (AppSettingsSection)configuration.GetSection("appSettings");

        section2.Settings["YAF.ConfigPassword"].Value = HashingManager.GenerateMD5(DateTime.Now + DomainName);
        configuration.Save();
    }
예제 #12
0
        protected bool CheckIncomeHash()
        {
            List <SolidTrustPayAccountDetails> gateWays = TableHelper.SelectRows <SolidTrustPayAccountDetails>(TableHelper.MakeDictionary("IsActive", true));

            bool isOk = false;

            foreach (var gateway in gateWays)
            {
                try
                {
                    string toHash = TransactionID + ":" + HashingManager.GenerateMD5(gateway.PaymentButtonsPassword) + ":" + Amount + ":" +
                                    MerchantAccount + ":" + PayerAccount;

                    CheckHash(SentHash, HashingManager.GenerateMD5(toHash));
                    isOk = true;
                }
                catch (Exception ex) { }
            }

            return(isOk);
        }
예제 #13
0
        public override TransactionResponse CommitTransaction(TransactionRequest request)
        {
            try
            {
                //Creating proxy client
                using (var proxy = new I_OkPayAPIClient())
                {
                    string ID = HashingManager.GenerateMD5(DateTime.Now + request.MemberName + AppSettings.Site.Url);

                    //Send Money
                    var OI = proxy.Send_Money(Details.Username, SecurityToken, request.PayeeId, AppSettings.Site.CurrencyCode, Decimal.Parse(request.Payment.ToShortClearString()),
                                              request.Note, true, ID);

                    return(new OKPayTransactionResponse(this, OI));
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                return(new OKPayTransactionResponse(this, ex));
            }
        }
예제 #14
0
    protected void VideoSourceButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (VideoFileUpload.PostedFile.ContentLength > MiniVideoManager.MaxFileSize)
            {
                throw new MsgException(string.Format(U6008.SIZECANBEUPTO, MiniVideoManager.FileSizeInMB));
            }

            var phyicalFilePath = Path.GetFileName(VideoFileUpload.PostedFile.FileName);
            var extension       = Path.GetExtension(phyicalFilePath);

            if (MiniVideoManager.CheckVideoExtension(extension))
            {
                VideoLabel.Text = phyicalFilePath;
                var    fileName = HashingManager.GenerateMD5(DateTime.Now + phyicalFilePath) + extension;
                string folder   = Server.MapPath("~/Images/uploaded_videos/");
                Directory.CreateDirectory(folder);
                VideoFileUpload.PostedFile.SaveAs(Path.Combine(folder, fileName));
                VideoURLHiddenLabel.Text = "~/Images/uploaded_videos/" + fileName;
            }
            else
            {
                var extensions = "";
                foreach (var ext in MiniVideoManager.FileExtensions)
                {
                    extensions += ext + " ";
                }

                throw new MsgException(string.Format(U6008.WRONGFILEEXTENSION, extensions));
            }
        }
        catch (Exception ex)
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = ex.Message;
        }
    }
예제 #15
0
    public static ApiAccessToken GetOrCreate(int userId)
    {
        var tokens = TableHelper.GetListFromRawQuery <ApiAccessToken>(String.Format(
                                                                          "SELECT * FROM ApiAccessTokens WHERE UserId = {0} AND ExpiresDate >= '{1}'", userId, AppSettings.ServerTime.ToDBString()));

        ApiAccessToken result = null;

        if (tokens.Count > 0)
        {
            result = tokens[0];
        }
        else
        {
            result             = new ApiAccessToken();
            result.UserId      = userId;
            result.ExpiresDate = DateTime.Now.AddDays(7);
            result.Token       = HashingManager.SHA512HMAC(HashingManager.GenerateMD5(userId + DateTime.Now.ToString()),
                                                           HashingManager.SHA256(AppSettings.Offerwalls.UniversalHandlerPassword + userId + DateTime.Now));
            result.Save();
        }

        return(result);
    }
예제 #16
0
        private string buildTransactionRequestString(TransactionRequest request, ref string queryString)
        {
            string transactionID = HashingManager.GenerateMD5(DateTime.Now + request.MemberName + AppSettings.Offerwalls.UniversalHandlerPassword);

            var arrayToHash = new string[] { accountDetails.APIKey, accountDetails.APISecret, "json", accountDetails.LocationId.ToString(), "live" };
            var DataToHash  = String.Join(".", arrayToHash);
            var user        = new Member(request.MemberName);

            string hash = HashingManager.SHA256(DataToHash).ToLower();

            //We need to convert money from our currency to KES
            var moneyToBeSent = CurrencyExchangeHelper.Calculate(request.Payment, "KES");

            queryString = String.Format("format=json&api_key={0}&hash={1}&location_id={2}&mode=live",
                                        accountDetails.APIKey, hash, accountDetails.LocationId.ToString());

            return(new NVPStringBuilder()
                   .Append("format", "json")
                   .Append("api_key", accountDetails.APIKey)
                   .Append("hash", hash)
                   .Append("location_id", accountDetails.LocationId)
                   .Append("mode", "live")
                   .Append("beneficiaries[0][gateway]", "mpesa")
                   .Append("beneficiaries[0][phone]", request.PayeeId)
                   .Append("beneficiaries[0][trans_reference]", transactionID)
                   .Append("beneficiaries[0][description]", request.Note)
                   .Append("beneficiaries[0][first_name]", user.FirstName)
                   .Append("beneficiaries[0][last_name]", user.SecondName)
                   .Append("beneficiaries[0][amount]", moneyToBeSent.ToShortClearString())
                   .Append("beneficiaries[0][callback_url]", AppSettings.Site.Url + "Handlers/Payment/MPesaSapamaX.ashx")
                   .Append("beneficiaries[0][callback_http_method]", "GET")
                   .Append("beneficiaries[0][message]", HttpUtility.UrlEncode(AppSettings.Payments.TransactionNote))
                   .Append("beneficiaries[0][short_code]", accountDetails.Username)
                   .Append("beneficiaries[0][currency]", "KES")
                   .Build());
        }
예제 #17
0
        public override void ProcessRequest()
        {
            try
            {
                string secretKey = HashingManager.GenerateMD5(AppSettings.Offerwalls.UniversalHandlerPassword + "Neteller");

                string documentContents;
                using (Stream receiveStream = context.Request.InputStream)
                {
                    using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
                    {
                        documentContents = readStream.ReadToEnd();
                    }
                }

                JObject obj = JObject.Parse(documentContents);

                //Parse Args
                Status        = obj["eventType"].ToString();
                SentHash      = obj["key"].ToString();
                TransactionID = obj["id"].ToString();
                //Currency
                //Amount
                //Args?
                //CommandName

                Args        = HashingManager.Base64Decode(Args);
                Args        = Args.Substring(Args.IndexOf("**") + 2);
                CommandName = "Prem.PTC.Payments." + Args.Substring(0, Args.IndexOf("#"));
                Args        = Args.Substring(Args.IndexOf("#") + 1);

                //Check IPs
                //Not available in Neteller

                //Check hash
                CheckHash(secretKey, SentHash);

                //Check duplicated transactions
                CheckIfNotDoneYet(TransactionID);

                //Check if we are the merchant
                //Not available in Neteller

                //Check currency
                CheckCurrency(Currency);

                //Check status
                CheckStatus(Status, "order_payment_succeeded");

                //All OK, let's proceed
                Assembly    assembly = Assembly.GetAssembly(typeof(IIpnHandler));
                var         type     = assembly.GetType(CommandName, true, true);
                IIpnHandler command  = Activator.CreateInstance(type) as IIpnHandler;

                command.HandleNeteller(Args, TransactionID, Amount);

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