public ActionResult Process(HttpRequestBase request, ModelStateDictionary modelState)
        {
            IpnVerificationBinder binder = new IpnVerificationBinder();
            Transaction tx = binder.Bind(request.Form, modelState);

            ContentResult cr = new ContentResult();
            cr.ContentEncoding = Encoding.UTF8;
            cr.ContentType = "text/html";
            cr.Content = "INVALID";

            if (tx != null)
            {
                Transaction dbTx = m_txRepository.GetAll().Where(x => x.Tx == tx.Tx).FirstOrDefault();
                if (dbTx != null)
                {
                    string expected = dbTx.ToIpnQueryString().ToString();
                    QueryString actualQs = new QueryString();
                    actualQs.Add(request.Form);
                    actualQs.Remove("cmd");
                    string actual = actualQs.ToString();

                    if (expected == actual)
                    {
                        cr.Content = "VERIFIED";
                    }
                }
            }

            return cr;
        }
        public void ShouldBindTx()
        {
            // Arrange
            IpnVerificationBinder binder = new IpnVerificationBinder();

            NameValueCollection form = new NameValueCollection {
                { "txn_id", m_txn_id},
                { "payment_status", m_payment_status},
                { "mc_gross", m_mc_gross},
                { "mc_currency", m_mc_currency},
                { "custom", m_custom},
                { "item_number", m_item_number},
                { "business", m_business},
                { "verify_sign", m_verify_sign}
            };

            // Act
            Transaction p = binder.Bind(form, m_modelState);

            // Assert
            Assert.AreEqual(m_txn_id, p.Tx);
            Assert.AreEqual(m_payment_status, p.State);
            Assert.AreEqual(m_mc_gross, p.Amount);
            Assert.AreEqual(m_mc_currency, p.Currency);
            Assert.AreEqual(m_custom, p.Custom);
            Assert.AreEqual(m_item_number, p.ItemNumber);
            Assert.AreEqual(m_business, p.Account);
            Assert.AreEqual(m_verify_sign, p.VerifySign);
        }
        public void ShouldFailToBindIfAmountMissing()
        {
            // Arrange
            IpnVerificationBinder binder = new IpnVerificationBinder();

            NameValueCollection form = new NameValueCollection {
                { "txn_id", m_txn_id},
                { "payment_status", m_payment_status},
                { "mc_currency", m_mc_currency},
                { "custom", m_custom},
                { "item_number", m_item_number},
                { "business", m_business},
                { "verify_sign", m_verify_sign}
            };

            // Act
            Transaction p = binder.Bind(form, m_modelState);

            // Assert
            Assert.AreEqual(null, p);
            Assert.IsFalse(m_modelState.IsValid);
        }