/// <summary>
        /// Submits Invoices to QuickFee
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="client"></param>
        /// <param name="invoices"></param>
        /// <returns></returns>
        public async Task <ProviderResult> SubmitInvoices(ClientDetails client, IEnumerable <InvoiceDetails> invoices)
        {
            try
            {
                var config     = ReadConfig();
                var httpClient = new HttpClient();
                httpClient.BaseAddress = new Uri(config.Url);

                // Login the the API
                var       loginXML    = redPlanetXML.BuildLoginRequest(config);
                XDocument loginResult = await PostToQuickFee(httpClient, loginXML);

                if (!redPlanetXML.IsSuccess(loginResult))
                {
                    return(redPlanetXML.GetError(loginResult));
                }

                // Request a New Quote
                var       session     = redPlanetXML.GetSession(loginResult);
                string    quoteXML    = redPlanetXML.BuildQuoteRequest(session, client, invoices);
                XDocument quoteResult = await PostToQuickFee(httpClient, quoteXML);

                if (!redPlanetXML.IsSuccess(quoteResult))
                {
                    return(redPlanetXML.GetError(quoteResult));
                }

                // Logoff the API
                //var logoffXML = buildLogoffRequest(session);
                //XDocument logoffResult = await PostToQuickFee(httpClient, logoffXML);

                //if (!IsSuccess(logoffResult))
                //    return GetError(logoffResult);

                // Return the Redirect
                return(redPlanetXML.GetRedirect(quoteResult));
            }
            catch (ConfigurationErrorsException cex)
            {
                return(ProviderResult.ErrorResult("CONFIG", cex.Message));
            }
            catch (HttpRequestException hex)
            {
                return(ProviderResult.ErrorResult("HTTP", hex.Message));
            }
            catch (Exception ex)
            {
                return(ProviderResult.ErrorResult("GENERAL", ex.Message));
            }
        }
        /// <summary>
        /// Runs the Receipt Sync
        /// </summary>
        /// <param name="token">Cancellation Token that should be checked whenever possible for Requested Cancellation</param>
        /// <returns></returns>
        public async Task RunAsync(CancellationToken token)
        {
            System.Diagnostics.Trace.TraceInformation("RunAsync Started");

            try
            {
                var httpClient = new HttpClient();
                httpClient.BaseAddress = new Uri(config.Url);

                // Login the the API
                //loggingService.Logger.Information("Logging into QuickFee");
                var       loginXML    = redPlanetXML.BuildLoginRequest(config);
                XDocument loginResult = await PostToQuickFee(httpClient, loginXML, token);

                if (!redPlanetXML.IsSuccess(loginResult))
                {
                    throw new Exception(redPlanetXML.GetError(loginResult).Message);
                }

                // Check Token
                if (token.IsCancellationRequested)
                {
                    return;
                }

                // Request Loan Status Updates
                //loggingService.Logger.Information("Requesting Loan Status");
                var       session            = redPlanetXML.GetSession(loginResult);
                string    quoteXML           = redPlanetXML.BuildLoanStatusRequest(session);
                XDocument loanStatusResponse = await PostToQuickFee(httpClient, quoteXML, token);

                if (!redPlanetXML.IsSuccess(loanStatusResponse))
                {
                    throw new Exception(redPlanetXML.GetError(loanStatusResponse).Message);
                }

                // Send confirmation request
                //loggingService.Logger.Information("Sending Loan Status Confirmation");
                string confirmationXML = redPlanetXML.BuildLoanStatusConfirmationRequest(session);

                XDocument confirmationResponse = await PostToQuickFee(httpClient, confirmationXML, token);

                if (!redPlanetXML.IsSuccess(confirmationResponse))
                {
                    throw new Exception(redPlanetXML.GetError(confirmationResponse).Message);
                }

                // Important Save this file in-case we are interrupted later.
                //loggingService.Logger.Information("Writing Resiliance File");
                //loanStatusResponse.Save(resilianceFile);

                // Check Token
                if (token.IsCancellationRequested)
                {
                    return;
                }

                // Process Loan Status Data
                //loggingService.Logger.Information("Processing Loan Status Data");
                await ProcessLoanStatusData(loanStatusResponse);

                //loggingService.Logger.Information("Processing Receipts Complete");

                System.Diagnostics.Trace.TraceInformation("RunAsync Complete");
            }
            catch (Exception ex)
            {
                //loggingService.Logger.Error(ex.Message);
                Trace.TraceError(ex.Message);
                Debug.WriteLine(ex.Message);
            }
        }