コード例 #1
0
        void AddWithCustomFields()
        {
            Subscriber subscriber = new Subscriber(listID);

            try
            {
                List<SubscriberCustomField> customFields = new List<SubscriberCustomField>();
                customFields.Add(new SubscriberCustomField() { Key = "CustomFieldKey", Value = "Value" });
                customFields.Add(new SubscriberCustomField() { Key = "CustomFieldKey2", Value = "Value2" });

                string newSubscriberID = subscriber.Add("*****@*****.**", "Test Name", customFields, false);
                Console.WriteLine(newSubscriberID);
            }
            catch (CreatesendException ex)
            {
                ErrorResult error = (ErrorResult)ex.Data["ErrorResult"];
                Console.WriteLine(error.Code);
                Console.WriteLine(error.Message);
            }
            catch (Exception ex)
            {
                // Handle some other failure
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #2
0
        public JsonResult AddSubscriber(CMSubscriber model)
        {
            Subscriber subscriber = new Subscriber(_auth, _listID);

            try
            {
                string newSubscriberID = subscriber.Add(model.Email, "", null, false);
                return Json(new { Success = true });
            }
            catch (CreatesendException ex)
            {
                ErrorResult error = (ErrorResult)ex.Data["ErrorResult"];
                return Json(new { Success = false, Error = error });
            }
            catch (Exception ex)
            {
                return Json(new { Success = false, Error = new { Message = ex.ToString() } });
            }
        }
コード例 #3
0
        void BasicAdd()
        {
            Subscriber subscriber = new Subscriber(listID);

            try
            {
                string newSubscriberID = subscriber.Add("*****@*****.**", "Test Name", null, false);
                Console.WriteLine(newSubscriberID);
            }
            catch (CreatesendException ex)
            {
                ErrorResult error = (ErrorResult)ex.Data["ErrorResult"];
                Console.WriteLine(error.Code);
                Console.WriteLine(error.Message);
            }
            catch (Exception ex)
            {
                //handle some other failure
            }
        }
コード例 #4
0
        public ActionResult SubscribeTour(TourShow tourShow)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    foreach (var value in ModelState.Values.ToList())
                    {
                        foreach (var error in value.Errors)
                        {
                            ModelState.AddModelError(string.Empty, error.ErrorMessage);
                        }
                    }
                    tourShow.IsTripBooked = false;
                    return PartialView("_Coming Soon", tourShow);
                }

                tourShow.IsTripBooked = true;
                if (tourShow.MailingListID != null)
                {
                    AuthenticationDetails auth = new ApiKeyAuthenticationDetails(ConfigurationManager.AppSettings["CampaignMonitorAPI_key"]);
                    Subscriber objSubscriber = new Subscriber(auth, tourShow.MailingListID);
                    string newSubscriberID = objSubscriber.Add(tourShow.EmailToSubscribe.ToString(), null, null, false);
                }

                return PartialView("_Coming Soon", tourShow);

            }
            catch (Exception e)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(e);
                return PartialView("_Coming Soon");
            }
        }
コード例 #5
0
        public ActionResult AuthorizeNetSimGift(FormCollection post)
        {
            _logger.Info("keys: {0}", string.Join(", ", post.AllKeys));
            var orderId = Convert.ToInt32(post["GiftOrderId"]);
            var userId = Convert.ToInt32(post["UserId"]);
            var order = _giftCardOrderService.FindOrder(orderId, userId);

            _logger.Info("Authorizing SIM...");

            //the URL to redirect to- this MUST be absolute
            var successUrl = Url.RouteUrl("giftconfirmation", new { orderId = order.Id }, SecureProtocol);
            var failureUrl = Url.RouteUrl("billing-giftdetails", new { orderId = order.Id }, SecureProtocol);
            var redirectUrl = successUrl;

            var response = new SIMResponse(post);

            _logger.Info("Approved: {0}", response.Approved);
            _logger.Info("Code: {0}", response.ResponseCode);
            _logger.Info("Message: {0}", response.Message);
            _logger.Info("Authorization Code: {0}", response.AuthorizationCode);
            _logger.Info("Card Number: {0}", response.CardNumber);
            _logger.Info("Card Type: {0}", response.CardType);
            _logger.Info("Invoice Number: {0}", response.InvoiceNumber);
            _logger.Info("MD5 Hash: {0}", response.MD5Hash);
            _logger.Info("Transaction ID: {0}", response.TransactionID);

            //first order of business - validate that it was Authorize.Net that posted this using the
            //MD5 hash that was passed back to us
            var isValid = response.Validate(AuthorizeNetConfig.Md5HashValue, AuthorizeNetConfig.ApiLogin);

            _logger.Info("Valid: {0}", isValid);
            if (isValid && response.Approved)
            {
                _giftorderConfirmationMailer.SendGiftOrderConfirmationEmail(order);
                _giftCardOrderService.CompleteOrder(order, response.TransactionID);

                //Campaign Monitor -Adding subscriber to Gift card recipients List

                AuthenticationDetails auth = new ApiKeyAuthenticationDetails(ConfigurationManager.AppSettings["CampaignMonitorAPI_key"]);
                Subscriber objSubscriber = new Subscriber(auth, ConfigurationManager.AppSettings["CampaignMonitorListID"]);

                for (int i = 0; i < order.GiftOrderDetail.Count; i++)
                {
                    List<SubscriberCustomField> customFields = new List<SubscriberCustomField>();
                    customFields.Add(new SubscriberCustomField() { Key = "Amount", Value = order.GiftOrderDetail[i].Amount.ToString() });
                    customFields.Add(new SubscriberCustomField() { Key = "Your Name", Value = order.GiftOrderDetail[i].YourName.ToString() });
                    customFields.Add(new SubscriberCustomField() { Key = "Gift Code", Value = order.GiftOrderDetail[i].RecipientGiftCode.ToString() });
                    customFields.Add(new SubscriberCustomField() { Key = "Message", Value = order.GiftOrderDetail[i].Message.ToString() });

                    string newSubscriberID = objSubscriber.Add(order.GiftOrderDetail[i].RecipientEmail.ToString(), null, customFields, false);
                }

            }
            else
            {
                _giftCardOrderService.FailOrder(order, response.Message);
                redirectUrl = failureUrl;
            }

            return Content(AuthorizeNet.Helpers.CheckoutFormBuilders.Redirecter(redirectUrl));
        }
コード例 #6
0
        public ActionResult Billing(Britespokes.Services.GiftCards.BillingDetails billingDetails)
        {
            //decimal GiftAmount = 0;
            //int OrderDetailId = 0;

            var order = _giftCardOrderService.FindOrder(billingDetails.GiftOrderId, UserContext.UserId);
            if (!billingDetails.AcceptedTermsAndConditions)
                ModelState.AddModelError("AcceptedTermsAndConditions", "you must accept the terms and conditions to purchase a tour");
            if (order.OrderStatus != _giftCardOrderService.StatusPending())
                ModelState.AddModelError("", "This order is no longer pending");
            if (UserContext.IsGuest && string.IsNullOrEmpty(billingDetails.Password))
                ModelState.AddModelError("Password", "required");

            if (string.CompareOrdinal(billingDetails.Password, billingDetails.ConfirmPassword) != 0)
                ModelState.AddModelError("ConfirmPassword", "doesn't match");

            if (ModelState.IsValid)
            {
                if (UserContext.IsGuest)
                {
                    var user = _userService.Find(UserContext.UserId);
                    _registrationService.PromoteGuest(user, billingDetails.Email, billingDetails.Password);
                    _userMailer.SendWelcomeEmail(UserContext.Organization, user);
                }
                _giftCardOrderService.UpdateBillingDetails(billingDetails);

                //Campaign Monitor -Adding subscriber to Gift card recipients List

                AuthenticationDetails auth = new ApiKeyAuthenticationDetails(ConfigurationManager.AppSettings["CampaignMonitorAPI_key"]);
                Subscriber objSubscriber = new Subscriber(auth, ConfigurationManager.AppSettings["CampaignMonitorListID"]);

                for (int i = 0; i < order.GiftOrderDetail.Count; i++)
                {
                    List<SubscriberCustomField> customFields = new List<SubscriberCustomField>();
                    customFields.Add(new SubscriberCustomField() { Key = "Amount", Value = order.GiftOrderDetail[i].Amount ==null? "":order.GiftOrderDetail[i].Amount.ToString() });
                    customFields.Add(new SubscriberCustomField() { Key = "Your Name", Value = order.GiftOrderDetail[i].YourName == null ? "" : order.GiftOrderDetail[i].YourName.ToString() });
                    customFields.Add(new SubscriberCustomField() { Key = "Gift Code", Value = order.GiftOrderDetail[i].RecipientGiftCode == null ? "" : order.GiftOrderDetail[i].RecipientGiftCode.ToString() });
                    customFields.Add(new SubscriberCustomField() { Key = "Message", Value = order.GiftOrderDetail[i].Message == null ? "" : order.GiftOrderDetail[i].Message.ToString() });

                    string newSubscriberID = objSubscriber.Add(order.GiftOrderDetail[i].RecipientEmail.ToString(), null, customFields, false);
                }

                return Json(new { BillingDetails = billingDetails, Errors = new object[0] });
            }

            billingDetails.BillingOverview = _giftCardOrderService.BuildBillingOverview(order);
            billingDetails.PaymentRequest = new PaymentRequest(order.Total, AuthorizeNetConfig.ApiLogin, AuthorizeNetConfig.TransactionKey, AuthorizeNetConfig.TestMode);
            return Json(new { BillingDetails = billingDetails, Errors = ModelStateErrorsForJson() });
        }