예제 #1
0
        private void ShowDecryptCardSwipeUI()
        {
            DecryptCardSwipeRequestDto decryptRequest = new DecryptCardSwipeRequestDto();

            try
            {
                Console.WriteLine("=====================Request building start======================");
                decryptRequest.BillingLabel          = Read_String_Input("Please enter the BillingLabel:", true);
                decryptRequest.CustomerTransactionID = Read_String_Input("Please enter the CustomerTransactionID:", true);
                decryptRequest.CustomerCode          = Read_String_Input("Please enter the CustomerCode:", false);
                decryptRequest.Username              = Read_String_Input("Please enter the Username:"******"Please enter the Password:"******"Please enter the DeviceSN:", false);
                decryptRequest.KSN                   = Read_String_Input("Please enter the KSN:", false);
                decryptRequest.KeyType               = Read_KeyType_Input("Please enter the KeyType:");
                decryptRequest.MagnePrint            = Read_String_Input("Please enter the MagnePrint:", false);
                decryptRequest.MagnePrintStatus      = Read_String_Input("Please enter the MagnePrintStatus:", false);
                decryptRequest.Track1                = Read_LongString_Input("Please enter the Track1:", false);
                decryptRequest.Track2                = Read_LongString_Input("Please enter the Track2:", false);
                decryptRequest.Track3                = Read_LongString_Input("Please enter the Track3:", true);
                decryptRequest.AdditionalRequestData = Read_MultipleKeysInput("AdditionalRequestData");
                Console.WriteLine("=====================Request building End======================");
                var svc    = _serviceProvider.GetService <IDecryptV3Client>();
                var result = svc.DecryptCardSwipe(decryptRequest).Result;
                if ((result.Response != null) && (result.SoapDetails != null))
                {
                    Console.WriteLine("=====================Response Start======================");
                    Console.WriteLine("Request:");
                    Console.Write(PrettyXml(result.SoapDetails.RequestXml) + "\n");
                    Console.WriteLine("Response:");
                    Console.Write(PrettyXml(result.SoapDetails.ResponseXml) + "\n");
                    Console.WriteLine("=====================Response End======================");
                    Console.WriteLine("=====================Parsed Response Start======================");
                    Console.WriteLine(result.Response.ToString());
                    Console.WriteLine("=====================Parsed Response End======================");
                }
                else
                {
                    Console.WriteLine("Response is null, Please check with input values given and try again");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while Decryptcardswipe : " + ex.Message.ToString());
            }
        }
예제 #2
0
 public async Task <(DecryptCardSwipeResponseDto Response, RawSoapDetails SoapDetails)> DecryptCardSwipe(DecryptCardSwipeRequestDto dto)
 {
     (DecryptCardSwipeResponseDto Response, RawSoapDetails SoapDetails)result = (default, default);
예제 #3
0
        private async void btn_Process_Click(object sender, RoutedEventArgs e)
        {
            DecryptCardSwipeRequestDto decryptRequest = new DecryptCardSwipeRequestDto();

            try
            {
                decryptRequest.BillingLabel          = "";
                decryptRequest.CustomerTransactionID = txt_customerTransactionId.Text;
                decryptRequest.CustomerCode          = txt_Customercode.Text;
                decryptRequest.Password         = txt_Password.Password;
                decryptRequest.Username         = txt_Username.Text;
                decryptRequest.DeviceSN         = txt_DeviceSn.Text;
                decryptRequest.KSN              = txt_KSn.Text;
                decryptRequest.KeyType          = txt_KeyType.Text;
                decryptRequest.MagnePrint       = txt_MagnePrint.Text;
                decryptRequest.MagnePrintStatus = txt_MagnePrintStatus.Text;
                var track1 = txt_Track1.Text;
                decryptRequest.Track1 = track1;
                decryptRequest.Track2 = txt_Track2.Text;
                decryptRequest.Track3 = txt_Track3.Text;
                decryptRequest.AdditionalRequestData = new List <KeyValuePair <string, string> >();
                foreach (var item in _additionalRequestData)
                {
                    var temp = new KeyValuePair <string, string>(item.Key, item.Value);
                    decryptRequest.AdditionalRequestData.Add(temp);
                }

                var validator = new DecryptCardSwipeRequestDtoValidator();
                var results   = validator.Validate(decryptRequest);
                if (!results.IsValid)
                {
                    var errorMsg = string.Empty;
                    var failures = results.Errors.ToList();
                    failures.ForEach(x => errorMsg = errorMsg + x + Environment.NewLine);
                    MessageBox.Show(errorMsg, "Validation Failure");
                }
                else
                {
                    IServiceCollection services = new ServiceCollection();
                    IConfiguration     config   = new ConfigurationBuilder().AddJsonFile("appsettings.json", true, true).Build();
                    services.AddSingleton <IConfiguration>(config);
                    services.AddSingleton <IDecryptV3Client, DecryptV3Client>();
                    if (config.GetValue <string>("CERTIFICATE_FILENAME").Trim() == "")
                    {
                        MessageBox.Show("Certificate FileName Not Found In appsettings.json");
                    }
                    else if (config.GetValue <string>("CERTIFICATE_PASSWORD").Trim() == "")
                    {
                        MessageBox.Show("Certificate Password Not Found In appsettings.json");
                    }
                    else
                    {
                        IServiceProvider serviceProvider = services.BuildServiceProvider();
                        var svc    = serviceProvider.GetService <IDecryptV3Client>();
                        var result = await svc.DecryptCardSwipe(decryptRequest);

                        if ((result.Response != null) && (result.SoapDetails != null))
                        {
                            txt_Response.Text = result.Response.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                txt_Response.Text = "Error while DecryptCardSwipe : " + ex.Message.ToString();
            }
        }