Beispiel #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));
        }
        public async Task <TransactionRegistrationResponse> InitializeTransaction(string _returnurl, string _merchantreference, string _merchantid, string _description, string _totalamount, string _currencycode, string _customerEmail, string _customerNumber, string _customerFirstName, string _customerLastName, bool isLive)
        {
            var client = HttpConnection.Call(_token, isLive);

            if (isLive)
            {
                baseURL = Constants.BaseEndURlLive;
            }

            List <Product> _products = new List <Product>();

            var _product = new Product
            {
                Name      = _description,
                Quantity  = "1",
                Unitprice = _totalamount
            };

            _products.Add(_product);

            var _customer = new Customer
            {
                Email     = _customerEmail,
                Firstname = _customerFirstName,
                Lastname  = _customerLastName,
                Mobile    = _customerNumber,
            };

            var transactionRegistrationRequest = new TransactionRegistrationRequest
            {
                Returnurl         = _returnurl,
                Customerip        = "",
                Merchantreference = _merchantreference,
                Merchantid        = _merchantid,
                Description       = _description,
                Currencycode      = _currencycode,
                Totalamount       = _totalamount,
                Paymentmethod     = "card",
                TransactionType   = "Payment",
                Connectionmode    = "redirect",
                Customer          = _customer,
                Product           = _products
            };


            var requestJson   = JsonConvert.SerializeObject(transactionRegistrationRequest);
            var stringContent = new StringContent(requestJson, Encoding.UTF8, "application/json");
            var response      = await client.PostAsync(baseURL + "/SetRequest", stringContent);

            var responseJson = await response.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <TransactionRegistrationResponse>(responseJson));
        }
Beispiel #3
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));
        }