/// <summary> /// 记录日志 /// </summary> /// <param name="key">消息的key</param> /// <param name="message">消息的正文内容,即model序列化后的内容</param> /// <param name="shardingKey">顺序消息要用的shardingKey,其他消息留空字符串</param> /// <param name="transactionStatus">事务消息的返回类型,其他消息留空字符串</param> /// <param name="failureReason">失败原因,通常有错误时会写入错误原因</param> /// <param name="accomplishment">是否已经完成消息</param> /// <param name="producedTimes">上游执行次数</param> /// <param name="serviceResult">上游执行结果</param> protected void LogData(string key, string message, string shardingKey, string transactionStatus, string failureReason, bool accomplishment, int producedTimes, bool serviceResult) { try { ProducerData producerData = new ProducerData(this.GetRequestTraceId()); producerData.Accomplishment = accomplishment; producerData.ApplicationAlias = _ApplicationAlias; producerData.Topic = this.Topic; producerData.Tag = this.Tag; producerData.ProducerId = this.Pid; producerData.Key = key; producerData.Type = this.MessageType.ToString(); producerData.Message = Base64Util.Decode(message); producerData.TransactionType = ""; producerData.Method = this.GetType().Name; producerData.ServiceResult = serviceResult; producerData.TransactionStatus = transactionStatus; producerData.FailureReason = failureReason; producerData.ProducedTimes = producedTimes; producerData.ShardingKey = shardingKey; producerData.ServerIp = ONSHelper.GetServerIp(); NestDataHelper.WriteData(producerData); } catch (Exception e) { //如果es发送异常,以后可以发送邮件,目前暂时不处理 } }
/// <summary> /// 解密加过密的字符串 /// </summary> /// <param name="input"></param> /// <param name="throwException">解密失败是否抛异常</param> /// <returns></returns> public static string DecryptString(string input, bool throwException) { var res = ""; try { res = input;// Base64.Decrypt(input); if (Md5Util.ValidateValue(res)) { return(Md5Util.RemoveMd5Profix(Base64Util.Decrypt(Md5Util.RemoveMd5Profix(res)))); } else { throw new Exception("字符串无法转换成功!"); } } catch { if (throwException) { throw; } else { return(""); } } }
public object Config() { ViewBag.ConfigModel = SingleInstance <WeChatBLL> .Instance.GetJsApiParamsModel(EnumWeChatType.Client.GetHashCode(), Request.Url.AbsoluteUri); ViewBag.WiFiKey = Base64Util.Base64Encode(ConfigUtil.WiFiKey); return(View()); }
private string encodedSign(byte[] data) { HMACSHA1 hmac = new HMACSHA1(Encoding.UTF8.GetBytes(mac.SecretKey)); byte[] digest = hmac.ComputeHash(data); return(Base64Util.UrlSafeBase64Encode(digest)); }
public static string unsuan(string str, string key) { StringBuilder sb = new StringBuilder(); for (int i = 0, len = str.Length; i < len; i++) { if (i % 2 == 0) { sb.Append(str[i]); } } str = sb.ToString(); str = Base64Util.decode(str); key = key + "ro4w78Jx"; var coder = Encoding.UTF8; byte[] data = coder.GetBytes(str); byte[] keyData = coder.GetBytes(key); int keyIndex = 0; for (int x = 0; x < data.Length; x++) { data[x] = (byte)(data[x] ^ keyData[keyIndex]); if (++keyIndex == keyData.Length) { keyIndex = 0; } } str = coder.GetString(data); return(Base64Util.decode(str)); }
public HostedAdminResponse(string webserviceResponseXml, string originalSecretWord, string expectedMerchantId) { WebserviceResponseXml = webserviceResponseXml; var responseDocument = new XmlDocument(); responseDocument.LoadXml(webserviceResponseXml); MessageBase64Encoded = responseDocument.SelectSingleNode("//message").InnerText; Mac = responseDocument.SelectSingleNode("//mac").InnerText; MerchantId = responseDocument.SelectSingleNode("//merchantid").InnerText; var expectedMac = HashUtil.CreateHash(MessageBase64Encoded + originalSecretWord); if (MerchantId != expectedMerchantId) { throw new System.Exception( string.Format( "The merchantId in the response from the server is not the expected. This could mean that someone has tamepered with the message. Expected:{0} Actual:{1}", expectedMerchantId, MerchantId)); } if (Mac != expectedMac) { throw new System.Exception( string.Format( "SEVERE: The mac from the server does not match the expected mac. The message might have been tampered with, or the secret word used is not correct. Merchant:{0} Message:\n{1}", expectedMerchantId, MessageBase64Encoded)); } Message = Base64Util.DecodeBase64String(MessageBase64Encoded); MessageXmlDocument = new XmlDocument(); MessageXmlDocument.LoadXml(Message); }
public void TestPayPagePaymentWithSetPaymentMethodSveaCardPayPF() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(Item.IndividualCustomer() .SetNationalIdNumber(TestingTool.DefaultTestIndividualNationalIdNumber)) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .SetCustomerReference(TestingTool.DefaultTestCustomerReferenceNumber) .UsePaymentMethod(PaymentMethod.SVEACARDPAY_PF) .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); const string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<!--Message generated by Integration package C#--><payment><paymentmethod>SVEACARDPAY_PF</paymentmethod><customerrefno>33</customerrefno><currency>SEK</currency><amount>12500</amount><vat>2500</vat><lang>en</lang><returnurl>http://myurl.se</returnurl><iscompany>false</iscompany><customer><unknowncustomer>true</unknowncustomer><country>SE</country></customer><orderrows><row><sku>1</sku><name>Prod</name><description>Specification</description><amount>12500</amount><vat>2500</vat><quantity>2</quantity><unit>st</unit></row><row><sku>1</sku><name>Relative</name><description>RelativeDiscount</description><amount>-12500</amount><vat>-2500</vat><quantity>1</quantity><unit>st</unit></row></orderrows><excludepaymentMethods /><addinvoicefee>false</addinvoicefee></payment>"; Assert.That(xml, Is.EqualTo(expectedXml)); string base64Payment = form.GetXmlMessageBase64(); string html = Base64Util.DecodeBase64String(base64Payment); Assert.That(html.Contains("<paymentmethod>SVEACARDPAY_PF</paymentmethod>"), Is.True); }
public void Base64UrlDecode_WorksSpecialChars() { var bytes = new byte[] { 0x04, 0x9f, 0x9c, 0xff, 0x3f, 0x0a }; // normal base64: BJ+c/z8K Assert.AreEqual(bytes, Base64Util.UrlDecode("BJ-c_z8K")); }
private ElemeRetTokenModel GetTokenByRefreshToken(StringBuilder parms, int tryNum) { //请求接口地址 ElemeRetTokenModel token = null; var header = Base64Util.Base64Encode(string.Format("{0}:{1}", ConfigUtil.EleAppKey, ConfigUtil.EleAppSecret), Encoding.UTF8); var responseText = HttpRequestUtil.HttpPost(ElemeConsts.GET_ACCESS_TOKEN_API, parms.ToString(), false, header); if (!string.IsNullOrWhiteSpace(responseText)) { token = JsonUtil.ToObject <ElemeRetTokenModel>(responseText); if (token == null) { LogUtil.Error(string.Format("通过RefreshToken获取AccessToken返回错误信息:{0},请求参数:{1}", responseText, parms.ToJson())); } else { //令牌提前半天过期(12h) token.expires_in = token.expires_in - (12 * 60 * 60); LogUtil.Info(string.Format("尝试通过RefreshToken:{0}获取AccessToken:{1}", parms.ToString(), token.ToJson())); } } else { LogUtil.Error(string.Format("通过RefreshToken获取AccessToken失败,返回信息为空,请求参数:{0}", parms.ToJson())); } return(token); }
/// <summary> /// 上游生产者的实现rocketmq的核心方法,其中会由rocketmq自动间接调用AbstractProducerService实例的InternalProduce方法 /// </summary> /// <param name="model">接收的参数</param> /// <returns>事务执行结果</returns> public bool Process(T model) { if (_AliyunOnsIsAllowedToSend != "1") { return(false); } string requestTraceId = ""; string key = this.CreateMessageKey(); string failureReason = ""; string body = ""; bool accomplishment = false; int producedTimes = 0; int errorTimes = 0; try { //获取requestTraceId requestTraceId = this.GetRequestTraceId(); //此方法中,只要是普通消息或顺序消息都是空实现,直接返回true InternalProcess(model); //序列化实体,即消息正文 body = model.GetType().Name.ToLower() == "system.string" ? model.ToString() : JsonConvert.SerializeObject(model); //防止中文乱码 body = Base64Util.Encode(body); //获取生产者 IONSProducer producer = GetProducer(); //生成消息实体 Message message = new Message(this.Topic, this.Tag, body); message.setKey(key); message.putUserProperties("type", this.MessageType.ToString()); message.putUserProperties("requestTraceId", requestTraceId); //message.putUserProperties("shardingKey", shardingKey); //定义消息结果对象 SendResultONS sendResultONS = null; //尝试发送 sendResultONS = TryToSend(producer, message, null, key, errorTimes); //判断结果,一般走不到这步,因为如果发送有问题会直接抛出异常的 if (sendResultONS == null) { throw new Exception("发送BASE消息失败。key=" + key); } //更新发送状态 accomplishment = true; //更新消费次数 producedTimes = 1; } catch (Exception e) { //将内部捕捉的错误赋值给failureReason,然后由ProduceData的FailureReason属性统一处理 failureReason = "发送BASE消息,key=" + key + ",捕捉异常:" + e.ToString(); return(false); } finally { //无论是否有异常都统一写入生产日志 LogData(key, body, "", "", failureReason, accomplishment, producedTimes, failureReason != "" ? false : true); } return(true); }
/// <summary> /// 生成并返回jwt token /// </summary> /// <returns></returns> public string CreateToken() { string header = Base64Util.Base64Encode(JsonUtil.SerializeObject(Header)); string payload = Base64Util.Base64Encode(JsonUtil.SerializeObject(Payload)); string signature = SHA256.Encrypt(SHA256.Encrypt(header + "." + payload) + secret); return(header + "." + payload + "." + signature); }
public void TestRoundtrip() { const string message = "Secure that disk!"; var trip = Base64Util.Utf8Base64ToString(Base64Util.StringToUtf8Base64(message)); Assert.That(trip, Is.EqualTo(message)); }
public static String HmacSha1(String value, String key) { byte[] keyBytes = Encoding.UTF8.GetBytes(key); var mac = new System.Security.Cryptography.HMACSHA1(keyBytes); byte[] rawHmac = mac.ComputeHash(Encoding.UTF8.GetBytes(value)); return(Base64Util.Base64(rawHmac)); }
public void ConvertTest() { const string STR_DECODED = "hello world"; const string STR_ENCODED = "aGVsbG8gd29ybGQ="; Assert.Equal(STR_ENCODED, Base64Util.Encode(STR_DECODED)); Assert.Equal(STR_DECODED, Base64Util.Decode(STR_ENCODED)); }
public string DeleteJob(string JOB_ID, string JOB_NAME) { WebClientEx wc = new WebClientEx(36000); return(wc.DownloadString(new Uri(@"http://127.0.0.1:9500/Job/DeleteJobRequest/" + Base64Util.Base64Encode(JOB_ID) + "/" + Base64Util.Base64Encode(JOB_NAME)))); }
public static string CreateToken(string accesskey, string secretKey, Dictionary <string, object> param) { var json = string.Format("{{{0}}}", string.Join(",", param.Select(i => string.Format("\"{0}\":{1}", i.Key, i.Value is string?string.Format("\"{0}\"", i.Value) : i.Value)))); var base64param = Base64Util.Base64(json); var sign = HmacUtil.HmacSha1(base64param, secretKey); var token = accesskey + ":" + sign + ":" + base64param; return(token); }
public LightPage(DeviceViewModel deviceViewModel) { InitializeComponent(); _deviceViewModel = deviceViewModel; _deviceViewModel.Name = _settings.AppSettings.Base64 && Base64Util.IsBase64(_deviceViewModel.Name) ? Base64Util.Base64Decode(_deviceViewModel.Name) : _deviceViewModel.Name; Text = _deviceViewModel.ToString(); LightBulbIndicator.State = _deviceViewModel.IsOn == "on" ? UILightState.On : UILightState.Off; }
private void SaveImg() { img.Img = (Bitmap)pictureBox1.Image; img.Base64 = Base64Util.GetBase64FromImage(img.Img); if (!checkBox1.Checked) { img.FileName = User.GetFileName; } File.WriteAllText($"{dirName}/{img.FileName}.ini", img.ToJson()); }
private void btnBase64_Click(object sender, EventArgs e) { string original = "这是一个测试的Base64加密字符串"; string encrypt = Base64Util.Encrypt(original); Console.WriteLine(encrypt);//输出内容:6L*Z5pi_5LiA5Liq5rWL6K*V55qEQmFzZTY05Yqg5b*G5b2X56ym5Liy string decrypt = Base64Util.Decrypt(encrypt); Debug.Assert(original == decrypt);//验证相等 }
/// <summary> /// 根据token获取PayLoad /// </summary> /// <param name="jwtToken"></param> /// <returns></returns> public static Payload GetTokenPayLoad(string jwtToken) { if (!VerifyToken(jwtToken)) { throw new ServiceException("非法的Token!"); } string payload = Base64Util.Base64Decode(jwtToken.Split('.')[1]); return(JsonUtil.DeserializeToObject <Payload>(payload)); }
public void ValidateTest() { const string STR_1 = "aGVsbG8gd29ybGQ="; const string STR_2 = "aGVsbG8gd29ybGQ"; const string STR_3 = "aGVsbG8gd29ybGQ."; const string STR_4 = "aGVsbG8gd29ybG=Q"; Assert.True(Base64Util.TryDecode(STR_1, out _)); Assert.False(Base64Util.TryDecode(STR_2, out _)); Assert.False(Base64Util.TryDecode(STR_3, out _)); Assert.False(Base64Util.TryDecode(STR_4, out _)); }
public PaymentResponse(string messageBase64, string mac, string merchantId) { Mac = mac; MessageBase64 = messageBase64; MerchantId = merchantId; Message = Base64Util.DecodeBase64String(messageBase64); MessageXmlDoc = new XmlDocument(); MessageXmlDoc.LoadXml(Message); TransactionId = long.Parse(MessageXmlDoc.SelectSingleNode("//transaction").Attributes["id"].Value); }
private void SetValues(string xmlBase64) { Xml = Base64Util.DecodeBase64String(xmlBase64); var d1 = new XmlDocument(); d1.LoadXml(Xml); foreach (XmlElement element in d1.GetElementsByTagName("response")) { StatusCode = int.Parse(GetTagValue(element, "statuscode")); // MacValidation should be reworked in a new major release, MacValidation should be mandatory if (StatusCode == 0 && MacValidation == 2 || StatusCode == 150 && MacValidation == 2) { OrderAccepted = false; ErrorMessage = "Mac validation failed."; } else if (StatusCode == 0 && MacValidation <= 1 || StatusCode == 150 && MacValidation <= 1) { switch (StatusCode) { case 0: ResultCode = "0 (ORDER_ACCEPTED)"; break; case 150: ResultCode = "150 (CREDIT_PENDING)"; break; } OrderAccepted = true; } else { OrderAccepted = false; SetErrorParams(StatusCode); } TransactionId = GetTagAttribute(element, "transaction", "id"); PaymentMethod = GetTagValue(element, "paymentmethod"); MerchantId = GetTagValue(element, "merchantid"); ClientOrderNumber = GetTagValue(element, "customerrefno"); Amount = int.Parse(GetTagValue(element, "amount")) * 0.01; Currency = GetTagValue(element, "currency"); SubscriptionId = GetTagValue(element, "subscriptionid"); SubscriptionType = GetTagValue(element, "subscriptiontype"); CardType = GetTagValue(element, "cardtype"); MaskedCardNumber = GetTagValue(element, "maskedcardno"); ExpiryMonth = GetTagValue(element, "expirymonth"); ExpiryYear = GetTagValue(element, "expiryyear"); AuthCode = GetTagValue(element, "authcode"); } }
public HostedAdminRequest(string message, string secretWord, string merchantId, string endPointBase) { EndPointBase = endPointBase; Message = message; SecretWord = secretWord; MerchantId = merchantId; MessageBase64Encoded = Base64Util.EncodeBase64String(Message); Mac = HashUtil.CreateHash(MessageBase64Encoded + secretWord); MessageXmlDocument = new XmlDocument(); MessageXmlDocument.LoadXml(message); }
/// <summary> /// 生成任务调度 /// </summary> /// <param name="JOB_ID">任务唯一主键(TJ-121322842348234235)</param> /// <param name="JOB_NAME">任务名称(示例;药品调价)</param> /// <param name="START_TIME">开始时间(示例:2018-12-12 16:29:51)</param> /// <param name="PRIORITY">优先级(1-10)</param> /// <param name="MoKuaiMc">模块名称(示例:HIS-YKF-PanCun)</param> /// <param name="YeWuMc">业务名称(示例:YKPanCun)</param> /// <param name="CaoZuoMc">操作名称(示例:GetTiJiaoPCD)</param> /// <param name="CanShu">参数(示例:{ "panCunDID":"1" })</param> /// <returns>返回值为【ok】代表正常,其他代表异常</returns> public string GenerateJob(string JOB_ID, string JOB_NAME, string MoKuaiMc, string YeWuMc, string CaoZuoMc, DateTime START_TIME, string CanShu = "{ }", int PRIORITY = 5) { WebClientEx wc = new WebClientEx(36000); return(wc.DownloadString(new Uri(@"http://127.0.0.1:9500/Job/GenerateJob/" + Base64Util.Base64Encode(JOB_ID) + "/" + Base64Util.Base64Encode(JOB_NAME) + "/" + START_TIME.ToInvariantString("yyyy-MM-dd HH:mm:ss") + "/" + PRIORITY.ToString() + "/" + MoKuaiMc + "/" + YeWuMc + "/" + CaoZuoMc + "/" + Base64Util.Base64Encode(CanShu)))); }
private static string GenerateToken() { StringBuilder tokenBuilder = new StringBuilder(); long tokenid = SnowFlake_Net.GenerateSnowFlakeID(); tokenBuilder.Append(tokenid.ToString("x")); tokenBuilder.Append("@"); tokenBuilder.Append(RandomTool.CreatRandomString(16)); tokenBuilder.Append("@"); tokenBuilder.Append(DateTime.Now); var token = Base64Util.ToBase64String(tokenBuilder.ToString()); return(token); }
static void Main(string[] args) { // Base 64 testing Console.WriteLine("Start: Base 64 testing -------------------------------"); var inputString = "JkAT4OA3u9uJIe52ek7BobwBO:DzrxdQpIrSK7uBqsU1wHqXWBszymAq3LrFoqmtSjDI2MFzyj28"; var outputString1 = Base64Util.Base64Encode(inputString); Console.WriteLine("Encoded string: " + outputString1); Console.WriteLine("End: Base 64 testing -------------------------------"); // Time stamp testing Console.WriteLine("Start: Time stamp testing -------------------------------"); Console.WriteLine(); Console.WriteLine("Time stamp : " + DateTimeUtil.GenerateTimeStamp()); Console.WriteLine("End: Time stamp testing-------------------------------"); }
public void TestPayPagePaymentWithSetPaymentMethodNl() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(Item.IndividualCustomer() .SetInitials("SB") .SetBirthDate("19460509") .SetName("Sneider", "Boasman") .SetStreetAddress("Gate", "42") .SetLocality("BARENDRECHT") .SetZipCode("1102 HG")) .SetCountryCode(CountryCode.NL) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCustomerReference(TestingTool.DefaultTestCustomerReferenceNumber) .SetOrderDate(TestingTool.DefaultTestDate) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePaymentMethod(PaymentMethod.INVOICE) .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string xml = form.GetXmlMessage(); const string expectedXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<!--Message generated by Integration package C#-->" + "<payment><paymentmethod>INVOICE</paymentmethod><customerrefno>33</customerrefno>" + "<currency>SEK</currency><amount>12500</amount><vat>2500</vat>" + "<lang>en</lang><returnurl>http://myurl.se</returnurl><iscompany>false</iscompany>" + "<customer><ssn>19460509</ssn><firstname>Sneider</firstname><lastname>Boasman</lastname>" + "<initials>SB</initials><address>Gate</address><housenumber>42</housenumber>" + "<zip>1102 HG</zip><city>BARENDRECHT</city><country>NL</country></customer>" + "<orderrows><row><sku>1</sku><name>Prod</name><description>Specification</description>" + "<amount>12500</amount><vat>2500</vat><quantity>2</quantity><unit>st</unit></row>" + "<row><sku>1</sku><name>Relative</name><description>RelativeDiscount</description>" + "<amount>-12500</amount><vat>-2500</vat><quantity>1</quantity><unit>st</unit></row>" + "</orderrows><excludepaymentMethods /><addinvoicefee>false</addinvoicefee></payment>"; Assert.That(xml, Is.EqualTo(expectedXml)); string base64Payment = form.GetXmlMessageBase64(); string html = Base64Util.DecodeBase64String(base64Payment); Assert.That(html.Contains("<paymentmethod>INVOICE</paymentmethod>"), Is.True); }
public void TestSetHtmlFields() { string base64Payment = Base64Util.EncodeBase64String("0"); string mac = HashUtil.CreateHash(base64Payment + SecretWord); PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .SetCountryCode(TestingTool.DefaultTestCountryCode) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .AddOrderRow(TestingTool.CreateMiniOrderRow()) .AddCustomerDetails(TestingTool.CreateCompanyCustomer()) .UsePayPageDirectBankOnly() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); form.SetMessageBase64(base64Payment) .SetMerchantId(MerchantId) .SetSecretWord(SecretWord) .SetHtmlFields(); var formHtmlFields = form.GetFormHtmlFields(); string url = form.GetPayPageUrl(); Assert.That(formHtmlFields["form_start_tag"], Is.EqualTo("<form name=\"paymentForm\" id=\"paymentForm\" method=\"post\" action=\"" + url + "\">")); Assert.That(formHtmlFields["input_merchantId"], Is.EqualTo("<input type=\"hidden\" name=\"merchantid\" value=\"" + MerchantId + "\" />")); Assert.That(formHtmlFields["input_message"], Is.EqualTo("<input type=\"hidden\" name=\"message\" value=\"" + base64Payment + "\" />")); Assert.That(formHtmlFields["input_mac"], Is.EqualTo("<input type=\"hidden\" name=\"mac\" value=\"" + mac + "\" />")); Assert.That(formHtmlFields["noscript_p_tag"], Is.EqualTo("<noscript><p>Javascript är inaktiverat i er webbläsare, ni får dirigera om till paypage manuellt</p></noscript>")); Assert.That(formHtmlFields["input_submit"], Is.EqualTo("<input type=\"submit\" name=\"submit\" value=\"Betala\" />")); Assert.That(formHtmlFields["form_end_tag"], Is.EqualTo("</form>")); }
public void TestBuildDirectBankPaymentNotSe() { PaymentForm form = WebpayConnection.CreateOrder(SveaConfig.GetDefaultConfig()) .AddOrderRow(TestingTool.CreateExVatBasedOrderRow()) .AddFee(TestingTool.CreateExVatBasedShippingFee()) .AddFee(TestingTool.CreateExVatBasedInvoiceFee()) .AddDiscount(TestingTool.CreateRelativeDiscount()) .AddCustomerDetails(TestingTool.CreateMiniCompanyCustomer()) .SetCountryCode(CountryCode.DE) .SetOrderDate(TestingTool.DefaultTestDate) .SetClientOrderNumber(TestingTool.DefaultTestClientOrderNumber) .SetCurrency(TestingTool.DefaultTestCurrency) .UsePayPageDirectBankOnly() .SetReturnUrl("http://myurl.se") .GetPaymentForm(); string base64Payment = form.GetXmlMessageBase64(); string html = Base64Util.DecodeBase64String(base64Payment); Assert.That(html.Contains("<amount>18750</amount>"), Is.True); }