public ActionResult AddToBasket(AddToBasket model) { // Disable VAT in initial lookup so we don't double tax var merchello = new MerchelloHelper(false); // we want to include VAT Basket.EnableDataModifiers = true; var product = merchello.Query.Product.GetByKey(model.ProductKey); if (model.OptionChoice != Guid.Empty) { var extendedData = new ExtendedDataCollection(); var variant = product.GetProductVariantDisplayWithAttributes(new[] { model.OptionChoice }); //// serialize the attributes here as they are need in the design extendedData.SetValue(Constants.ExtendedDataKeys.BasketItemAttributes, JsonConvert.SerializeObject(variant.Attributes)); Basket.AddItem(variant, variant.Name, 1, extendedData); } else { Basket.AddItem(product, product.Name, 1); } Basket.Save(); if (Request.IsAjaxRequest()) { // this would be the partial for the pop window return Content("Form submitted"); } return RedirectToUmbracoPage(ContentResolver.Instance.GetBasketContent()); }
/// <summary> /// Initializes a new instance of the <see cref="AvaTaxTaxationGatewayMethod"/> class. /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <param name="extendedData"> /// The extended Data collection from the provider. /// </param> public AvaTaxTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData) : base(taxMethod) { _settings = extendedData.GetAvaTaxProviderSettings(); _avaTaxService = new AvaTaxService(_settings); }
/// <summary> /// Calculates tax for invoice. /// </summary> /// <param name="invoice"> /// The invoice. /// </param> /// <param name="taxAddress"> /// The tax address. /// </param> /// <returns> /// The <see cref="ITaxCalculationResult"/>. /// </returns> public override ITaxCalculationResult CalculateTaxForInvoice(IInvoice invoice, IAddress taxAddress) { decimal amount = 0m; foreach (var item in invoice.Items) { // can I use?: https://github.com/Merchello/Merchello/blob/5706b8c9466f7417c41fdd29de7930b3e8c4dd2d/src/Merchello.Core/Models/ExtendedDataExtensions.cs#L287-L295 if (item.ExtendedData.GetTaxableValue()) amount = amount + item.TotalPrice; } TaxRequest taxRequest = new TaxRequest(); taxRequest.Amount = amount; taxRequest.Shipping = invoice.TotalShipping(); taxRequest.ToCity = taxAddress.Locality; taxRequest.ToCountry = taxAddress.CountryCode; taxRequest.ToState = taxAddress.Region; taxRequest.ToZip = taxAddress.PostalCode; Models.TaxResult taxResult = _taxjarService.GetTax(taxRequest); if (taxResult.Success) { var extendedData = new ExtendedDataCollection(); extendedData.SetValue(Core.Constants.ExtendedDataKeys.TaxTransactionResults, JsonConvert.SerializeObject(taxResult)); return new TaxCalculationResult(TaxMethod.Name, taxResult.Rate, taxResult.TotalTax, extendedData); } throw new Exception("TaxJar.com error"); }
public SmtpNotificationGatewayMethod(IGatewayProviderService gatewayProviderService, INotificationMethod notificationMethod, ExtendedDataCollection extendedData) : base(gatewayProviderService, notificationMethod) { Mandate.ParameterNotNull(extendedData, "extendedData"); _settings = extendedData.GetSmtpProviderSettings(); }
public ActionResult AddToBasket(AddItemModel model) { // This is an example of using the ExtendedDataCollection to add some custom functionality. // In this case, we are creating a direct reference to the content (Product Detail Page) so // that we can provide a link, thumbnail and description in the cart per this design. In other // designs, there may not be thumbnails or descriptions and the link could be to a completely // different website. var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); var product = Services.ProductService.GetByKey(model.ProductKey); // In the event the product has options we want to add the "variant" to the basket. // -- If a product that has variants is defined, the FIRST variant will be added to the cart. // -- This was done so that we did not have to throw an error since the Master variant is no // -- longer valid for sale. if (model.OptionChoices != null && model.OptionChoices.Any()) { var variant = Services.ProductVariantService.GetProductVariantWithAttributes(product, model.OptionChoices); Basket.AddItem(variant, variant.Name, 1, extendedData); } else { Basket.AddItem(product, product.Name, 1, extendedData); } Basket.Save(); return RedirectToUmbracoPage(GetContentIdByContentName(BasketPage)); }
/// <summary> /// Initializes a new instance of the <see cref="TaxJarTaxationGatewayMethod"/> class. /// </summary> /// <param name="taxMethod"> /// The tax method. /// </param> /// <param name="extendedData"> /// The extended Data collection from the provider. /// </param> public TaxJarTaxationGatewayMethod(ITaxMethod taxMethod, ExtendedDataCollection extendedData) : base(taxMethod) { _settings = extendedData.GetTaxJarProviderSettings(); _taxjarService = new TaxJarTaxService(_settings); }
/// <summary> /// Computes the invoice tax result /// </summary> /// <returns> /// The <see cref="ITaxCalculationResult"/> /// </returns> public override Attempt<ITaxCalculationResult> CalculateTaxesForInvoice() { var extendedData = new ExtendedDataCollection(); try { var baseTaxRate = _taxMethod.PercentageTaxRate; extendedData.SetValue(Core.Constants.ExtendedDataKeys.BaseTaxRate, baseTaxRate.ToString(CultureInfo.InvariantCulture)); if (_taxMethod.HasProvinces) { baseTaxRate = AdjustedRate(baseTaxRate, _taxMethod.Provinces.FirstOrDefault(x => x.Code == TaxAddress.Region), extendedData); } var visitor = new TaxableLineItemVisitor(baseTaxRate / 100); Invoice.Items.Accept(visitor); var totalTax = visitor.TaxableLineItems.Sum(x => decimal.Parse(x.ExtendedData.GetValue(Core.Constants.ExtendedDataKeys.LineItemTaxAmount))); return Attempt<ITaxCalculationResult>.Succeed( new TaxCalculationResult(_taxMethod.Name, baseTaxRate, totalTax, extendedData)); } catch (Exception ex) { return Attempt<ITaxCalculationResult>.Fail(ex); } }
/// <summary> /// Initializes a new instance of the <see cref="ProductTaxCalculationResult"/> class. /// </summary> /// <param name="taxMethodName"> /// The tax method name /// </param> /// <param name="originalPrice"> /// The original price. /// </param> /// <param name="modifiedPrice"> /// The modified price. /// </param> /// <param name="originalSalePrice"> /// The original sale price. /// </param> /// <param name="modifiedSalePrice"> /// The modified sale price. /// </param> /// <param name="baseTaxRate"> /// The base tax rate /// </param> public ProductTaxCalculationResult( string taxMethodName, decimal originalPrice, decimal modifiedPrice, decimal originalSalePrice, decimal modifiedSalePrice, decimal? baseTaxRate = null) { var edprice = new ExtendedDataCollection(); var edsaleprice = new ExtendedDataCollection(); var taxRate = baseTaxRate != null ? baseTaxRate > 1 ? baseTaxRate.Value / 100M : baseTaxRate.Value : 0M; if (baseTaxRate != null) { edprice.SetValue(Core.Constants.ExtendedDataKeys.BaseTaxRate, baseTaxRate.Value.ToString(CultureInfo.InvariantCulture)); edsaleprice.SetValue(Core.Constants.ExtendedDataKeys.BaseTaxRate, baseTaxRate.Value.ToString(CultureInfo.InvariantCulture)); } edprice.SetValue(Constants.ExtendedDataKeys.ProductPriceNoTax, originalPrice.ToString(CultureInfo.InvariantCulture)); edprice.SetValue(Constants.ExtendedDataKeys.ProductPriceTaxAmount, modifiedPrice.ToString(CultureInfo.InvariantCulture)); edsaleprice.SetValue(Constants.ExtendedDataKeys.ProductSalePriceNoTax, originalSalePrice.ToString(CultureInfo.InvariantCulture)); edsaleprice.SetValue(Constants.ExtendedDataKeys.ProductSalePriceTaxAmount, modifiedSalePrice.ToString(CultureInfo.InvariantCulture)); PriceResult = new TaxCalculationResult(taxMethodName, taxRate, modifiedPrice, edprice); SalePriceResult = new TaxCalculationResult(taxMethodName, taxRate, modifiedSalePrice, edsaleprice); }
public TaxCalculationResult(string name, decimal taxRate, decimal taxAmount, ExtendedDataCollection extendedData) { Mandate.ParameterNotNull(extendedData, "extendedData"); Name = string.IsNullOrEmpty(name) ? "Tax" : name; TaxRate = taxRate; TaxAmount = taxAmount; ExtendedData = extendedData; }
internal Payment(Guid paymentTypeFieldKey, decimal amount, Guid? paymentMethodKey, ExtendedDataCollection extendedData) { Mandate.ParameterCondition(!Guid.Empty.Equals(paymentTypeFieldKey), "paymentTypeFieldKey"); Mandate.ParameterNotNull(extendedData, "extendedData"); _amount = amount; _paymentMethodKey = paymentMethodKey; _paymentTypeFieldKey = paymentTypeFieldKey; _extendedData = extendedData; }
/// /// Used to display extended data - for example purposes only /// private static string DictionaryToString(ExtendedDataCollection extendedData) { var extendedDataAsString = string.Empty; foreach (var dataItem in extendedData) { extendedDataAsString += dataItem.Key + ":" + dataItem.Value + ";"; } return extendedDataAsString; }
public static IInvoice GetMockInvoiceForTaxation() { var origin = new Address() { Organization = "Mindfly Web Design Studios", Address1 = "114 W. Magnolia St. Suite 300", Locality = "Bellingham", Region = "WA", PostalCode = "98225", CountryCode = "US", Email = "*****@*****.**", Phone = "555-555-5555" }; var billToShipTo = new Address() { Name = "Space Needle", Address1 = "400 Broad St", Locality = "Seattle", Region = "WA", PostalCode = "98109", CountryCode = "US", }; var invoiceService = new InvoiceService(); var invoice = invoiceService.CreateInvoice(Core.Constants.DefaultKeys.InvoiceStatus.Unpaid); invoice.SetBillingAddress(billToShipTo); var extendedData = new ExtendedDataCollection(); // this is typically added automatically in the checkout workflow extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD"); extendedData.SetValue(Core.Constants.ExtendedDataKeys.Taxable, true.ToString()); // make up some line items var l1 = new InvoiceLineItem(LineItemType.Product, "Item 1", "I1", 10, 1, extendedData); var l2 = new InvoiceLineItem(LineItemType.Product, "Item 2", "I2", 2, 40, extendedData); invoice.Items.Add(l1); invoice.Items.Add(l2); var shipment = new ShipmentMock(origin, billToShipTo, invoice.Items); var shipmethod = new ShipMethodMock(); var quote = new ShipmentRateQuote(shipment, shipmethod) { Rate = 16.22M }; invoice.Items.Add(quote.AsLineItemOf<InvoiceLineItem>()); invoice.Total = invoice.Items.Sum(x => x.TotalPrice); return invoice; }
/// <summary> /// Initializes a new instance of the <see cref="ShipmentRateQuote"/> class. /// </summary> /// <param name="shipment"> /// The shipment. /// </param> /// <param name="shipMethod"> /// The ship method. /// </param> /// <param name="extendedData"> /// The extended data. /// </param> public ShipmentRateQuote(IShipment shipment, IShipMethod shipMethod, ExtendedDataCollection extendedData) { Mandate.ParameterNotNull(shipment, "shipment"); Mandate.ParameterNotNull(shipMethod, "shipMethod"); Mandate.ParameterNotNull(extendedData, "extendedData"); shipment.ShipMethodKey = shipMethod.Key; Shipment = shipment; ShipMethod = shipMethod; ExtendedData = extendedData; }
public void Can_Deserialize_ExtendedData_To_Dictionary() { //// Arrange var persisted = @"<?xml version=""1.0"" encoding=""utf-16""?><extendedData><key3>value3</key3><key2>value2</key2><key1>value1</key1><key5>value5</key5><key4>value4</key4></extendedData>"; //// Act var extended = new ExtendedDataCollection(persisted); //// Assert Assert.IsTrue(5 == extended.Count); Assert.AreEqual("value3", extended.GetValue("key3")); }
public void Init() { var billTo = new Address() { Organization = "Mindfly Web Design Studios", Address1 = "114 W. Magnolia St. Suite 504", Locality = "Bellingham", Region = "WA", PostalCode = "98225", CountryCode = "US", Email = "*****@*****.**", Phone = "555-555-5555" }; // create an invoice var invoiceService = new InvoiceService(); _invoice = invoiceService.CreateInvoice(Core.Constants.DefaultKeys.InvoiceStatus.Unpaid); _invoice.SetBillingAddress(billTo); _invoice.Total = 120M; var extendedData = new ExtendedDataCollection(); // this is typically added automatically in the checkout workflow extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD"); // make up some line items var l1 = new InvoiceLineItem(LineItemType.Product, "Item 1", "I1", 10, 1, extendedData); var l2 = new InvoiceLineItem(LineItemType.Product, "Item 2", "I2", 2, 40, extendedData); var l3 = new InvoiceLineItem(LineItemType.Shipping, "Shipping", "shipping", 1, 10M, extendedData); var l4 = new InvoiceLineItem(LineItemType.Tax, "Tax", "tax", 1, 10M, extendedData); _invoice.Items.Add(l1); _invoice.Items.Add(l2); _invoice.Items.Add(l3); _invoice.Items.Add(l4); var processorSettings = new AuthorizeNetProcessorSettings { LoginId = ConfigurationManager.AppSettings["xlogin"], TransactionKey = ConfigurationManager.AppSettings["xtrankey"], UseSandbox = true }; Provider.GatewayProviderSettings.ExtendedData.SaveProcessorSettings(processorSettings); if (Provider.PaymentMethods.Any()) return; var resource = Provider.ListResourcesOffered().ToArray(); Provider.CreatePaymentMethod(resource.First(), "Credit Card", "Credit Card"); }
public void Can_Deserialize_An_Address_Stored_in_ExtendedDataCollection() { //// Arrange var extendedData = new ExtendedDataCollection(); extendedData.AddAddress(_address, AddressType.Shipping); //// Act var address = extendedData.GetAddress(AddressType.Shipping); //// Assert Assert.NotNull(address); Assert.AreEqual(typeof(Address), address.GetType()); }
private void MakeInvoice() { var origin = new Address() { Organization = "Mindfly Web Design Studios", Address1 = "114 W. Magnolia St. Suite 300", Locality = "Bellingham", Region = "WA", PostalCode = "98225", CountryCode = "US", Email = "*****@*****.**", Phone = "555-555-5555" }; var billToShipTo = new Address() { Name = "The President of the United States", Address1 = "1600 Pennsylvania Ave NW", Locality = "Washington", Region = "DC", PostalCode = "20500", CountryCode = "US", }; var invoiceService = new InvoiceService(); Invoice = invoiceService.CreateInvoice(Core.Constants.DefaultKeys.InvoiceStatus.Unpaid); Invoice.SetBillingAddress(billToShipTo); Invoice.Total = 120M; var extendedData = new ExtendedDataCollection(); // this is typically added automatically in the checkout workflow extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD"); extendedData.SetValue(Core.Constants.ExtendedDataKeys.Taxable, true.ToString()); // make up some line items var l1 = new InvoiceLineItem(LineItemType.Product, "Item 1", "I1", 10, 1, extendedData); var l2 = new InvoiceLineItem(LineItemType.Product, "Item 2", "I2", 2, 40, extendedData); Invoice.Items.Add(l1); Invoice.Items.Add(l2); var shipment = new ShipmentMock(origin, billToShipTo, Invoice.Items); var shipmethod = new ShipMethodMock(); var quote = new ShipmentRateQuote(shipment, shipmethod) { Rate = 16.22M }; Invoice.Items.Add(quote.AsLineItemOf<InvoiceLineItem>()); }
public ActionResult AddToBasket(AddItemModel model) { // This is an example of using the ExtendedDataCollection to add some custom functionality. // In this case, we are creating a direct reference to the content (Product Detail Page) so // that we can provide a link, thumbnail and description in the cart per this design. In other // designs, there may not be thumbnails or descriptions and the link could be to a completely // different website. var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); var product = _merchelloContext.Services.ProductService.GetByKey(model.ProductKey); // In the event the product has options we want to add the "variant" to the basket. // -- If a product that has variants is defined, the FIRST variant will be added to the cart. // -- This was done so that we did not have to throw an error since the Master variant is no // -- longer valid for sale. if (model.OptionChoices != null && model.OptionChoices.Any()) { var variant = _merchelloContext.Services.ProductVariantService.GetProductVariantWithAttributes(product, model.OptionChoices); // TODO : This is an error in the back office ... name should already include the variant info // Begin fix ------------------------------------------------------------------------------------------- // We need to save the variant name (T-Shirt - blue, large) instead of (T-Shirt). This is done in the // ProductVariantService CreateProductVariantWithKey ... but obviously we're not using that method // and must be doing it himself in the Back Office before he sends it to the server - likely just // calling save. http://issues.merchello.com/youtrack/issue/M-153 var name = product.Name; foreach (var att in variant.Attributes) { if (name == product.Name) name += " - "; else name += ", "; name += " " + att.Name; } // end fix ---------------------------------------------------------------------------------------------- _basket.AddItem(variant, name, 1, extendedData); } else { _basket.AddItem(product, product.Name, 1, extendedData); } _basket.Save(); // redirect to the cart page - this is a quick and dirty and should be done differently in // practice return RedirectToUmbracoPage(BasketContentId); }
protected LineItemBase(Guid lineItemTfKey, string name, string sku, int quantity, decimal price, ExtendedDataCollection extendedData) { Mandate.ParameterCondition(lineItemTfKey != Guid.Empty, "lineItemTfKey"); Mandate.ParameterNotNull(extendedData, "extendedData"); Mandate.ParameterNotNullOrEmpty(name, "name"); Mandate.ParameterNotNullOrEmpty(sku, "sku"); _lineItemTfKey = lineItemTfKey; _name = name; _sku = sku; _quantity = quantity; _price = price; _extendedData = extendedData; }
public void ContainsAny_Returns_False_When_Keys_DoNot_Exist() { //// Arrange var ed = new ExtendedDataCollection(); ed.SetValue("one", "value"); ed.SetValue("two", "value"); ed.SetValue("three", "value"); //// Act var found = ed.ContainsAny(new[] { "six", "five" }); //// Assert Assert.IsFalse(found); }
public void Init() { var billTo = new Address() { Organization = "Flightpath", Address1 = "36 West 25th Street", Locality = "New York", Region = "NY", PostalCode = "10010", CountryCode = "US", Email = "*****@*****.**", Phone = "212-555-5555" }; // create an invoice var invoiceService = new InvoiceService(); _invoice = invoiceService.CreateInvoice(Core.Constants.DefaultKeys.InvoiceStatus.Unpaid); _invoice.SetBillingAddress(billTo); _invoice.Total = 120M; var extendedData = new ExtendedDataCollection(); // this is typically added automatically in the checkout workflow extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD"); // make up some line items var l1 = new InvoiceLineItem(LineItemType.Product, "Item 1", "I1", 10, 1, extendedData); var l2 = new InvoiceLineItem(LineItemType.Product, "Item 2", "I2", 2, 40, extendedData); var l3 = new InvoiceLineItem(LineItemType.Shipping, "Shipping", "shipping", 1, 10M, extendedData); var l4 = new InvoiceLineItem(LineItemType.Tax, "Tax", "tax", 1, 10M, extendedData); _invoice.Items.Add(l1); _invoice.Items.Add(l2); _invoice.Items.Add(l3); _invoice.Items.Add(l4); var processorSettings = new StripeProcessorSettings { ApiKey = ConfigurationManager.AppSettings["stripeApiKey"] }; Provider.GatewayProviderSettings.ExtendedData.SaveProcessorSettings(processorSettings); if (Provider.PaymentMethods.Any()) return; var resource = Provider.ListResourcesOffered().ToArray(); Provider.CreatePaymentMethod(resource.First(), "Credit Card", "Credit Card"); }
public ActionResult AddToBasket(AddItemModel model) { // This is an example of using the ExtendedDataCollection to add some custom functionality. // In this case, we are creating a direct reference to the content (Product Detail Page) so // that we can provide a link, thumbnail and description in the cart per this design. In other // designs, there may not be thumbnails or descriptions and the link could be to a completely // different website. var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); // NEW IN 1.9.1 // We've added some data modifiers that can handle such things as including taxes in product // pricing. The data modifiers can either get executed when the item is added to the basket or // as a result from a MerchelloHelper query - you just don't want them to execute twice. // Calls directly to the ProductService are not modified // var product = this.MerchelloServices.ProductService.GetByKey(model.Product.Key); // Calls to using the MerchelloHelper WILL be modified // var merchello = new MerchelloHelper(); // // if you want to do this you should tell the basket not to modify the data again when adding the item //this.Basket.EnableDataModifiers = false; // In this case we want to get the product without any data modification var merchello = new MerchelloHelper(false); var product = merchello.Query.Product.GetByKey(model.Product.Key); // In the event the product has options we want to add the "variant" to the basket. // -- If a product that has variants is defined, the FIRST variant will be added to the cart. // -- This was done so that we did not have to throw an error since the Master variant is no // -- longer valid for sale. if (model.OptionChoices != null && model.OptionChoices.Any()) { // NEW in 1.9.1 // ProductDisplay and ProductVariantDisplay classes can be added directly to the Basket // so you don't have to query the service. var variant = product.GetProductVariantDisplayWithAttributes(model.OptionChoices); this.Basket.AddItem(variant, variant.Name, 1, extendedData); } else { this.Basket.AddItem(product, product.Name, 1, extendedData); } this.Basket.Save(); return this.RedirectToUmbracoPage(model.BasketPageId); }
public void Can_Serialize_ProviderSettings_To_CamelCased_Json() { //// Arrange var extendedData = new ExtendedDataCollection(); var settings = TestHelper.GetBraintreeProviderSettings(); Assert.NotNull(settings); Assert.AreEqual(EnvironmentType.Sandbox, settings.Environment); //// Act extendedData.SaveProviderSettings(settings); //// Assert Assert.IsTrue(extendedData.ContainsKey(Constants.ExtendedDataKeys.BraintreeProviderSettings)); }
public void Can_Deserialize_ProviderSettings_FromCamelCased_Json() { //// Arrange var extendedData = new ExtendedDataCollection(); var settings = TestHelper.GetBraintreeProviderSettings(); extendedData.SaveProviderSettings(settings); //// Act var json = extendedData.GetValue(Constants.ExtendedDataKeys.BraintreeProviderSettings); Assert.IsNotNullOrEmpty(json); var deserialized = JsonConvert.DeserializeObject<BraintreeProviderSettings>(json); Assert.NotNull(deserialized); }
public void Can_Deserialize_An_Address_Stored_In_A_Serialized_ExtendedDataCollection() { //// Arrange var extendedDataContainer = new ExtendedDataCollection(); var extendedDataWrapper = new ExtendedDataCollection(); extendedDataWrapper.AddAddress(_address, AddressType.Shipping); extendedDataContainer.AddExtendedDataCollection(extendedDataWrapper); //// Act var wrapper = extendedDataContainer.GetExtendedDataCollection(); var address = wrapper.GetAddress(AddressType.Shipping); //// Assert Assert.NotNull(address); Assert.AreEqual(typeof(Address), address.GetType()); }
public void Can_Convert_A_LineItem_Of_Type_ItemCacheLineItem_To_A_InvoiceLineItem() { //// Arrange var product = MockProductDataMaker.MockProductForInserting(); var extendedData = new ExtendedDataCollection(); extendedData.AddProductVariantValues(((Product)product).MasterVariant); var itemCacheLineItem = new ItemCacheLineItem(LineItemType.Product, product.Name, product.Sku, 2, 2*product.Price, extendedData); //// Act var invoiceLineItem = itemCacheLineItem.AsLineItemOf<InvoiceLineItem>(); //// Assert Assert.NotNull(invoiceLineItem); Assert.AreEqual(Guid.Empty, invoiceLineItem.ContainerKey); Assert.AreEqual(typeof(InvoiceLineItem), invoiceLineItem.GetType()); }
public void TestCaseNumber_1_Section_A_A_And_B() { //Arrange const string cardType = "ChaseNet"; const string card = "4011361100000012"; const string cardCode = ""; const string postalCode = "22222"; const int amount = 25; // Setup extended data for invoice var extendedData = new ExtendedDataCollection(); // this is typically added automatically in the checkout workflow extendedData.SetValue(Core.Constants.ExtendedDataKeys.CurrencyCode, "USD"); _invoice.BillToPostalCode = postalCode; // Set the total value for the invoice. _invoice.Total = amount; // make up some line items for the invoice var l1 = new InvoiceLineItem(LineItemType.Product, "Item 1", "I1", 1, amount, extendedData); _invoice.Items.Add(l1); var creditCardMethod = Provider.GetPaymentGatewayMethodByPaymentCode("CreditCard"); Assert.NotNull(creditCardMethod); var ccEntry = TestHelper.GetCreditCardFormData(cardType, card, cardCode); // Act var result = _payment.AuthorizePayment(_invoice, ccEntry.AsProcessorArgumentCollection()); var result2 = _payment.VoidPayment(_invoice, result.Payment.Result, ccEntry.AsProcessorArgumentCollection()); // Assert Assert.IsTrue(result.Payment.Success); Assert.IsTrue(result.ApproveOrderCreation); Assert.AreEqual("0", result2.Payment.Result.ExtendedData.GetValue(Constants.ExtendedDataKeys.VoidProcStatus)); // Log Results for certification TestHelper.LogInformation("Test 1A Section A", result); TestHelper.LogInformation("Test 1B Section A", result2); }
public ActionResult AddToBasket(AddItemModel model) { // Add to Logical Basket // add Umbraco content id to Merchello Product extended properties var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); // get Merchello product var product = Services.ProductService.GetByKey(model.ProductKey); // add a single item of the Product to the logical Basket Basket.AddItem(product, product.Name, 1, extendedData); // Save to Database tables: merchItemCache, merchItemCacheItem Basket.Save(); return RedirectToUmbracoPage(BasketContentId); }
public ActionResult AddToWishList(AddItemModel model) { var extendedData = new ExtendedDataCollection(); extendedData.SetValue("umbracoContentId", model.ContentId.ToString(CultureInfo.InvariantCulture)); var product = this.MerchelloServices.ProductService.GetByKey(model.Product.Key); if (model.OptionChoices != null && model.OptionChoices.Any()) { var variant = this.MerchelloServices.ProductVariantService.GetProductVariantWithAttributes(product, model.OptionChoices); _wishList.AddItem(variant, variant.Name, 1, extendedData); } else { _wishList.AddItem(product, product.Name, 1, extendedData); } _wishList.Save(); return this.RedirectToUmbracoPage(model.WishListPageId); }
public void Init() { _origin = new Address() { Name = "Mindfly Web Design Studio", Address1 = "114 W. Magnolia St. Suite 504", Locality = "Bellingham", Region = "WA", PostalCode = "98225", CountryCode = "US", IsCommercial = true }; _destination = new Address() { Name = "Stratosphere Casino, Hotel & Tower", Address1 = "2000 S Las Vegas Blvd", Locality = "Las Vegas", Region = "NV", PostalCode = "89104", CountryCode = "US", IsCommercial = true }; var extendedData = new ExtendedDataCollection(); extendedData.SetValue("merchProductKey", Guid.NewGuid().ToString()); extendedData.SetValue("merchProductVariantKey", Guid.NewGuid().ToString()); extendedData.SetValue("merchWeight", "12"); var lineItemCollection = new LineItemCollection() { {new ItemCacheLineItem(LineItemType.Product, "Product1", "Sku1", 1, 10, extendedData)}, {new ItemCacheLineItem(LineItemType.Product, "Product2", "Sku2", 2, 12, extendedData)}, {new ItemCacheLineItem(LineItemType.Product, "Product3", "Sku3", 3, 14, extendedData)}, }; _shipment = new Shipment(new ShipmentStatusMock(), _origin, _destination, lineItemCollection); }
/// <summary> /// Saves the processor settings to an extended data collection /// </summary> /// <param name="extendedData">The <see cref="ExtendedDataCollection"/></param> /// <param name="processorSettings">The <see cref="StripeProcessorSettings"/> to be serialized and saved</param> public static void SaveProcessorSettings(this ExtendedDataCollection extendedData, StripeProcessorSettings processorSettings) { var settingsJson = JsonConvert.SerializeObject(processorSettings); extendedData.SetValue(Constants.ExtendedDataKeys.ProcessorSettings, settingsJson); }
/// <summary> /// Serializes and saves a <see cref="Transaction"/> in extended data /// </summary> /// <param name="extendedData"> /// The extended data. /// </param> /// <param name="transaction"> /// The transaction. /// </param> public static void SetBraintreeTransaction(this ExtendedDataCollection extendedData, Transaction transaction) { extendedData.SetValue(Constants.ExtendedDataKeys.BraintreeTransaction, JsonConvert.SerializeObject(transaction)); }
/// <summary> /// Adds a line item to the backoffice /// </summary> /// <param name="productVariant"> /// The product Variant. /// </param> /// <param name="name"> /// The name. /// </param> /// <param name="quantity"> /// The quantity. /// </param> /// <param name="extendedData"> /// The extended Data. /// </param> public void AddItem(IProductVariant productVariant, string name, int quantity, ExtendedDataCollection extendedData) { if (!extendedData.DefinesProductVariant()) { extendedData.AddProductVariantValues(productVariant); } var onSale = productVariant.OnSale ? extendedData.GetSalePriceValue() : extendedData.GetPriceValue(); AddItem(string.IsNullOrEmpty(name) ? productVariant.Name : name, productVariant.Sku, quantity, onSale, extendedData); }