/// <summary>
 /// a member can register, and skip the 2nd step
 /// if these values are then set afterwards when editing this profile, then we can then mark the registration as complete
 /// </summary>
 /// <param name="partier"></param>
 private void CheckRegistrationComplete(IPartier partier)
 {
     // once it has been completed, we never revert back, so only process if dot mailer thinks the host hasn't yet completed registration
     if (!partier.DotMailerRegistrationComplete)
     {
         if (!string.IsNullOrWhiteSpace(partier.FirstName) && !string.IsNullOrWhiteSpace(partier.LastName) && !string.IsNullOrWhiteSpace(partier.BillingAddress.ToString()))
         {
             if (partier is PartyHost)
             {
                 DotMailerService.HostRegistrationCompleted((Contact)(PartyHost)partier);
             }
             else if (partier is PartyGuest)
             {
                 DotMailerService.GuestRegistrationCompleted((Contact)(PartyGuest)partier);
             }
         }
     }
 }
示例#2
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));
        }
示例#3
0
        public HttpResponseMessage Notifcation([FromBody] NotificationRequest notificationRequest)
        {
            // create response obj to send back to Sage Pay (defaulting to error)
            NotificationResponse notificationResponse = new NotificationResponse();

            notificationResponse.Status = NotificationStatus.ERROR;

            // get associated transaction details from the database
            DonationRow donationRow = this.DatabaseContext.Database.Fetch <DonationRow>("SELECT TOP 1 * FROM wonderlandDonation WHERE VendorTxCode = @0", notificationRequest.VendorTxCode).Single();

            // safety checks
            if (notificationRequest.VPSTxId != donationRow.VPSTxId)
            {
                notificationResponse.StatusDetail += "VPSTxID Invalid" + Environment.NewLine;
            }
            else if (!this.IsSignatureValid(donationRow, notificationRequest))
            {
                notificationResponse.StatusDetail += "Signature Invalid" + Environment.NewLine;
            }
            else
            {
                // change response status from Error to OK, as valid inbound data is valid
                notificationResponse.Status = NotificationStatus.OK;

                switch (notificationRequest.Status)
                {
                case NotificationStatus.OK:
                    donationRow.Success = true;
                    this.SendPaymentConfirmationEmail(donationRow);
                    break;

                case NotificationStatus.ABORT:
                    donationRow.Cancelled = true;
                    break;
                }

                this.DatabaseContext.Database.Update(donationRow);
            }

            // determine redirect url
            string redirectUrl = WebConfigurationManager.AppSettings["SagePay:RedirectDomain"];

            switch (donationRow.PaymentJourney)
            {
            case PaymentJourney.RegisterGuest:

                // safety check (memberId should always have a value)
                if (donationRow.MemberId.HasValue)
                {
                    // update dot mailer to indicate guest has fully registered
                    DotMailerService.GuestRegistrationCompleted((Contact)(PartyGuest)this.Members.GetById(donationRow.MemberId.Value));
                }

                redirectUrl += this.Umbraco.TypedContentSingleAtXPath("//" + RegisterGuest.Alias).Url;
                break;

            case PaymentJourney.Donate:

                redirectUrl += this.Umbraco.TypedContentSingleAtXPath("//" + Donate.Alias).Url;
                break;
            }

            //update dot mailer donation_amount and guest_count for associated party host
            DotMailerService.UpdateContact((Contact)this.Members.GetPartyHost(donationRow.PartyGuid));

            notificationResponse.RedirectURL = redirectUrl;

            if (donationRow.Success)
            {
                notificationResponse.RedirectURL += "complete/";
            }

            if (donationRow.Cancelled)
            {
                notificationResponse.RedirectURL += "cancelled/";
            }

            notificationResponse.RedirectURL += "?VendorTxCode=" + notificationRequest.VendorTxCode;

            // ensure the return type is plain text
            return(new HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new StringContent(
                    SagePaySerializer.SerializeResponse(notificationResponse),
                    Encoding.UTF8,
                    "text/plain")
            });
        }