Beispiel #1
0
        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");
        }
Beispiel #2
0
        public void FixtureSetup()
        {
            SqlSyntaxProviderTestHelper.EstablishSqlSyntax();

            var cacheProvider = new Mock <IRuntimeCacheProvider>();

            GatewayProviderService = new GatewayProviderService();

            var providers =
                GatewayProviderService.GetAllGatewayProviders()
                .Where(x => x.GatewayProviderType == GatewayProviderType.Payment);

            GatewayProviderSettings = providers.FirstOrDefault(x => x.Key == new Guid("C6BF6743-3565-401F-911A-33B68CACB11B"));

            if (GatewayProviderSettings != null)
            {
                GatewayProviderService.Delete(GatewayProviderSettings);
            }

            var petaPoco = new PetaPocoUnitOfWorkProvider();

            var xLogin   = ConfigurationManager.AppSettings["xlogin"];
            var xtrankey = ConfigurationManager.AppSettings["xtrankey"];

            var sql = new Sql();

            var dto = new GatewayProviderSettingsDto()
            {
                Key                 = new Guid("C6BF6743-3565-401F-911A-33B68CACB11B"),
                Name                = "AuthorizeNet",
                Description         = "AuthorizeNet",
                ExtendedData        = "<extendedData />",
                EncryptExtendedData = false,
                ProviderTfKey       = Constants.TypeFieldKeys.GatewayProvider.PaymentProviderKey,
                CreateDate          = DateTime.Now,
                UpdateDate          = DateTime.Now
            };


            petaPoco.GetUnitOfWork().Database.Insert(dto);

            GatewayProviderSettings =
                GatewayProviderService.GetGatewayProviderByKey(new Guid("C6BF6743-3565-401F-911A-33B68CACB11B"));

            var providerSettings = new AuthorizeNetProcessorSettings()
            {
                LoginId        = xLogin,
                TransactionKey = xtrankey
            };

            GatewayProviderSettings.ExtendedData.SaveProcessorSettings(providerSettings);

            Provider = new AuthorizeNetPaymentGatewayProvider(GatewayProviderService, GatewayProviderSettings,
                                                              cacheProvider.Object);
        }
Beispiel #3
0
        /// <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="AuthorizeNetProcessorSettings"/> to be serialized and saved</param>
        public static void SaveProcessorSettings(this ExtendedDataCollection extendedData, AuthorizeNetProcessorSettings processorSettings)
        {
            var settingsJson = JsonConvert.SerializeObject(processorSettings);

            extendedData.SetValue(Constants.ExtendedDataKeys.ProcessorSettings, settingsJson);
        }
 public AuthorizeNetPaymentProcessor(AuthorizeNetProcessorSettings settings)
 {
     _settings = settings;
 }