Exemple #1
0
        private void ShowProcessCardSwipeUI()
        {
            var requestDto = new ProcessCardSwipeRequestDto();

            try
            {
                requestDto.AdditionalProcessCardSwipeRequestData = Read_MultipleKeysInput("AdditionalProcessCardSwipeRequestData");
                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.ProcessCardSwipeInput_CustomerCode = Read_Optional_String_Input("ProcessCardSwipeInput_CustomerCode");
                requestDto.ProcessCardSwipeInput_Username     = Read_Optional_String_Input("ProcessCardSwipeInput_Username");
                requestDto.ProcessCardSwipeInput_Password     = Read_Optional_String_Input("ProcessCardSwipeInput_Password");
                requestDto.BillingLabel = Read_Optional_String_Input("BillingLabel");
                requestDto.ProcessCardSwipeInput_CustomerTransactionID = Read_Optional_String_Input("ProcessCardSwipeInput_CustomerTransactionID");
                requestDto.DeviceSN         = Read_Optional_String_Input("DeviceSN");
                requestDto.IsReturnCardID   = Read_TrueFalse_Input("IsReturnCardID");
                requestDto.KSN              = Read_Mandatory_String_Input("KSN");
                requestDto.MagnePrint       = Read_Mandatory_String_Input("MagnePrint");
                requestDto.MagnePrintStatus = Read_Mandatory_String_Input("MagnePrintStatus");
                requestDto.Track1           = Read_Optional_String_Input("Track1");
                requestDto.Track2           = Read_Mandatory_String_Input("Track2");
                requestDto.Track3           = Read_Optional_String_Input("Track3");
                requestDto.AdditionalEncryptedCardSwipeData = Read_MultipleKeysInput("AdditionalEncryptedCardSwipeData");
                requestDto.Headers = Read_MultipleKeysInput("Headers");
                requestDto.AdditionalPayloadInfoData = Read_MultipleKeysInput("AdditionalPayloadInfoData");
                requestDto.NetworkProtocolType       = Read_NetworkProtocolType_Input("NetworkProtocolType");
                requestDto.Base64ClientCert          = Read_Optional_String_Input("Base64ClientCert");
                requestDto.ClientCertPassword        = Read_Optional_String_Input("ClientCertPassword");
                requestDto.AdditionalHTTPInfoData    = Read_MultipleKeysInput("AdditionalHTTPInfoData");
                requestDto.Payload = Read_LongString_Input("Payload", false);
                requestDto.AccessEngineHeaderHex       = Read_Optional_String_Input("AccessEngineHeaderHex");
                requestDto.AdditionalTCPIPInfoData     = Read_MultipleKeysInput("AdditionalTCPIPInfoData");
                requestDto.NumberOfBytesToAddForLength = 0;
                requestDto.Port = 0;
                if (requestDto.NetworkProtocolType != "HTTP")
                {
                    requestDto.NumberOfBytesToAddForLength = Read_Intuser_Input("NumberOfBytesToAddForLength");
                    requestDto.Port = Read_Intuser_Input("Port");
                }
                requestDto.Uri = Read_Optional_String_Input("Uri");

                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());
            }
        }
Exemple #2
0
        private void ShowProcessCardSwipeUI()
        {
            var requestDto = new ProcessCardSwipeRequestDto();

            try
            {
                requestDto.CustomerCode          = Read_Mandatory_String_Input("CustomerCode");
                requestDto.Username              = Read_Mandatory_String_Input("Username");
                requestDto.Password              = Read_Mandatory_String_Input("PassWord");
                requestDto.Cvv                   = Read_Intuser_Input("Cvv").ToString();
                requestDto.DeviceSN              = Read_Mandatory_String_Input("DeviceSN");
                requestDto.KSN                   = Read_Mandatory_String_Input("KSN");
                requestDto.MagnePrint            = Read_Mandatory_String_Input("MagnePrint");
                requestDto.MagnePrintStatus      = Read_Mandatory_String_Input("MagnePrintStatus");
                requestDto.Track1                = Read_Mandatory_String_Input("Track1");
                requestDto.Track2                = Read_Mandatory_String_Input("Track2");
                requestDto.Track3                = Read_Optional_String_Input("Track3");
                requestDto.CustomerTransactionID = Read_Optional_String_Input("CustomerTransactionID");
                requestDto.Amount                = Read_Decimal_Input("Amount");
                requestDto.ProcessorName         = Read_Mandatory_String_Input("ProcessorName");
                requestDto.Payload               = Read_Mandatory_String_Input("Payload");
                requestDto.TransactionType       = Read_TransactionType_Input("TransactionType");
                var svc    = _serviceProvider.GetService <IProcessCardSwipeClient>();
                var result = svc.ProcessCardSwipe(requestDto);
                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 Occurred while Processing ProcessCardSwipe" + ex.Message.ToString());
            }
        }
Exemple #3
0
        private void ShowProcessCardSwipeUI()
        {
            var requestDto = new ProcessCardSwipeRequestDto();

            try
            {
                requestDto.CustomerCode          = Read_String_Input("Please enter value for CustomerCode", false);
                requestDto.Username              = Read_String_Input("Please enter value for username", false);
                requestDto.Password              = Read_String_Input("Please enter value for password", false);
                requestDto.DeviceSN              = Read_String_Input("Please enter value for DeviceSN", true);
                requestDto.KSN                   = Read_String_Input("Please enter value for KSN", false);
                requestDto.MagnePrint            = Read_String_Input("Please enter value for MagnePrint", false);
                requestDto.MagnePrintStatus      = Read_String_Input("Please enter value for MagnePrintStatus", false);
                requestDto.Track1                = Read_String_Input("Please enter value for Track1", true);
                requestDto.Track2                = Read_String_Input("Please enter value for Track2", false);
                requestDto.Track3                = Read_String_Input("Please Enter value for Track3", true);
                requestDto.CustomerTransactionID = Read_String_Input("Please enter value for CustomerTransactionID", true);
                requestDto.Amount                = Read_Decimal_Input("Please enter value for Amount");
                requestDto.ProcessorName         = Read_String_Input("Please enter value for ProcessorName", false);
                requestDto.TransactionType       = Read_TransactionType_Input("Please enter value for TransactionType");
                var svc         = _serviceProvider.GetService <IProcessCardSwipeClient>();
                var responseDto = svc.ProcessCardSwipe(requestDto);
                if (responseDto != null)
                {
                    var response = responseDto as ProcessCardSwipeResponseDto;
                    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 ProcessCardSwipe" + ex.Message.ToString());
            }
        }
        public ProcessCardSwipeResponseDto ProcessCardSwipe(ProcessCardSwipeRequestDto dto)
        {
            var    response    = new ProcessCardSwipeResponseDto();
            string pageContent = string.Empty;
            string soapAction  = "http://www.magensa.net/MPPGv4/IMPPGv4Service/ProcessCardSwipe";

            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:ProcessCardSwipe>
      <mpp:ProcessCardSwipeRequests>
        <mpp1:ProcessCardSwipeRequest>
          <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:CardSwipeInput>
            <mpp1:EncryptedCardSwipe>
              <mpp1:DeviceSN>{dto.DeviceSN}</mpp1:DeviceSN>
              <mpp1:KSN>{dto.KSN}</mpp1:KSN>
              <mpp1:MagnePrint>{dto.MagnePrint}</mpp1:MagnePrint>
              <mpp1:MagnePrintStatus>{dto.MagnePrintStatus}</mpp1:MagnePrintStatus>
              <mpp1:Track1>{dto.Track1}</mpp1:Track1>
              <mpp1:Track2>{dto.Track2}</mpp1:Track2>
              <mpp1:Track3>{dto.Track3}</mpp1:Track3>
            </mpp1:EncryptedCardSwipe>
          </mpp1:CardSwipeInput>
          <mpp1:CustomerTransactionID>{dto.CustomerTransactionID}</mpp1:CustomerTransactionID>
          <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:ProcessCardSwipeRequest>
      </mpp:ProcessCardSwipeRequests>
    </mpp:ProcessCardSwipe>
  </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);
        }
Exemple #5
0
        public async Task <ProcessCardSwipeResponseDto> ProcessCardSwipe(ProcessCardSwipeRequestDto dto)
        {
            var responseDto = new ProcessCardSwipeResponseDto();

            try
            {
                var soapRequest = new ProcessCardSwipeRequest
                {
                    AdditionalProcessCardSwipeRequestData = dto.AdditionalProcessCardSwipeRequestData.ToArray(),
                    Authentication = new Authentication()
                    {
                        CustomerCode = dto.CustomerCode,
                        Username     = dto.Username,
                        Password     = dto.Password
                    },
                    CustomerTransactionID  = dto.CustomerTransactionID,
                    ProcessCardSwipeInputs = new List <ProcessCardSwipeInput>()
                    {
                        new ProcessCardSwipeInput()
                        {
                            AdditionalRequestData = dto.AdditionalRequestData.ToArray(),
                            Authentication        = new Authentication()
                            {
                                CustomerCode = dto.ProcessCardSwipeInput_CustomerCode,
                                Username     = dto.ProcessCardSwipeInput_Username,
                                Password     = dto.ProcessCardSwipeInput_Password
                            },
                            BillingLabel          = dto.BillingLabel,
                            CustomerTransactionID = dto.ProcessCardSwipeInput_CustomerTransactionID,
                            EncryptedCardSwipe    = new EncryptedCardSwipe()
                            {
                                DeviceSN         = dto.DeviceSN,
                                IsReturnCardID   = bool.Parse(dto.IsReturnCardID),
                                KSN              = dto.KSN,
                                MagnePrint       = dto.MagnePrint,
                                MagnePrintStatus = dto.MagnePrintStatus,
                                Track1           = dto.Track1,
                                Track2           = dto.Track2,
                                Track3           = dto.Track3,
                                AdditionalEncryptedCardSwipeData = dto.AdditionalEncryptedCardSwipeData.ToArray(),
                            },
                            PayloadInfo = new PayloadInfo()
                            {
                                HTTPInfo = new HTTPInfo()
                                {
                                    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.ProcessCardSwipeAsync(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);
        }
 public (ProcessCardSwipeResponseDto Response, RawSoapDetails SoapDetails) ProcessCardSwipe(ProcessCardSwipeRequestDto dto)
 {
     (ProcessCardSwipeResponseDto Response, RawSoapDetails SoapDetails)result = (default, default);