public void SetAuthResponseProperties(VisitableNameValueCollection responseParameters, IPizzaConfiguration bankConfiguration, IPizzaAuthResponse bankAuthResponse) { List <BankMessageField> messageFields = bankAuthResponse.PostParameters.ToList(); _basicMessageFieldFinder.MapResponseParamsToMessageFields(responseParameters, messageFields); VerifyResponseMac(bankConfiguration, messageFields); bankAuthResponse.IdCode = _basicMessageFieldFinder.FindOrDefault("VK_USER_ID", messageFields); bankAuthResponse.User = _basicMessageFieldFinder.FindOrDefault("VK_USER", messageFields); bankAuthResponse.Nonce = _basicMessageFieldFinder.FindOrDefault("VK_NONCE", messageFields); bankAuthResponse.UserName = _basicMessageFieldFinder.FindOrDefault("VK_USER_NAME", messageFields); bankAuthResponse.Country = _basicMessageFieldFinder.FindOrDefault("VK_COUNTRY", messageFields); bankAuthResponse.Language = _basicMessageFieldFinder.FindOrDefault("VK_LANG", messageFields); bankAuthResponse.Other = _basicMessageFieldFinder.FindOrDefault("VK_OTHER", messageFields); // ReSharper disable once PossibleInvalidOperationException // Request datetime always exists for auth responses DateTime requestGeneratedAt = _basicMessageFieldFinder.FindOrDefaultDateTime("VK_DATETIME", bankConfiguration.DateTimeFormat, messageFields).Value; bankAuthResponse.RequestDateTime = requestGeneratedAt; bankAuthResponse.IsRequestDateTimeValid = IsRequestDateTimeValid(requestGeneratedAt, _timeProvider.Now); bankAuthResponse.RequestEncoding = _basicMessageFieldFinder.FindOrDefault("VK_ENCODING", messageFields); bankAuthResponse.RequestId = _basicMessageFieldFinder.FindOrDefault("VK_RID", messageFields); bankAuthResponse.Token = _basicMessageFieldFinder.FindOrDefault("VK_TOKEN", messageFields); }
public void SetPaymentResponseProperties(VisitableNameValueCollection responseParameters, IPizzaConfiguration bankConfiguration, IPizzaPaymentResponse bankPaymentResponse) { List <BankMessageField> messageFields = bankPaymentResponse.PostParameters.ToList(); _basicMessageFieldFinder.MapResponseParamsToMessageFields(responseParameters, messageFields); VerifyResponseMac(bankConfiguration, messageFields); bankPaymentResponse.IsAutomaticResponse = _basicMessageFieldFinder.FindOrDefault("VK_AUTO", messageFields) == "Y"; bankPaymentResponse.Amount = _basicMessageFieldFinder.FindOrDefaultDecimal("VK_AMOUNT", bankConfiguration.DecimalFormat, messageFields); bankPaymentResponse.RequestStartDateTime = _basicMessageFieldFinder.FindOrDefaultDateTime("VK_T_DATETIME", bankConfiguration.DateTimeFormat, messageFields); string serviceCode = _basicMessageFieldFinder.FindOrDefault("VK_SERVICE", messageFields); bankPaymentResponse.IsPaymentSuccessful = serviceCode == "1111"; bankPaymentResponse.Stamp = _basicMessageFieldFinder.FindOrDefault("VK_STAMP", messageFields); bankPaymentResponse.Currency = _basicMessageFieldFinder.FindOrDefault("VK_CURR", messageFields); bankPaymentResponse.Language = _basicMessageFieldFinder.FindOrDefault("VK_LANG", messageFields); bankPaymentResponse.PaymentMessage = _basicMessageFieldFinder.FindOrDefault("VK_MSG", messageFields); bankPaymentResponse.PaymentOrderNumber = _basicMessageFieldFinder.FindOrDefault("VK_T_NO", messageFields); bankPaymentResponse.PaymentOrderReferenceNumber = _basicMessageFieldFinder.FindOrDefault("VK_REF", messageFields); bankPaymentResponse.PaymentReceiverAccount = _basicMessageFieldFinder.FindOrDefault("VK_REC_ACC", messageFields); bankPaymentResponse.PaymentReceiverName = _basicMessageFieldFinder.FindOrDefault("VK_REC_NAME", messageFields); bankPaymentResponse.PaymentSenderAccount = _basicMessageFieldFinder.FindOrDefault("VK_SND_ACC", messageFields); bankPaymentResponse.PaymentSenderName = _basicMessageFieldFinder.FindOrDefault("VK_SND_NAME", messageFields); bankPaymentResponse.RequestEncoding = _basicMessageFieldFinder.FindOrDefault("VK_ENCODING", messageFields); }
public void MapResponseParamsToMessageFields(VisitableNameValueCollection visitable, IEnumerable <BankMessageField> bankMessagefields) { foreach (BankMessageField bankMessageField in bankMessagefields) { bankMessageField.Value = visitable[bankMessageField.FieldName]; } }
public void SetPaymentResponseProperties(VisitableNameValueCollection responseParameters, EstcardConfiguration bankConfiguration, EstcardPaymentResponse bankPaymentResponse) { List <BankMessageField> postParameters = bankPaymentResponse.PostParameters.ToList(); _basicMessageFieldFinder.MapResponseParamsToMessageFields(responseParameters, postParameters); VerifyResponseMac(bankConfiguration, postParameters); bankPaymentResponse.AmountInCents = _basicMessageFieldFinder.FindOrDefaultLong("eamount", postParameters).Value; bankPaymentResponse.Currency = _basicMessageFieldFinder.FindOrDefault("cur", postParameters); bankPaymentResponse.MsgData = _basicMessageFieldFinder.FindOrDefault("msgdata", postParameters); bankPaymentResponse.ActionText = _basicMessageFieldFinder.FindOrDefault("actiontext", postParameters); bankPaymentResponse.ReceiptNr = _basicMessageFieldFinder.FindOrDefaultInt("receipt_no", postParameters).Value; // TODO: configurable datetime format string transactionDateTimeString = _basicMessageFieldFinder.FindOrDefault("datetime", postParameters); bankPaymentResponse.TransactionDateTime = DateTime.ParseExact(transactionDateTimeString, "yyyyMMddHHmmss", CultureInfo.InvariantCulture); bankPaymentResponse.TransactionNr = _basicMessageFieldFinder.FindOrDefaultLong("ecuno", postParameters).Value; string respCode = _basicMessageFieldFinder.FindOrDefault("respcode", postParameters); bankPaymentResponse.RespCode = respCode; bankPaymentResponse.IsPaymentSuccessful = respCode == "000"; }
public void SetUp() { _macCalculatorMock = new Mock <IMacCalculator>(); _macCalculatorMock.Setup(macCalc => macCalc.VerifyMac(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IEnumerable <BankMessageField> >())) .Returns(true); var macCalculatorFactoryMock = new Mock <MacCalculatorFactory>(); macCalculatorFactoryMock .Setup(factory => factory.CreateCalculator(It.IsAny <string>(), It.IsAny <IPkiBankConfiguration>())) .Returns(_macCalculatorMock.Object); _timeProviderMock = new Mock <TimeProvider>(); _messageMapper = new IPizzaMessageMapper(new BasicMessageFieldFinder(), macCalculatorFactoryMock.Object, _timeProviderMock.Object); _testData = new VisitableNameValueCollection { { "VK_DATETIME", string.Empty }, }; _authResponse = new IPizzaAuthResponse(string.Empty, new List <BankMessageField> { new BankMessageField { FieldName = "VK_DATETIME", MaxLength = int.MaxValue, } }); _ipizzaConfiguration = new IPizzaConfiguration(); }