public string GetConfigEntry(string entryName, bool isRequired)
        {
            string entry = string.Empty;

            try
            {
                entry = _configEntries[entryName];
                if (string.IsNullOrEmpty(entry) && isRequired)
                {
                    throw new ApplicationException(string.Format(ErrorConfigEntryFoundButHadNoData, entryName));
                }
            }
            catch (Exception ex)
            {
                if (isRequired)
                {
                    string error = string.Format(ErrorMissingGateWayExternalConfigInfo, Thread.CurrentThread.CurrentCulture.Name, entryName, ex.Message);
                    PaymentGatewayInvoker.LogBlindError(error);
                    //LoggerHelper.Error(error, LoggingSource);
                    LoggerHelper.Error(error); //write to eventlog anyway.
                    throw;
                }
            }

            return(entry);
        }
示例#2
0
 protected void LogJsonWarningSerialization(string paymentGateway, string jsondata)
 {
     PaymentGatewayInvoker.LogBlindError(
         paymentGateway,
         string.Format(
             "JsonWarningSerialization: Json Serialization fail  :\r\nPosted:{0}\r\nQueryString: {1}\r\nJson: {2}",
             this.GetFormData(),
             HttpContext.Current.Request.QueryString, jsondata));
 }
示例#3
0
 protected void LogJsonWarning(string paymentGateway)
 {
     PaymentGatewayInvoker.LogBlindError(
         paymentGateway,
         string.Format(
             "JsonWarning: Json Posted data are null :\r\nPosted:{0}\r\nQueryString: {1}",
             this.GetFormData(),
             HttpContext.Current.Request.QueryString));
 }
示例#4
0
 protected void LogSecurityWarning(string paymentGateway)
 {
     PaymentGatewayInvoker.LogBlindError(paymentGateway, string.Format("Securtity Warning: Posted data did not match querystring:\r\nPosted:{0}\r\nQueryString: {1}", GetFormData(), HttpContext.Current.Request.QueryString));
 }
示例#5
0
        public static PaymentGatewayResponse Create(bool logTheResponse)
        {
            PaymentGatewayResponse response = null;

            if (HLConfigManager.Configurations.PaymentsConfiguration.HasPaymentGateway)
            {
                var handlers = GetPaymentGatewayResponseList();

                foreach (PaymentGatewayResponse handler in handlers)
                {
                    if (handler.CanProcess)
                    {
                        response = handler;
                        response.CanSubmitIfApproved = response.DetermineSubmitStatus();
                        if (handler.LogResponses(logTheResponse))
                        {
                            if (string.IsNullOrEmpty(response.errorMessage))
                            {
                                if (response.AuthResultMissing)
                                {
                                    response.errorMessage = string.Format(NoAuthResultInResponse, response.GatewayName);
                                }
                            }
                            if (string.IsNullOrEmpty(response.OrderNumber))
                            {
                                response.errorMessage = string.Format(NoOrderNumberInResponse, response.GatewayName);
                            }
                            string message = (!string.IsNullOrEmpty(response.errorMessage)) ? string.Format(ResponseHadError, response.errorMessage) : string.Empty;
                            if (!string.IsNullOrEmpty(response.errorMessage))
                            {
                                PaymentGatewayInvoker.LogBlindError(message);
                            }
                            else
                            {
                                var statusType = PaymentGatewayRecordStatusType.Unknown;
                                if (response.IsReturning)
                                {
                                    statusType = response.Status;
                                    if (statusType != PaymentGatewayRecordStatusType.OrderSubmitted)
                                    {
                                        statusType = (response.IsApproved) ? PaymentGatewayRecordStatusType.Approved : PaymentGatewayRecordStatusType.Declined;
                                        statusType = (response.IsPendingTransaction) ? PaymentGatewayRecordStatusType.ApprovalPending : statusType;
                                        statusType = (response.IsCancelled) ? PaymentGatewayRecordStatusType.CancelledByUser : statusType;
                                    }
                                }
                                else
                                {
                                    statusType = (response.IsApproved) ? PaymentGatewayRecordStatusType.Approved : PaymentGatewayRecordStatusType.Declined;
                                    statusType = (response.IsPendingTransaction) ? PaymentGatewayRecordStatusType.ApprovalPending : statusType;
                                    statusType = (response.IsCancelled) ? PaymentGatewayRecordStatusType.CancelledByUser : statusType;
                                    statusType = (response.Status == PaymentGatewayRecordStatusType.OrderSubmitted) ? response.Status : statusType;
                                }
                                PaymentGatewayInvoker.LogMessageWithInfo(PaymentGatewayLogEntryType.Response, response.OrderNumber, string.Empty, response.GetType().Name.Replace("Response", string.Empty), statusType, response.WebResponse);
                            }
                        }
                    }
                }
            }

            return(response);
        }