Exemple #1
0
    /// <summary>
    /// Calculating hash and submitting form after the send button is clicked
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSend_Click(object sender, EventArgs e)
    {
        string formScript = "<script language=\"javascript\" type=\"text/javascript\">" +
                            "document.getElementById('{0}').submit();" +
                            "</script>";

        string formName   = "form1";
        string formAction = "https://test.ipg-online.com/connect/gateway/processing";

        //if timezone isn't specified, will get local timezone and put it into textbox in the web form
        if (this.timezone.Text.Equals(String.Empty))
        {
            String[] TimeZoneDispNameSplit = TimeZoneInfo.Local.DisplayName.Split(' ');
            this.timezone.Text = Regex.Replace(TimeZoneDispNameSplit[0], @"[)(]", String.Empty);;
        }

        //if date and time isn't specified, will get actual date and time and put it into textbox in the web form
        if (this.txndatetime.Text.Equals(String.Empty))
        {
            this.txndatetime.Text = DateTime.Now.ToString(@"yyyy\:MM\:dd-HH\:mm\:ss");
        }

        //hash
        var StringToHash = this.storename.Text + this.txndatetime.Text + this.chargetotal.Text + this.currency.Text + this.sharedsecret.Text;

        //calculate hash value and put it into textbox in the web form
        string hash = CalculateHash.calculateHashFromString(new StringBuilder(StringToHash), this.hash_algorithm.Text);

        this.hash.Text = hash;

        ltrForm.Text   = string.Format("<form id=\"{0}\" name=\"{0}\" method=\"post\" action=\"{1}\">", formName, formAction) + AllInputTagsString() + "</form>";
        ltrScript.Text = string.Format(formScript, formName);
    }
    /// <summary>
    /// Calculating extended hash and submitting form after the send button is clicked
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSend_Click(object sender, EventArgs e)
    {
        string formScript = "<script language=\"javascript\" type=\"text/javascript\">" +
                            "document.getElementById('{0}').submit();" +
                            "</script>";

        string formName   = "form1";
        string formAction = "https://test.ipg-online.com/connect/gateway/processing";

        //if timezone isn't specified, will get local timezone and put it into textbox in the web form
        if (this.timezone.Text.Equals(String.Empty))
        {
            String[] TimeZoneDispNameSplit = TimeZoneInfo.Local.DisplayName.Split(' ');
            this.timezone.Text = Regex.Replace(TimeZoneDispNameSplit[0], @"[)(]", String.Empty);;
        }

        //if date and time isn't specified, will get actual date and time and put it into textbox in the web form
        if (this.txndatetime.Text.Equals(String.Empty))
        {
            this.txndatetime.Text = DateTime.Now.ToString(@"yyyy\:MM\:dd-HH\:mm\:ss");
        }

        //get dictionary containing all fields from web form (ID,value)
        var allComponents = GetAllFormComponents();

        //calcualte extended hash from sorted web form fields and update hashExtended value in web form and dictionary
        string hashExtended = CalculateHash.calculateHashFromString(new StringBuilder(StringToHashExtended(allComponents)), this.hash_algorithm.Text);

        this.hashExtended.Text        = hashExtended;
        allComponents["hashExtended"] = hashExtended;

        ltrForm.Text   = string.Format("<form id=\"{0}\" name=\"{0}\" method=\"post\" action=\"{1}\">", formName, formAction) + AllInputTagstring(allComponents) + "</form>";
        ltrScript.Text = string.Format(formScript, formName);
    }