public PaymentConfiguration CreateInstance(PaymentCredentials paymentCredentials, PaymentInterface paymentInterface, PaymentProvider paymentProvider, BehaviorModel behaviorModel)
 {
     if (!this.HasData)
     {
         return(null);
     }
     return(new PaymentConfiguration(this.PaymentConfigurationID, paymentCredentials ?? new PaymentCredentials(this.PaymentCredentialsID), paymentInterface ?? new PaymentInterface(this.PaymentInterfaceID), paymentProvider ?? new PaymentProvider(this.PaymentProviderID), behaviorModel ?? new BehaviorModel(this.BehaviorModelID), this.Name, this.Updated, this.Created));
 }
Esempio n. 2
0
        public HttpStatusCode UpdateRecurrentAffiliation(Guid recurrentId, MerchantAuthentication merchantAuthentication, PaymentCredentials affiliation)
        {
            var restRequest = new RestRequest(@"RecurrentPayment/{recurrentId}/Affiliation", Method.PUT)
            {
                RequestFormat = DataFormat.Json
            };

            AddHeaders(restRequest, merchantAuthentication);

            restRequest.AddUrlSegment("recurrentId", recurrentId.ToString());

            restRequest.AddJsonBody(affiliation);

            var response = RestClient.Execute <HttpStatusCode>(restRequest);

            return(response.StatusCode);
        }
Esempio n. 3
0
        protected override PaymentConfiguration LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             PaymentConfigurationTable.GetColumnNames("[pc]") +
                             (this.Depth > 0 ? "," + PaymentCredentialsTable.GetColumnNames("[pc_pc]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentInterfaceTable.GetColumnNames("[pc_pi]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentProviderTable.GetColumnNames("[pc_pp]") : string.Empty) +
                             (this.Depth > 0 ? "," + BehaviorModelTable.GetColumnNames("[pc_bm]") : string.Empty) +
                             " FROM [core].[PaymentConfiguration] AS [pc] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentCredentials] AS [pc_pc] ON [pc].[PaymentCredentialsID] = [pc_pc].[PaymentCredentialsID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentInterface] AS [pc_pi] ON [pc].[PaymentInterfaceID] = [pc_pi].[PaymentInterfaceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentProvider] AS [pc_pp] ON [pc].[PaymentProviderID] = [pc_pp].[PaymentProviderID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[BehaviorModel] AS [pc_bm] ON [pc].[BehaviorModelID] = [pc_bm].[BehaviorModelID] ";
                }
                sqlCmdText += "WHERE [pc].[PaymentConfigurationID] = @PaymentConfigurationID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@PaymentConfigurationID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "loadinternal", "notfound"), "PaymentConfiguration could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                PaymentConfigurationTable pcTable    = new PaymentConfigurationTable(query);
                PaymentCredentialsTable   pc_pcTable = (this.Depth > 0) ? new PaymentCredentialsTable(query) : null;
                PaymentInterfaceTable     pc_piTable = (this.Depth > 0) ? new PaymentInterfaceTable(query) : null;
                PaymentProviderTable      pc_ppTable = (this.Depth > 0) ? new PaymentProviderTable(query) : null;
                BehaviorModelTable        pc_bmTable = (this.Depth > 0) ? new BehaviorModelTable(query) : null;


                PaymentCredentials   pc_pcObject = (this.Depth > 0) ? pc_pcTable.CreateInstance() : null;
                PaymentInterface     pc_piObject = (this.Depth > 0) ? pc_piTable.CreateInstance() : null;
                PaymentProvider      pc_ppObject = (this.Depth > 0) ? pc_ppTable.CreateInstance() : null;
                BehaviorModel        pc_bmObject = (this.Depth > 0) ? pc_bmTable.CreateInstance() : null;
                PaymentConfiguration pcObject    = pcTable.CreateInstance(pc_pcObject, pc_piObject, pc_ppObject, pc_bmObject);
                sqlReader.Close();

                return(pcObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "loadinternal", "exception"), "PaymentConfiguration could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "PaymentConfiguration", "Exception while loading PaymentConfiguration object from database. See inner exception for details.", ex);
            }
        }
Esempio n. 4
0
        public List <PaymentConfiguration> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             PaymentConfigurationTable.GetColumnNames("[pc]") +
                             (this.Depth > 0 ? "," + PaymentCredentialsTable.GetColumnNames("[pc_pc]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentInterfaceTable.GetColumnNames("[pc_pi]") : string.Empty) +
                             (this.Depth > 0 ? "," + PaymentProviderTable.GetColumnNames("[pc_pp]") : string.Empty) +
                             (this.Depth > 0 ? "," + BehaviorModelTable.GetColumnNames("[pc_bm]") : string.Empty) +
                             " FROM [core].[PaymentConfiguration] AS [pc] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentCredentials] AS [pc_pc] ON [pc].[PaymentCredentialsID] = [pc_pc].[PaymentCredentialsID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentInterface] AS [pc_pi] ON [pc].[PaymentInterfaceID] = [pc_pi].[PaymentInterfaceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[PaymentProvider] AS [pc_pp] ON [pc].[PaymentProviderID] = [pc_pp].[PaymentProviderID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[BehaviorModel] AS [pc_bm] ON [pc].[BehaviorModelID] = [pc_bm].[BehaviorModelID] ";
                }


                sqlCmdText = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "customloadmany", "notfound"), "PaymentConfiguration list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(new List <PaymentConfiguration>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                PaymentConfigurationTable pcTable    = new PaymentConfigurationTable(query);
                PaymentCredentialsTable   pc_pcTable = (this.Depth > 0) ? new PaymentCredentialsTable(query) : null;
                PaymentInterfaceTable     pc_piTable = (this.Depth > 0) ? new PaymentInterfaceTable(query) : null;
                PaymentProviderTable      pc_ppTable = (this.Depth > 0) ? new PaymentProviderTable(query) : null;
                BehaviorModelTable        pc_bmTable = (this.Depth > 0) ? new BehaviorModelTable(query) : null;

                List <PaymentConfiguration> result = new List <PaymentConfiguration>();
                do
                {
                    PaymentCredentials   pc_pcObject = (this.Depth > 0) ? pc_pcTable.CreateInstance() : null;
                    PaymentInterface     pc_piObject = (this.Depth > 0) ? pc_piTable.CreateInstance() : null;
                    PaymentProvider      pc_ppObject = (this.Depth > 0) ? pc_ppTable.CreateInstance() : null;
                    BehaviorModel        pc_bmObject = (this.Depth > 0) ? pc_bmTable.CreateInstance() : null;
                    PaymentConfiguration pcObject    = (this.Depth > -1) ? pcTable.CreateInstance(pc_pcObject, pc_piObject, pc_ppObject, pc_bmObject) : null;
                    result.Add(pcObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("pc", "customloadmany", "exception"), "PaymentConfiguration list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "PaymentConfiguration", "Exception while loading (custom/many) PaymentConfiguration object from database. See inner exception for details.", ex);
            }
        }