//激活软件按钮 private void button1_Click(object sender, EventArgs e) { this.label3.Text = "正在校验注册码..."; this.button1.Enabled = false; RespMessage respMessage = sr.checkReg(this.textBox2.Text); if (respMessage.code == 1)//激活成功,跳转到mainForm { //隐藏激活页面 this.Hide(); Point activityFormLocation = this.Location; //显示功能页面 mainForm = new MainForm(); //调整页面位置 mainForm.Location = activityFormLocation; mainForm.Text = mainForm.Text + "-版本" + ActivityConst.VERSION; mainForm.Show(); this.button1.Enabled = true; } else { this.label3.Text = "注册码错误!!!"; this.button1.Enabled = true; MessageBox.Show(respMessage.message); } }
private static async Task AssertWrite(string rawMessage, RespMessage message) { var stream = new MemoryStream(); var respWriter = new RespWriter(stream); await respWriter.WriteAsync(message); stream.Position = 0; var streamReader = new StreamReader(stream); var actual = await streamReader.ReadToEndAsync(); Assert.That(actual, Is.EqualTo(rawMessage)); }
protected void btnRefundTransaction_Click(object sender, EventArgs e) { RespMessage rm = p.Refund(AmeriaPaymentFields); ltMessage.Text = "RespMessage:" + rm.Respmessage + "|" + " RespCode:" + rm.Respcode; }
public async Task Should_read_normal_messages(string name, string rawMessage, RespMessage message) { var stream = new MemoryStream(Encoding.GetBytes(rawMessage)); var reader = new RespReader(stream); var actual = await reader.ReadAsync(); Assert.That(actual, Is.EqualTo(message)); }
public async Task Should_write_normal_messages(string name, string rawMessage, RespMessage message) { await AssertWrite(rawMessage, message); var stream = new MemoryStream(); var respWriter = new RespWriter(stream); await respWriter.WriteAsync(message); stream.Position = 0; var streamReader = new StreamReader(stream); var actual = await streamReader.ReadToEndAsync(); Assert.That(actual, Is.EqualTo(rawMessage)); }
private PaymentAuthorizationResponse ParseResponseFromCivicaResponse(RespMessage civicaResponse) { if (null == civicaResponse) { return(new PaymentAuthorizationResponse(true, PaymentAuthorizationResult.ErrorUnknownStatus, 0, "null response", null)); } switch (civicaResponse.ResponseCode) { case "00000": // continue processing break; case "00001": // record not found : either user is still in the GUI or abandonded the process return(new PaymentAuthorizationResponse(true, PaymentAuthorizationResult.Unknown, 0, civicaResponse.ResponseDescription, null)); default: string failureReason = String.Format("Response code = {0}, Description = '{1}'", civicaResponse.ResponseCode, civicaResponse.ResponseDescription); return(new PaymentAuthorizationResponse(true, PaymentAuthorizationResult.ErrorUnknownStatus, 0, failureReason, null)); } bool anyAuthorized = false; bool anyDeclined = false; decimal totalPayed = 0; List <String> receiptNumbers = new List <string>(); if (null != civicaResponse.PaymentList) { foreach (PaymentStructure payStruct in civicaResponse.PaymentList) { // workaround for Issue (SR-985 : civica not returning any value for TrueAccountReference) if (String.IsNullOrEmpty(payStruct.TrueAccountReference)) { payStruct.TrueAccountReference = payStruct.AccountReference; } // according to documentation, additional charges (e.g. card charges on top of the bill) have a different TrueAccountReference if (payStruct.AccountReference == payStruct.TrueAccountReference) { if ("A" == payStruct.RequestStatus) { totalPayed += payStruct.AccountPaymentAmount; if (!String.IsNullOrEmpty(payStruct.IncomeManagementReceiptNumber)) { receiptNumbers.Add(payStruct.IncomeManagementReceiptNumber); } anyAuthorized = true; } else { anyDeclined = true; } } } } string uniqueReceipts = String.Join(", ", receiptNumbers.Distinct().ToArray()); if (anyAuthorized) { if (anyDeclined) { return(new PaymentAuthorizationResponse( true, PaymentAuthorizationResult.ErrorUnknownStatus, totalPayed, "Payment contains both authorized and not-authorized payments", uniqueReceipts)); } else { return(new PaymentAuthorizationResponse( true, PaymentAuthorizationResult.Authorized, totalPayed, "Authorized", uniqueReceipts)); } } else { if (anyDeclined) { return(new PaymentAuthorizationResponse(true, PaymentAuthorizationResult.Declined, totalPayed, "Payment not authorized", uniqueReceipts)); } else { return(new PaymentAuthorizationResponse(true, PaymentAuthorizationResult.ErrorUnknownStatus, 0, "PaymentList is empty", uniqueReceipts)); } } }