예제 #1
0
        public static Registreringar MappaTillRegistrering(SignMeUpVM SUPVM, SignMeUpService SMU)
        {
            var banId = int.Parse(SUPVM.GetFaltvarde("Bana"));
            var bana  = SMU.Db.Banor.Find(banId);

            var klassId = int.Parse(SUPVM.GetFaltvarde("Klass"));
            var klass   = SMU.Db.Klasser.Find(klassId);

            var kanotId = int.Parse(SUPVM.GetFaltvarde("Kanot"));
            var kanot   = SMU.Db.Kanoter.Find(kanotId);

            var deltagareSteg  = SUPVM.GetStep("Deltagare");
            int antalDeltagare = deltagareSteg.FaltLista.Count / 2;
            var deltagare      = new List <Deltagare>();

            for (int i = 1; i <= antalDeltagare; i++)
            {
                deltagare.Add(new Deltagare
                {
                    Förnamn   = SUPVM.GetFaltvarde("Förnamn " + i),
                    Efternamn = SUPVM.GetFaltvarde("Efternamn " + i)
                });
            }

            int?rabattId = null;

            if (SUPVM.Rabatt != null)
            {
                rabattId = SUPVM.Rabatt.Id;
            }

            int?forseningsavgId = null;

            if (SUPVM.FAVM != null)
            {
                forseningsavgId = SUPVM.FAVM.Id;
            }

            return(new Registreringar
            {
                EvenemangsId = SUPVM.EvenemangsId,
                Lagnamn = SUPVM.GetFaltvarde("Lagnamn"),
                Bana = bana,
                Klass = klass,
                Kanot = kanot,
                Klubb = SUPVM.GetFaltvarde("Klubb"),
                Deltagare = deltagare.ToList(),
                Adress = SUPVM.GetFaltvarde("Adress"),
                Telefon = SUPVM.GetFaltvarde("Telefon"),
                Epost = SUPVM.GetFaltvarde("Epost"),
                RabattId = rabattId,
                ForseningsavgiftId = forseningsavgId,
                Invoice = SUPVM.Fakturaadress != null?MappTillInvoice(SUPVM.Fakturaadress) : null,
                              Registreringstid = DateTime.Now,
                              PaysonToken = SUPVM.PaysonToken,
                              HarBetalt = SUPVM.AttBetala == 0 ? true : false
            });
        }
예제 #2
0
        private PayData SkapaPaysonPayData(SignMeUpVM SUPVM, Organisation org)
        {
            // We remove port info to help when the site is behind a load balancer/firewall that does port rewrites.
            var scheme = Request.Url.Scheme;
            var host   = Request.Url.Host;

            var returnUrl = Url.Action("Returned", "Payson", new RouteValueDictionary(), scheme, host) + "/" + SUPVM.RegistreringsId;

            var cancelUrl = Url.Action("Cancelled", "Payson", new RouteValueDictionary(), scheme, host) + "/" + SUPVM.RegistreringsId;

            var sender = new Sender(SUPVM.Kontaktinformation.SenderEmail);

            sender.FirstName = SUPVM.Kontaktinformation.SenderFirstName;
            sender.LastName  = SUPVM.Kontaktinformation.SenderLastName;

            var receiver = new Receiver(org.Epost, SUPVM.AttBetala);

            receiver.FirstName = org.Namn;
            receiver.SetPrimaryReceiver(true);

            var payData = new PayData(returnUrl,
                                      cancelUrl,
                                      smuService.HamtaEvenemang(SUPVM.EvenemangsId).Namn + " - " + SUPVM.GetFaltvarde("Lagnamn"),
                                      sender,
                                      new List <Receiver> {
                receiver
            });

            // Set IPN callback URL
            // When the shop is hosted by Payson the IPN scheme must be http and not https
            var ipnNotificationUrl = Url.Action("IPN", "Payson", new RouteValueDictionary(), scheme, host) + "/" + SUPVM.RegistreringsId;

            payData.SetIpnNotificationUrl(ipnNotificationUrl);

            payData.SetFundingConstraints(new List <FundingConstraint> {
                FundingConstraint.Bank, FundingConstraint.CreditCard
            });
            payData.SetTrackingId(SUPVM.RegistreringsId.ToString());

            // Skapa poster för betalning
            var orderItems = new List <PaysonIntegration.Utils.OrderItem>();

            foreach (ValViewModel post in SUPVM.Betalnignsposter)
            {
                var oi = new PaysonIntegration.Utils.OrderItem(post.TypNamn + ": " + post.Namn);
                oi.SetOptionalParameters("st", 1, post.Avgift, 0);
                orderItems.Add(oi);
            }

            payData.SetOrderItems(orderItems);

            return(payData);
        }