Exemple #1
0
 /// <summary>
 /// Generates an XML representation of operation envelope.
 /// </summary>
 /// <param name="signatureProvider">A signature provider object to calculate signature for operation.</param>
 /// <returns>An XMl representation of operation envelope.</returns>
 public virtual XElement ToOperationEnvelopeXml(SignatureProvider signatureProvider)
 {
     return
         new XElement(OperationEnvelopeNodeName,
             new XElement(OperationXmlNodeName, Convert.ToBase64String(Encoding.ASCII.GetBytes(ToXml().ToString()))),
             new XElement(SignatureNodeName, signatureProvider.GenerateSignature(this.ToXml().ToString()))
         );
 }
		/// <summary>
		/// Creates a new instance of LiqPayClient class
		/// </summary>
		/// <param name="merchantId">
		/// Merchant identifier.
		/// </param>
		/// <param name="sendMoneySign">
		/// Signature for send money operations.
		/// </param>
		/// <param name="otherOperationsSign">
		/// Signature for other operations.
		/// </param>
        public LiqPayClient(string merchantId, string sendMoneySign, string otherOperationsSign)
        {
            this.MerchantId = merchantId;
            this.SendMoneySign = sendMoneySign;
			this.OtherOperationsSign = otherOperationsSign;
            this.SendMoneySignatureProvider = new SignatureProvider(this.SendMoneySign);
			this.OtherOperationsSignatureProvider = new SignatureProvider(this.OtherOperationsSign);
        }
Exemple #3
0
		/// <summary>
		/// Generates html code for click&buy request.
		/// </summary>
		/// <param name="signatureProvider">
		/// Specifies signature provider.
		/// </param>
		/// <param name="submitButtonValue">
		/// The name of submit button.
		/// </param>
		/// <returns>
		/// Html code for click&buy request.
		/// </returns>
        public virtual string ToHtml(SignatureProvider signatureProvider, string submitButtonValue)
        {
            return ToHtml(signatureProvider, null, submitButtonValue);
        }
Exemple #4
0
		/// <summary>
		/// Generates html code for click&buy request.
		/// </summary>
		/// <param name="signatureProvider">
		/// Specifies signature provider.
		/// </param>
		/// <param name="formName">
		/// The name of html form element.
		/// </param>
		/// <param name="submitButtonValue">
		/// The name of submit button.
		/// </param>
		/// <returns>
		/// Html code for click&buy request
		/// </returns>
        public virtual string ToHtml(SignatureProvider signatureProvider, string formName, string submitButtonValue)
        {
            return new XElement(
                "form", new XAttribute("name", string.IsNullOrEmpty(formName) ? DefaultFormName : formName), new XAttribute("action", ApiUrl), new XAttribute("method", "POST"),
                ToOperationHtml(),
                ToSignatureHtml(signatureProvider),
                new XElement("input", new XAttribute("type", "submit"), new XAttribute("value", submitButtonValue))
                ).ToString();
        }
Exemple #5
0
		/// <summary>
		/// Generates html code for hidden field with signature xml
		/// </summary>
		/// <param name="signatureProvider">
		/// SignatureProvider object which will be used by this instance to generate signature.
		/// </param>
		/// <returns>A XElement object.</returns>
        protected XElement ToSignatureHtml(SignatureProvider signatureProvider)
        {
            string signature = signatureProvider.GenerateSignature(ToXml().ToString());
            
            return new XElement(
                "input", 
                new XAttribute("type", "hidden"), 
                new XAttribute("name", "signature"), 
                new XAttribute("value", signature));
        }
		protected virtual void OnGenerateHtmlClicked (object sender, System.EventArgs e)
		{
			if (Validate())
			{
				string merchantId = merchantIdEntry.Text.Trim();
				string pwd = pwdEntry.Text.Trim();
				string resultUrl = resultUrlEntry.Text.Trim();
				string serverUrl = serverUrlEntry.Text.Trim();
				try
				{
					ClickNBuy clicknbuy = new ClickNBuy()
					{
						MerchantId = merchantId,
						ResultUrl = string.IsNullOrEmpty(resultUrl) ? null : new Uri(resultUrl),
						ServerUrl = string.IsNullOrEmpty(serverUrl) ? null : new Uri(serverUrl),
						Amount = double.Parse(amountEntry.Text),
						Currency = currencyComboBox.ActiveText,
						Description = descriptionEntry.Text,
						DefaultPhone = defaultPhoneEntry.Text,
						OrderId = orderIdEntry.Text,
						PayWay = payWayComboBox.ActiveText
					};
					SignatureProvider signatureProvider = new SignatureProvider(pwd);
					generatedHtmlTextView.Buffer.Text = clicknbuy.ToHtml(signatureProvider, "Pay");
					
					UserSettings.SharedSettings.MerchantId = merchantId;
					UserSettings.SharedSettings.OtherPassword = pwd;
					UserSettings.SharedSettings.Save();
				}
				catch (Exception ex)
				{
					DialogHelper.DisplayError((Gtk.Window)this.Toplevel, "Generate html for click&buy operation failed. Error: " + ex.Message);
				}
			}
		}