//private void ShowProcessCardSwipeUI1() //{ // var requestDto = new ProcessCardSwipeRequestDto(); // try // { // requestDto.AdditionalProcessCardSwipeRequestData = new List<KeyValuePair<string, string>>() // { // }; // requestDto.CustomerCode = "VV73029843"; // requestDto.Username = "******"; // requestDto.Password = "******"; // requestDto.CustomerTransactionID = ""; // requestDto.AdditionalRequestData = new List<KeyValuePair<string, string>>() // { // new KeyValuePair<string, string>("EncryptionType","81") , // new KeyValuePair<string, string>("TokenDataFormat","5A$Iif($IsEqualStrings($Substring({CCNum},0,2),34),08{CCNum}F,$Iif($IsEqualStrings($Substring({CCNum},0,2),37),08{CCNum}F,08{CCNum}))5F2402{YY}{MM}"), // new KeyValuePair<string, string>("TokenValidUntilUTC","12/12/2025") // }; // requestDto.ProcessCardSwipeInput_CustomerCode = "VV73029843"; // requestDto.ProcessCardSwipeInput_Username = "******"; // requestDto.ProcessCardSwipeInput_Password = "******"; // requestDto.BillingLabel = "BillingLabel"; // requestDto.ProcessCardSwipeInput_CustomerTransactionID = "CustomerTransactionID"; // requestDto.DeviceSN = "B00CC5B"; // requestDto.IsReturnCardID = "true"; // requestDto.KSN = "9011400B00CC5B0011A1"; // requestDto.MagnePrint = "12C458E3EE877AC87975E805E857EE00CB780FD477EEACCC1F49E56117C3D16215CFF1397CA954A63DA2B35CEDD06C66E2F59381AEAA8025"; // requestDto.MagnePrintStatus = "2098705"; // requestDto.Track1 = "9E76622E68086DBD810C91FA754CA2DD4DF56EBB60C459FE44BAB35A4A1F1DD1087BC967DE4E0071AE8D23DE0A2F20DC3B691A1835EB5CFB038B6C4888C2BD94002FFAA2F9ECC6B5"; // requestDto.Track2 = "C74580955B180F94EE66B8A14BB9287B4F28D139A96BC7423071899FB6B93EA7"; // requestDto.Track3 = ""; // requestDto.AdditionalEncryptedCardSwipeData = new List<KeyValuePair<string, string>>() // { // }; // requestDto.Headers = new List<KeyValuePair<string, string>>() // { // new KeyValuePair<string, string>("Content-Type","text/xml; charset=utf-8") // }; // requestDto.AdditionalPayloadInfoData = new List<KeyValuePair<string, string>>() // { // }; // requestDto.NetworkProtocolType = "HTTP"; // requestDto.Base64ClientCert = ""; // requestDto.ClientCertPassword = ""; // requestDto.AdditionalHTTPInfoData = new List<KeyValuePair<string, string>>() // { // }; // requestDto.Payload = File.ReadAllText(@"C:\Users\spottumuttu\Desktop\payload.txt"); // requestDto.AccessEngineHeaderHex = ""; // requestDto.AdditionalTCPIPInfoData = new List<KeyValuePair<string, string>>() // { // }; // requestDto.NumberOfBytesToAddForLength = 0; // requestDto.Port = 0; // if (requestDto.NetworkProtocolType != "HTTP") // { // requestDto.NumberOfBytesToAddForLength = Read_Intuser_Input("NumberOfBytesToAddForLength"); // requestDto.Port = Read_Intuser_Input("Port"); // } // requestDto.Uri = @"https://stg.dw.us.fdcnet.biz/rc"; // var svc = _serviceProvider.GetService<IProcessCardSwipeClient>(); // var responseDto = svc.ProcessCardSwipe(requestDto).Result; // Console.WriteLine("=====================Response Start======================"); // Console.WriteLine("Response:"); // Console.Write(PrettyXml(responseDto.Content) + "\n"); // Console.WriteLine("=====================Response End======================"); // } // catch (Exception ex) // { // Console.WriteLine("Error Occurred while Processing ProcessCardSwipe" + ex.Message.ToString()); // } //} private void ShowProcessDataUI() { var requestDto = new ProcessDataRequestDto(); try { requestDto.AdditionalProcessDataRequestData = Read_MultipleKeysInput("AdditionalProcessDataRequestData"); requestDto.CustomerCode = Read_Mandatory_String_Input("CustomerCode"); requestDto.Username = Read_Mandatory_String_Input("Username"); requestDto.Password = Read_Mandatory_String_Input("Password"); requestDto.CustomerTransactionID = Read_Optional_String_Input("CustomerTransactionID"); requestDto.AdditionalRequestData = Read_MultipleKeysInput("AdditionalRequestData"); requestDto.ProcessDataInput_CustomerCode = Read_Optional_String_Input("ProcessDataInput_CustomerCode"); requestDto.ProcessDataInput__Username = Read_Optional_String_Input("ProcessDataInput__Username"); requestDto.ProcessDataInput_Password = Read_Optional_String_Input("ProcessDataInput_Password"); requestDto.BillingLabel = Read_Optional_String_Input("BillingLabel"); requestDto.ProcessDataInput_CustomerTransactionID = Read_Optional_String_Input("ProcessDataInput_CustomerTransactionID"); requestDto.Data = Read_LongString_Input("Data", false); requestDto.DataFormatType = Read_DataFormatType_Input("DataFormatType"); requestDto.EncryptionType = Read_EncryptionType_Input("EncryptionType"); requestDto.KSN = Read_Mandatory_String_Input("KSN"); requestDto.NumberOfPaddedBytes = Read_Intuser_Input("NumberOfPaddedBytes"); requestDto.IsEncrypted = Read_TrueFalse_Input("IsEncrypted"); requestDto.OutputPanLast4Format = Read_Optional_String_Input("OutputPanLast4Format"); requestDto.AdditionalPayloadInfoData = Read_MultipleKeysInput("AdditionalPayloadInfoData"); requestDto.Base64ClientCert = Read_Optional_String_Input("Base64ClientCert"); requestDto.ClientCertPassword = Read_Optional_String_Input("ClientCertPassword"); requestDto.AdditionalHTTPInfoData = Read_MultipleKeysInput("AdditionalHTTPInfoData"); requestDto.Headers = Read_MultipleKeysInput("Headers"); requestDto.NetworkProtocolType = Read_NetworkProtocolType_Input("NetworkProtocolType"); requestDto.Payload = Read_LongString_Input("Payload", false); requestDto.AccessEngineHeaderHex = Read_Optional_String_Input("AccessEngineHeaderHex"); requestDto.AdditionalTCPIPInfoData = Read_MultipleKeysInput("AdditionalTCPIPInfoData"); if (requestDto.NetworkProtocolType != "HTTP") { requestDto.NumberOfBytesToAddForLength = Read_Intuser_Input("NumberOfBytesToAddForLength"); requestDto.Port = Read_Intuser_Input("Port"); } requestDto.Uri = Read_Mandatory_String_Input("Uri"); var svc = _serviceProvider.GetService <IProcessDataClient>(); var responseDto = svc.ProcessData(requestDto).Result; Console.WriteLine("=====================Response Start======================"); Console.WriteLine("Response:"); Console.Write(PrettyXml(responseDto.Content) + "\n"); Console.WriteLine("=====================Response End======================"); } catch (Exception ex) { Console.WriteLine("Error Occurred while Processing ProcessData" + ex.Message.ToString()); } }
private void ShowProcessDataUI() { var requestDto = new ProcessDataRequestDto(); try { requestDto.CustomerCode = Read_String_Input("Enter Customer Code:", false); requestDto.Username = Read_String_Input("Enter Username:"******"Enter PassWord:"******"Enter CustomerTransactionId:", true); requestDto.Data = Read_LongString_Input("Enter Data:", false); requestDto.DataFormatType = Read_DataFormatType_Input("Enter DataFormatType:"); requestDto.EncryptionType = Read_String_Input("Enter EncryptionType :", false); requestDto.KSN = Read_String_Input("Enter KSN:", false); requestDto.NumberOfPaddedBytes = Read_Intuser_Input("Enter NumberOfPaddedBytes:"); requestDto.IsEncrypted = Read_Isencrypted_Input("Enter IsEncrypted:"); requestDto.PaymentMode = Read_PaymentMode_Input("Enter PaymentMode:"); requestDto.Amount = Read_Intuser_Input("Enter Amount:"); requestDto.ProcessorName = Read_String_Input("Enter ProcessorName:", false); requestDto.TransactionType = Read_TransactionType_Input("Enter transactionType:"); var svc = _serviceProvider.GetService <IProcessDataClient>(); var responseDto = svc.ProcessData(requestDto); if (responseDto != null) { var response = responseDto as ProcessDataResponseDto; Console.WriteLine("=====================Response Start======================"); Console.WriteLine("Status Code:" + response.StatusCode); Console.WriteLine("Response:"); Console.Write(PrettyXml(response.PageContent) + "\n"); Console.WriteLine("=====================Response End======================"); } else { Console.WriteLine("Response is null, Please check with input values given and try again"); } } catch (Exception ex) { Console.WriteLine("Error Occurred while Processing ProcessData" + ex.Message.ToString()); } }
public async Task <ProcessDataResponseDto> ProcessData(ProcessDataRequestDto dto) { var responseDto = new ProcessDataResponseDto(); try { var soapRequest = new ProcessDataRequest { AdditionalProcessDataRequestData = dto.AdditionalProcessDataRequestData.ToArray(), Authentication = new Authentication() { CustomerCode = dto.CustomerCode, Username = dto.Username, Password = dto.Password }, CustomerTransactionID = dto.CustomerTransactionID, ProcessDataInputs = new List <ProcessDataInput>() { new ProcessDataInput() { AdditionalRequestData = dto.AdditionalRequestData.ToArray(), Authentication = new Authentication() { CustomerCode = dto.ProcessDataInput_CustomerCode, Username = dto.ProcessDataInput__Username, Password = dto.ProcessDataInput_Password }, BillingLabel = dto.BillingLabel, CustomerTransactionID = dto.ProcessDataInput_CustomerTransactionID, DataInput = new DataInput() { Data = dto.Data, DataFormatType = (dto.DataFormatType.Trim().ToUpper() == "TLV")?FormatType.TLV:FormatType.NONE, EncryptionInfo = new EncryptionInfo() { EncryptionType = dto.EncryptionType, KSN = dto.KSN, NumberOfPaddedBytes = dto.NumberOfPaddedBytes }, IsEncrypted = true, OutputPanLast4Format = dto.OutputPanLast4Format }, PayloadInfo = new PayloadInfo() { AdditionalPayloadInfoData = dto.AdditionalPayloadInfoData.ToArray(), Base64ClientCert = dto.Base64ClientCert, ClientCertPassword = dto.ClientCertPassword, HTTPInfo = new HTTPInfo() { AdditionalHTTPInfoData = dto.AdditionalHTTPInfoData.ToArray(), Headers = dto.Headers.ToArray() }, NetworkProtocolType = (dto.NetworkProtocolType.Trim().ToUpper() == "HTTP")? NetworkProtocolType.HTTP:NetworkProtocolType.TCPIP, Payload = dto.Payload, TCPIPInfo = new TCPIPInfo() { AccessEngineHeaderHex = Encoding.ASCII.GetBytes(dto.AccessEngineHeaderHex), AdditionalTCPIPInfoData = dto.AdditionalTCPIPInfoData.ToArray(), NumberOfBytesToAddForLength = dto.NumberOfBytesToAddForLength, Port = dto.Port }, Uri = dto.Uri } } }.ToArray() }; var svcEndPointAddress = new EndpointAddress(ServiceUrl); var svcEndPointConfig = DecryptAndForwardClient.EndpointConfiguration.BasicHttpBinding_IDecryptAndForward; var svcClient = new DecryptAndForwardClient(svcEndPointConfig, svcEndPointAddress); var requestInterceptor = new DafV4InspectorBehavior(); svcClient.Endpoint.EndpointBehaviors.Add(requestInterceptor); _ = await svcClient.ProcessDataAsync(soapRequest); _ = requestInterceptor.LastRequestXML; string responseXML = requestInterceptor.LastResponseXML; responseDto.Content = responseXML; } catch (Exception ex) when(ex is CommunicationException || ex is ProtocolException || ex is FaultException || ex is Exception) { throw ex; } return(responseDto); }
/// <summary> /// ProcessDataResponseDto process the input request and returns the response /// </summary> /// <param name="processDataRequestDto"></param> /// <returns></returns> public ProcessDataResponseDto ProcessData(ProcessDataRequestDto dto) { var response = new ProcessDataResponseDto(); string pageContent = string.Empty; string soapAction = "http://www.magensa.net/MPPGv4/IMPPGv4Service/ProcessData"; try { string soapBody = $@"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:mpp=""http://www.magensa.net/MPPGv4/"" xmlns:mpp1=""http://schemas.datacontract.org/2004/07/MPPGv4WS.Core"" xmlns:sys=""http://schemas.datacontract.org/2004/07/System.Collections.Generic""> <soapenv:Header/> <soapenv:Body> <mpp:ProcessData> <mpp:ProcessDataRequests> <mpp1:ProcessDataRequest> <mpp1:AdditionalRequestData> <sys:KeyValuePairOfstringstring> <sys:key/> <sys:value/> </sys:KeyValuePairOfstringstring> </mpp1:AdditionalRequestData> <mpp1:Authentication> <mpp1:CustomerCode>{dto.CustomerCode}</mpp1:CustomerCode> <mpp1:Password>{dto.Password}</mpp1:Password> <mpp1:Username>{dto.Username}</mpp1:Username> </mpp1:Authentication> <mpp1:CustomerTransactionID>{dto.CustomerTransactionID}</mpp1:CustomerTransactionID> <mpp1:DataInput> <mpp1:Data>{dto.Data}</mpp1:Data> <mpp1:DataFormatType>{dto.DataFormatType}</mpp1:DataFormatType> <mpp1:EncryptionInfo> <mpp1:EncryptionType>{dto.EncryptionType}</mpp1:EncryptionType> <mpp1:KSN>{dto.KSN}</mpp1:KSN> <mpp1:NumberOfPaddedBytes>{dto.NumberOfPaddedBytes}</mpp1:NumberOfPaddedBytes> </mpp1:EncryptionInfo> <mpp1:IsEncrypted>{dto.IsEncrypted}</mpp1:IsEncrypted> <mpp1:PaymentMode>{dto.PaymentMode}</mpp1:PaymentMode> </mpp1:DataInput> <mpp1:TransactionInput> <mpp1:Amount>{dto.Amount}</mpp1:Amount> <mpp1:ProcessorName>{dto.ProcessorName}</mpp1:ProcessorName> <mpp1:TransactionInputDetails> <sys:KeyValuePairOfstringstring> <sys:key/> <sys:value/> </sys:KeyValuePairOfstringstring> </mpp1:TransactionInputDetails> <mpp1:TransactionType>{dto.TransactionType}</mpp1:TransactionType> </mpp1:TransactionInput> </mpp1:ProcessDataRequest> </mpp:ProcessDataRequests> </mpp:ProcessData> </soapenv:Body> </soapenv:Envelope>"; MagensaSOAPClient soapClient = new MagensaSOAPClient(host: Host, certificateFileName: CertificateFileName, certificatePassword: CertificatePassword); HttpWebResponse webResponse = soapClient.CallWebService(soapAction, soapBody); Stream responseStream = webResponse.GetResponseStream(); using (StreamReader sr = new StreamReader(responseStream)) { response.StatusCode = (int)webResponse.StatusCode; response.PageContent = sr.ReadToEnd(); } responseStream.Close(); webResponse.Close(); } catch (WebException ex) { HttpStatusCode sCode = ((HttpWebResponse)ex.Response).StatusCode; response.StatusCode = (int)sCode; response.PageContent = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd(); } catch (Exception ex) { response.StatusCode = null; response.PageContent = ex.Message; } return(response); }