public ActionResult SendToPaymentProvider(
            PaymentProviderConfiguration configuration,
            GeneralisedPaymentTransfer transferObject,
            Action <PaymentProviderConfiguration, GeneralisedPaymentTransfer, string> saveProviderReference)
        {
            var civicaXfer = new CivicaPaymentTransfer()
            {
                ProviderUrl          = Shared.Civica.Default.CivicaPostUrl,
                ReturnUrl            = transferObject.ReturnUrl,
                CallingApplicationId = Shared.Civica.Default.CivicaAppId,
                CallingApplicationTransactionReference = transferObject.TransactionId,
                GeneralLedgerCode = $"{transferObject.GeneralLedgerCode}-{transferObject.ProductId}",
                //PaymentSourceCode = transferObject.PaymentSourceCode,
                PaymentSourceCode = transferObject.IsMediated ? "02" : "01",
                PaymentTotal      = transferObject.Amount,
                PaymentLines      = new List <string>()
            };

            foreach (var item in transferObject.LineItems)
            {
                civicaXfer.PaymentLines.Add(FormatPaymentLine(item));
            }
            var resultView = PaymentFrameworkUtility.CreateView("~/Views/Payment/SendToCivica.cshtml", civicaXfer);

            var sendToPaymentLogMessage = PaymentFrameworkUtility.DescribeActionResultForLogging(resultView, true);

            this.Logger.CreateEntry(typeof(CivicaPaymentProvider), LogLevel.Info, sendToPaymentLogMessage);
            return(resultView);
        }
        public ActionResult SendToPaymentProvider(
            PaymentProviderConfiguration configuration,
            GeneralisedPaymentTransfer transferObject, DateTime nowLocalTime)
        {
            var realExXfer = new RealExPaymentTransfer()
            {
                MerchantId     = configuration.AccountIdentifer,
                OrderId        = transferObject.TransactionId,
                Amount         = (int)(transferObject.Amount * 100),
                ProviderUrl    = Shared.RealEx.Default.RealExPostUrl,
                ReturnUrl      = transferObject.ReturnUrl,
                Currency       = "GBP",
                Timestamp      = nowLocalTime.ToString("yyyyMMddHHmmss"),
                AutoSettleFlag = true
            };

            realExXfer.Account           = transferObject.Account;
            realExXfer.VariableReference = MessageContentUtility.TruncateAndStripDisallowed(transferObject.VariableReference, 50, RealexFields.RealexFieldVarRefDisallowRegex);
            realExXfer.CustomerNumber    = transferObject.CustomerNumber;
            realExXfer.ProductId         = MessageContentUtility.TruncateAndStripDisallowed(transferObject.ProductId, null, RealexFields.RealexFieldProductIdDisallowRegex);
            realExXfer.Comment1          = MessageContentUtility.TruncateAndStripDisallowed(transferObject.Comment1, 255, RealexFields.RealexFieldCommentDisallowRegex);
            realExXfer.Comment2          = MessageContentUtility.TruncateAndStripDisallowed(transferObject.Comment2, 255, RealexFields.RealexFieldCommentDisallowRegex);

            var fieldsForSignature = new List <string>();

            fieldsForSignature.Add(realExXfer.Timestamp);
            fieldsForSignature.Add(realExXfer.MerchantId);
            fieldsForSignature.Add(realExXfer.OrderId);
            fieldsForSignature.Add(realExXfer.Amount.ToString());
            fieldsForSignature.Add(realExXfer.Currency);

            if (transferObject.SaveCard != null)
            {
                realExXfer.HasSavedCard       = true;
                realExXfer.CardStorageEnabled = true;
                realExXfer.OfferSaveCard      = transferObject.SaveCard.OfferSaveCard;
                realExXfer.PaymentReference   = MessageContentUtility.TruncateAndStripDisallowed(transferObject.SaveCard.PaymentReference, 30, RealexFields.RealexFieldPaymentRefDisallowRegex);
                realExXfer.PayerReference     = MessageContentUtility.TruncateAndStripDisallowed(transferObject.SaveCard.PayerReference, 50, RealexFields.RealexFieldPayerRefDisallowRegex);
                realExXfer.PayerExists        = transferObject.SaveCard.PayerExists;
                fieldsForSignature.Add(realExXfer.PayerReference);
                fieldsForSignature.Add(realExXfer.PaymentReference);
            }

            realExXfer.Sha1Hash = CalculateRealexSignature(fieldsForSignature.ToArray(), configuration.SharedSecret);

            var resultView = PaymentFrameworkUtility.CreateView("~/Views/Payment/SendToRealEx.cshtml", realExXfer);

            var sendToPaymentLogMessage = PaymentFrameworkUtility.DescribeActionResultForLogging(resultView, true);

            this.Logger.CreateEntry(typeof(RealExPaymentProvider), LogLevel.Info, sendToPaymentLogMessage);
            return(resultView);
        }