public void ProcessRequest(HttpContext context) { try { Logger.Write("New request received"); context.Response.ContentType = "application/xml"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; string ip = context.Request.UserHostAddress; string request = GetRequest(context.Request); Logger.Write("{0}:\n{1}", ip, request); string response = ""; if (string.IsNullOrWhiteSpace(request)) { Logger.Write("Request is null"); response = "Request is empty"; } else { response = new BillingProvider().GetResponse(request, ip); Logger.Write("Response:\n{0}", response); } byte[] responseBytes = System.Text.Encoding.UTF8.GetBytes(response); context.Response.OutputStream.Write(responseBytes, 0, responseBytes.Length); } catch (Exception ex) { Logger.Write("Exception while processing request\n{0}", ex.ToString()); context.Response.Write("500: Internal server error"); } }
public void Should_Resolve_Methods_Implicitly() { var provider = new BillingProvider(new Billing()); var total = P <IBilling>(provider).Bill(7.50M); Assert.AreEqual(9.50M, total); }
public string BuildNThree(BillingProvider billingProvider) { var buildNThree = new StringBuilder(); buildNThree.Append("N3" + "*"); buildNThree.Append(billingProvider.Address.StreetOne + "*"); //N301 Payee Address Line buildNThree.Append(billingProvider.Address.StreetTwo + "*"); //N302 Payee Address Line buildNThree.Append("~"); return(buildNThree.ToString()); }
public string BuildN4(BillingProvider billingProvider) { var buildNFour = new StringBuilder(); buildNFour.Append("N4" + "*"); buildNFour.Append(billingProvider.Address.City + "*"); //N401 Payee City Name buildNFour.Append(billingProvider.Address.State + "*"); //N402 Payee State Name buildNFour.Append(billingProvider.Address.ZipCode); //N403 Payee Payee Postal Zone or Zip Code buildNFour.Append("~"); return(buildNFour.ToString()); }
public HttpResponseMessage Get() { try { var bills = new BillingProvider(DbInfo).RetrieveBills(); return(Request.CreateResponse(HttpStatusCode.OK, bills)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.OK, ex.StackTrace)); } }
/// <summary> /// Initializes a new instance of the <see cref="ReconciliationLineItemCollectionOperations"/> class. /// </summary> /// <param name="rootPartnerOperations">The partner operations.</param> /// <param name="invoiceId">The invoice identifier.</param> /// <param name="billingProvider">The billing provider type.</param> /// <param name="invoiceLineItemType">The invoice line item type.</param> /// <param name="currencyCode">The currency code.</param> /// <param name="period">The period for unbilled recon.</param> /// <param name="size">The page size.</param> public ReconciliationLineItemCollectionOperations(IPartner rootPartnerOperations, string invoiceId, BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType, string currencyCode, BillingPeriod period, int?size = null) : base(rootPartnerOperations, invoiceId) { invoiceId.AssertNotEmpty(nameof(invoiceId)); currencyCode.AssertNotEmpty(nameof(currencyCode)); this.billingProvider = billingProvider; this.currencyCode = currencyCode; this.invoiceLineItemType = invoiceLineItemType; pageSize = size ?? maxPageSizeReconLineItems; this.period = period; }
public void SetDefaultBillingProvider(BillingProvider billingProvider) { Settings.Default.BillingProviderFirstName = billingProvider.FirstName; Settings.Default.BillingProviderLastName = billingProvider.LastName; Settings.Default.BillingProviderNpi = billingProvider.Npi; Settings.Default.BillingProviderName = billingProvider.Name; Settings.Default.BillingProviderAddressLineOne = billingProvider.Address.StreetOne; Settings.Default.BillingProviderAddressLineTwo = billingProvider.Address.StreetTwo; Settings.Default.BillingProviderAddressCity = billingProvider.Address.City; Settings.Default.BillingProviderAddressState = billingProvider.Address.State; Settings.Default.BillingProviderAddressZipCode = billingProvider.Address.ZipCode; Settings.Default.Save(); }
public string BuildNOne(BillingProvider billingProvider) { var buildNOne = new StringBuilder(); buildNOne.Append("N1" + "*"); buildNOne.Append("PE" + "*"); //N101 Payer Identifier Code buildNOne.Append(billingProvider.Name + "*"); //N102 Payee Name buildNOne.Append("XX" + "*"); //N103 Payee Identification Qualifier buildNOne.Append(billingProvider.Npi); //N104 Payee Identification Code buildNOne.Append("~"); return(buildNOne.ToString()); }
// POST: api/Billing public HttpResponseMessage Post(Billing billing) { try { var provider = new BillingProvider(DbInfo); var isSaved = provider.Save(billing); return(Request.CreateResponse(HttpStatusCode.OK, isSaved)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public BillingProvider PullDefaultBillingProvider(BillingProvider billingProvider) { if (!string.IsNullOrEmpty(Settings.Default.BillingProviderFirstName)) { billingProvider.FirstName = Settings.Default.BillingProviderFirstName; } if (Settings.Default.BillingProviderLastName != string.Empty) { billingProvider.LastName = Settings.Default.BillingProviderLastName; } if (Settings.Default.BillingProviderNpi != string.Empty) { billingProvider.Npi = Settings.Default.BillingProviderNpi; } if (Settings.Default.BillingProviderName != string.Empty) { billingProvider.Name = Settings.Default.BillingProviderName; } if (Settings.Default.BillingProviderAddressLineOne != string.Empty) { billingProvider.Address.StreetOne = Settings.Default.BillingProviderAddressLineOne; } if (Settings.Default.BillingProviderAddressLineTwo != string.Empty) { billingProvider.Address.StreetTwo = Settings.Default.BillingProviderAddressLineTwo; } if (Settings.Default.BillingProviderAddressCity != string.Empty) { billingProvider.Address.City = Settings.Default.BillingProviderAddressCity; } if (Settings.Default.BillingProviderAddressState != string.Empty) { billingProvider.Address.State = Settings.Default.BillingProviderAddressState; } if (Settings.Default.BillingProviderAddressZipCode != 0) { billingProvider.Address.ZipCode = Settings.Default.BillingProviderAddressZipCode; } return(billingProvider); }
/// <summary> /// Creates an invoice line item collection operation given a billing provider and invoice line item type. /// </summary> /// <param name="billingProvider">The billing provider.</param> /// <param name="invoiceLineItemType">The invoice line item type.</param> /// <returns>The invoice line item collection operations.</returns> public IInvoiceLineItemCollection By(BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType) => new InvoiceLineItemCollectionOperations(Partner, Context, billingProvider, invoiceLineItemType);
public BillingProviderService(BillingProvider provider) { _provider = provider ?? new BillingProvider(); }
/// <summary> /// Gets the line items for the specified invoice. /// </summary> /// <param name="invoiceId">Identifier for the invoice.</param> /// <param name="billingProvider">The provider of billing information.</param> /// <param name="invoiceLineItemType">Type of invoice line items.</param> /// <returns>A list of line items for the specified invoice.</returns> /// <exception cref="ArgumentException"> /// <paramref name="invoiceId"/> is empty or null. /// </exception> public async Task <List <InvoiceLineItem> > GetInvoiceLineItemsAsync(string invoiceId, BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType) { CustomerPrincipal principal; DateTime startTime; Dictionary <string, double> eventMetrics; Dictionary <string, string> eventProperties; Guid correlationId; IPartner operations; ResourceCollection <InvoiceLineItem> invoiceLineItems; invoiceId.AssertNotEmpty(nameof(invoiceId)); try { startTime = DateTime.Now; correlationId = Guid.NewGuid(); operations = await this.GetUserOperationsAsync(correlationId); principal = (CustomerPrincipal)HttpContext.Current.User; if (!principal.CustomerId.Equals(this.service.Configuration.PartnerCenterApplicationTenantId)) { throw new UnauthorizedAccessException("You are not authorized to perform this operation."); } invoiceLineItems = await operations.Invoices.ById(invoiceId).By(billingProvider, invoiceLineItemType).GetAsync(); // Track the event measurements for analysis. eventMetrics = new Dictionary <string, double> { { "ElapsedMilliseconds", DateTime.Now.Subtract(startTime).TotalMilliseconds }, { "NumberOfInvoiceLineItems", invoiceLineItems.TotalCount } }; // Capture the request for the customer summary for analysis. eventProperties = new Dictionary <string, string> { { "CustomerId", principal.CustomerId }, { "Name", principal.Name }, { "ParternCenterCorrelationId", correlationId.ToString() } }; this.service.Telemetry.TrackEvent("GetInvoiceLineItemsAsync", eventProperties, eventMetrics); return(new List <InvoiceLineItem>(invoiceLineItems.Items)); } finally { eventMetrics = null; eventProperties = null; invoiceLineItems = null; operations = null; principal = null; } }
private void LoadBillingProvider() { BillingProvider = new BillingProvider(); BillingProvider = Settings.PullDefaultBillingProvider(BillingProvider); ProviderStates = BillingProvider.Address.States; }
public void Should_Handle_Methods_Using_Protocol() { var billing = new BillingProvider(new Billing(4M)); Assert.AreEqual(7M, P <IBilling>(billing).Bill(3M)); }
/// <summary> /// Creates an invoice line item collection operations given a billing provider and invoice line item type. /// </summary> /// <param name="provider">The provider type.</param> /// <param name="invoiceLineItemType">The invoice line item.</param> /// <param name="currencyCode">The currency code.</param> /// <param name="period">The period for unbilled recon.</param> /// <param name="size">The page size.</param> /// <returns>The recon line item collection operations.</returns> public IReconciliationLineItemCollection By(BillingProvider provider, InvoiceLineItemType invoiceLineItemType, string currencyCode, BillingPeriod period, int?size = null) => new ReconciliationLineItemCollectionOperations(Partner, Context, provider, invoiceLineItemType, currencyCode, period, size);
/// <summary> /// Initializes a new instance of the <see cref="InvoiceLineItemCollectionOperations" /> class. /// </summary> /// <param name="rootPartnerOperations">The partner operations.</param> /// <param name="invoiceId">The invoice identifier.</param> /// <param name="billingProvider">The provider of billing information,</param> /// <param name="invoiceLineItemType">The type of invoice line item.</param> public InvoiceLineItemCollectionOperations(IPartner rootPartnerOperations, string invoiceId, BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType) : base(rootPartnerOperations, invoiceId) { this.billingProvider = billingProvider; this.invoiceLineItemType = invoiceLineItemType; }