Пример #1
0
        public ActionResult HandleDonateForm(DonateForm donateForm)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.CurrentUmbracoPage());
            }

            int?memberId = null;

            if (this.Members.IsLoggedInPartier())
            {
                memberId = this.Members.GetCurrentMemberId();
            }

            DonationRow donationRow = new DonationRow()
            {
                PartyGuid      = donateForm.PartyGuid,
                Amount         = donateForm.Amount,
                GiftAid        = donateForm.AllowGiftAid,
                MemberId       = memberId,
                FirstName      = donateForm.FirstName,
                LastName       = donateForm.LastName,
                Address1       = donateForm.Address1,
                Address2       = donateForm.Address2,
                TownCity       = donateForm.TownCity,
                Postcode       = donateForm.Postcode,
                PaymentJourney = PaymentJourney.Donate,
                Success        = false
            };

            // insert new record
            this.DatabaseContext.Database.Insert(donationRow);

            // build new obj containing data for sage pay
            TransactionRegistrationRequest transactionRegistrationRequest = new TransactionRegistrationRequest(donationRow);

            // send to sage pay and get respone
            TransactionRegistrationResponse transactionRegistrationResponse = TransactionRegistration.Send(transactionRegistrationRequest);

            // based on response, we redirect the user to...
            if (transactionRegistrationResponse.Status == TransactionRegistrationStatus.OK)
            {
                // update database
                donationRow.VPSTxId     = transactionRegistrationResponse.VPSTxId;
                donationRow.SecurityKey = transactionRegistrationResponse.SecurityKey;

                this.DatabaseContext.Database.Update(donationRow);

                return(this.Redirect(transactionRegistrationResponse.NextURL));
            }

            this.ViewData["errorMessage"] = transactionRegistrationResponse.StatusDetail;

            return(this.View("Donate/Failed", this.CurrentPage));
        }
Пример #2
0
        public TransactionRegistrationResponse Send(RequestContext context, string vendorTxCode, ShoppingBasket basket,
                                                    Address billingAddress, Address deliveryAddress, string customerEmail)
        {
            string sagePayUrl      = configuration.RegistrationUrl;
            string notificationUrl = urlResolver.BuildNotificationUrl(context);

            var registration = new TransactionRegistration(
                vendorTxCode, basket, notificationUrl,
                billingAddress, deliveryAddress, customerEmail,
                configuration.VendorName);

            var serializer = new HttpPostSerializer();
            var postData   = serializer.Serialize(registration);

            var response = requestSender.SendRequest(sagePayUrl, postData);

            var deserializer = new ResponseSerializer();

            return(deserializer.Deserialize <TransactionRegistrationResponse>(response));
        }
Пример #3
0
        public TransactionRegistrationResponse Send(RequestContext context, string vendorTxCode, ShoppingBasket basket,
                                                    Address billingAddress, Address deliveryAddress, string customerEmail, PaymentFormProfile paymentFormProfile = PaymentFormProfile.Normal, string currencyCode = "GBP",
                                                    MerchantAccountType accountType = MerchantAccountType.Ecommerce, TxType txType = TxType.Payment)
        {
            string sagePayUrl      = configuration.RegistrationUrl;
            string notificationUrl = urlResolver.BuildNotificationUrl(context);

            var registration = new TransactionRegistration(
                vendorTxCode, basket, notificationUrl,
                billingAddress, deliveryAddress, customerEmail,
                configuration.VendorName,
                paymentFormProfile, currencyCode, accountType, txType);

            var serializer = new HttpPostSerializer();
            var postData   = serializer.Serialize(registration);

            var response = requestSender.SendRequest(sagePayUrl, postData);

            var deserializer = new ResponseSerializer();

            return(deserializer.Deserialize <TransactionRegistrationResponse>(response));
        }
Пример #4
0
        private static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.Console()
                         .WriteTo.File(@"\Logs\EventExperiment.csv",
                                       rollingInterval: RollingInterval.Day,
                                       outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} ; [{Level:u3}] ; {Message:lj} ;{NewLine}{Exception};")
                         .CreateLogger();

            var logSub      = new LogSubscriber(Log.Logger);
            var customer    = new CustomerSubscriber();
            var customerPub = new CustomerPublisher();
            var site        = new SiteSubscriber();
            var sitePub     = new SitePublisher();
            var trans       = new TransactionRegistration();

            var configuration = new PipelineConfiguration(customer, customerPub, site, sitePub, trans, logSub)
                                .RegisterSiteSubscriptions()
                                .RegisterSitePublications()
                                .RegisterCustomerSubscriptions()
                                .RegisterCustomerPublications();

            var stopWatch = new Stopwatch();

            stopWatch.Start();

            Parallel.For(1, 1000, (x) => { trans.TransactionReceivedEvent(x, Guid.NewGuid()); });

            stopWatch.Stop();
            Log.Information($"Elapsed Time (Milliseconds): {stopWatch.ElapsedMilliseconds}.");

            Console.WriteLine("Press any key to continue.");
            Log.CloseAndFlush();
            Console.ReadKey();
        }
Пример #5
0
        public ActionResult HandleRegisterGuestBillingForm(RegisterGuestBillingForm registerGuestBillingForm)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.CurrentUmbracoPage());
            }

            PartyGuest partyGuest = (PartyGuest)this.Members.GetCurrentMember();

            if (partyGuest.FirstName != registerGuestBillingForm.FirstName)
            {
                partyGuest.FirstName = registerGuestBillingForm.FirstName;
            }

            if (partyGuest.LastName != registerGuestBillingForm.LastName)
            {
                partyGuest.LastName = registerGuestBillingForm.LastName;
            }

            Address address = new Address(
                registerGuestBillingForm.Address1,
                registerGuestBillingForm.Address2,
                registerGuestBillingForm.TownCity,
                registerGuestBillingForm.Postcode);

            partyGuest.BillingAddress = address;

            if (!string.IsNullOrWhiteSpace(registerGuestBillingForm.Message))
            {
                // post message to party wall
                this.DatabaseContext.Database.Insert(new MessageRow()
                {
                    MemberId = this.Members.GetCurrentMemberId(),
                    Text     = registerGuestBillingForm.Message,
                    Image    = null
                });
            }

            if (registerGuestBillingForm.Amount == 0)
            {
                // update dot mailer to indicate guest has fully registered
                DotMailerService.GuestRegistrationCompleted((Contact)partyGuest);

                return(this.Redirect(partyGuest.PartyUrl));
            }

            DonationRow donationRow = new DonationRow()
            {
                PartyGuid      = registerGuestBillingForm.PartyGuid,
                Amount         = registerGuestBillingForm.Amount,
                GiftAid        = registerGuestBillingForm.AllowGiftAid,
                MemberId       = this.Members.GetCurrentMemberId(),
                FirstName      = registerGuestBillingForm.FirstName,
                LastName       = registerGuestBillingForm.LastName,
                Address1       = registerGuestBillingForm.Address1,
                Address2       = registerGuestBillingForm.Address2,
                TownCity       = registerGuestBillingForm.TownCity,
                Postcode       = registerGuestBillingForm.Postcode,
                PaymentJourney = PaymentJourney.RegisterGuest,
                Success        = false
            };

            // insert new record
            this.DatabaseContext.Database.Insert(donationRow);

            // build new obj containing data for sage pay
            TransactionRegistrationRequest transactionRegistrationRequest = new TransactionRegistrationRequest(donationRow);

            // send to sage pay and get respone
            TransactionRegistrationResponse transactionRegistrationResponse = TransactionRegistration.Send(transactionRegistrationRequest);

            // based on response, we redirect the user to...
            if (transactionRegistrationResponse.Status == TransactionRegistrationStatus.OK)
            {
                // update database
                donationRow.VPSTxId     = transactionRegistrationResponse.VPSTxId;
                donationRow.SecurityKey = transactionRegistrationResponse.SecurityKey;

                this.DatabaseContext.Database.Update(donationRow);

                return(this.Redirect(transactionRegistrationResponse.NextURL));
            }

            this.ViewData["errorMessage"] = transactionRegistrationResponse.StatusDetail;

            return(this.View("RegisterGuest/Failed", this.CurrentPage));
        }
Пример #6
0
 public PipelineConfiguration(CustomerSubscriber customer, CustomerPublisher customerPub, SiteSubscriber site, SitePublisher sitePub, TransactionRegistration transaction, LogSubscriber logSubscriber)
 {
     this.customerSubscriber                   = customer;
     this.customerPublisher                    = customerPub;
     this.siteSubscriber                       = site;
     this.sitePublisher                        = sitePub;
     this.transactionRegistration              = transaction;
     this.siteSubscriber.SitePublisher         = this.sitePublisher;
     this.customerSubscriber.CustomerPublisher = this.customerPublisher;
     this.LogSubscriber                        = logSubscriber;
 }