示例#1
0
        public async Task <ActionResult> Feedback(string guid = "")
        {
            var             payRes  = new PaymentResponseViewModel();
            var             userId  = Functions.User.GetUserId();
            var             user    = _db.AspNetUsers.FirstOrDefault(w => w.Id == userId);
            PaymentResponse payment = await _paymentClient.GetPaymentAsync(user.UniquePaymentReference);

            if (user.PassThrougReference == guid && user.UniquePaymentReference == payment.Id)
            {
                switch (payment.Status)
                {
                case Mollie.Api.Models.Payment.PaymentStatus.Paid:
                    //This is our happy path, everything went well, show a successmessage to the user.
                    Subscription subscription = new Subscription()
                    {
                        UserId           = Functions.User.GetUserId(),
                        Number           = 10,
                        DatePurchased    = DateTime.Now,
                        PaymentReference = payment.Id,
                        PaymentMethod    = payment.Method.ToString()
                    };
                    Subscriptions.AddSubscription(_db, subscription, Server.MapPath("~\\MailTemplates\\BetalingOntvangen.html"));
                    await _db.SaveChangesAsync();

                    //update user to avoid double subscriptions!
                    var userToUpdate = _db.AspNetUsers.FirstOrDefault(w => w.Id == userId);
                    userToUpdate.UniquePaymentReference = "";
                    userToUpdate.PassThrougReference    = "";
                    await _db.SaveChangesAsync();

                    payRes.PassThroughId    = guid;
                    payRes.PaymentSucceeded = true;
                    payRes.PaymentReference = user.UniquePaymentReference;
                    payRes.SuccessMessage   = "Proficiat, uw betaling is geslaagd! U hebt nu 10 lessen beschikbaar!";
                    break;

                case Mollie.Api.Models.Payment.PaymentStatus.Open:
                    payRes.ErrorMessage = "Payment is still open, we have to reconnect to mollie";
                    //The payment hasn't started yet, try to relaunch the link to mollie here;
                    break;

                case Mollie.Api.Models.Payment.PaymentStatus.Pending:
                    payRes.ErrorMessage = "Payment is started, just wait a little...";
                    //The payment has started, wait for it.
                    break;

                default:
                    //The payment isn't paid, pending or open, we assume it's aborted: propose some actions here
                    payRes.ErrorMessage = "Er is helaas iets misgelopen, klik op onderstaande knop om opnieuw te proberen.";
                    break;
                }
            }
            else
            {
                //the guid we passed to Mollie is not mapped correctly, show an error
                payRes.ErrorMessage = "Er is reeds een nieuwe betaling gestart, u kan dit scherm sluiten.";
            }
            return(View(payRes));
        }
        public void TestBuildSubscriptions()
        {
            var ss = new Subscriptions {
                Node = "princely_musings"
            };

            ss.AddSubscription(new Subscription
            {
                Jid = "*****@*****.**",
                Id  = "123",
                SubscriptionState = SubscriptionState.Subscribed
            });
            ss.AddSubscription(new Subscription
            {
                Jid = "*****@*****.**",
                Id  = "456",
                SubscriptionState = SubscriptionState.Unconfigured
            });

            ss.ShouldBe(Resource.Get("Xmpp.PubSub.subscription1.xml"));


            var ss2 = new Subscriptions {
                Node = "princely_musings"
            };

            var sub1 = ss2.AddSubscription();

            sub1.Jid = "*****@*****.**";
            sub1.Id  = "123";
            sub1.SubscriptionState = SubscriptionState.Subscribed;

            var sub2 = ss2.AddSubscription();

            sub2.Jid = "*****@*****.**";
            sub2.Id  = "456";
            sub2.SubscriptionState = SubscriptionState.Unconfigured;

            ss2.ShouldBe(Resource.Get("Xmpp.PubSub.subscription1.xml"));

            ss2.RemoveAllSubscriptions();
            // try again, it shouln't raise an error when no nodes exist
            ss2.RemoveAllSubscriptions();

            ss2.ShouldBe("<subscriptions xmlns='http://jabber.org/protocol/pubsub' node='princely_musings'/>");
        }
示例#3
0
 public void Subscribe(ReferenceType refType, int refID)
 {
     if (Subscriptions.IsUserSubscribed(UserSession.LoginUser, UserSession.LoginUser.UserID, refType, refID))
     {
         Subscriptions.RemoveSubscription(UserSession.LoginUser, UserSession.LoginUser.UserID, refType, refID);
     }
     else
     {
         Subscriptions.AddSubscription(UserSession.LoginUser, UserSession.LoginUser.UserID, refType, refID);
     }
 }
示例#4
0
        public ActionResult Create([Bind(Include = "Id,UserId,DatePurchased,Number")] Subscription subscription)
        {
            if (ModelState.IsValid)
            {
                subscription.PaymentReference = "";
                subscription.PaymentMethod    = "Manueel";
                Subscriptions.AddSubscription(_db, subscription, Server.MapPath("~\\MailTemplates\\BetalingOntvangen.html"));
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(_db.AspNetUsers, "Id", "Email", subscription.UserId);
            ViewBag.Id     = new SelectList(_db.Subscriptions, "Id", "UserId", subscription.Id);
            ViewBag.Id     = new SelectList(_db.Subscriptions, "Id", "UserId", subscription.Id);
            return(View(subscription));
        }
        public void CreateSubscription(RabbitEndpoint definition, bool start)
        {
            if (Subscriptions.HasSubscription(definition.QueueName))
            {
                return;
            }

            var queueSubscription = new QueueSubscription(ProxyFactory, Dispatcher, definition);

            queueSubscription.Name = definition.QueueName;
            if (start)
            {
                Subscriptions.AddAndStartSubscription(queueSubscription);
            }
            else
            {
                Subscriptions.AddSubscription(queueSubscription);
            }
        }
示例#6
0
        public static string SubscribeToTicket(RestCommand command, int ticketIDOrNumber, int userId)
        {
            TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber);

            if (ticket == null || ticket.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }

            UsersViewItem subscribingUser = UsersView.GetUsersViewItem(command.LoginUser, userId);

            if (subscribingUser == null || subscribingUser.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }

            Subscriptions.AddSubscription(command.LoginUser, userId, ReferenceType.Tickets, ticket.TicketID);

            return(ticket.GetXml("Ticket", true));
        }