public void simpleAuthWithApplepayAndSecondaryAmountAndWallet()
        {
            authorization authorization = new authorization();

            authorization.reportGroup     = "Planets";
            authorization.orderId         = "123456";
            authorization.amount          = 110;
            authorization.secondaryAmount = 50;
            authorization.orderSource     = orderSourceType.applepay;
            applepayType       applepay           = new applepayType();
            applepayHeaderType applepayHeaderType = new applepayHeaderType();

            applepayHeaderType.applicationData    = "454657413164";
            applepayHeaderType.ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.publicKeyHash      = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.transactionId      = "1234";
            applepay.header        = applepayHeaderType;
            applepay.data          = "user";
            applepay.signature     = "sign";
            applepay.version       = "1";
            authorization.applepay = applepay;

            wallet wallet = new wallet();

            wallet.walletSourceTypeId = "123";
            wallet.walletSourceType   = walletWalletSourceType.MasterPass;
            authorization.wallet      = wallet;

            authorizationResponse response = litle.Authorize(authorization);

            Assert.AreEqual("Insufficient Funds", response.message);
            Assert.AreEqual("110", response.applepayResponse.transactionAmount);
        }
        public void SimpleSaleWithApplepayAndSecondaryAmountAndWallet()
        {
            var saleObj = new sale();
            saleObj.amount = 110;
            saleObj.secondaryAmount = 50;
            saleObj.litleTxnId = 123456;
            saleObj.orderId = "12344";
            saleObj.orderSource = orderSourceType.ecommerce;
            var applepay = new applepayType();
            var applepayHeaderType = new applepayHeaderType();
            applepayHeaderType.applicationData = "454657413164";
            applepayHeaderType.ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.publicKeyHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.transactionId = "1234";
            applepay.header = applepayHeaderType;
            applepay.data = "user";
            applepay.signature = "sign";
            applepay.version = "1";
            saleObj.applepay = applepay;
            var wallet = new wallet();
            wallet.walletSourceTypeId = "123";
            wallet.walletSourceType = walletWalletSourceType.MasterPass;
            saleObj.wallet = wallet;

            var responseObj = litle.Sale(saleObj);
            Assert.AreEqual("Insufficient Funds", responseObj.message);
            Assert.AreEqual("110", responseObj.applepayResponse.transactionAmount);
        }
        public void SimpleSaleWithApplepayAndSecondaryAmountAndWallet()
        {
            var saleObj = new sale();

            saleObj.amount          = 110;
            saleObj.secondaryAmount = 50;
            saleObj.litleTxnId      = 123456;
            saleObj.orderId         = "12344";
            saleObj.orderSource     = orderSourceType.ecommerce;
            var applepay           = new applepayType();
            var applepayHeaderType = new applepayHeaderType();

            applepayHeaderType.applicationData    = "454657413164";
            applepayHeaderType.ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.publicKeyHash      = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.transactionId      = "1234";
            applepay.header    = applepayHeaderType;
            applepay.data      = "user";
            applepay.signature = "sign";
            applepay.version   = "1";
            saleObj.applepay   = applepay;
            var wallet = new wallet();

            wallet.walletSourceTypeId = "123";
            wallet.walletSourceType   = walletWalletSourceType.MasterPass;
            saleObj.wallet            = wallet;

            var responseObj = litle.Sale(saleObj);

            Assert.AreEqual("Insufficient Funds", responseObj.message);
            Assert.AreEqual("110", responseObj.applepayResponse.transactionAmount);
        }
示例#4
0
        public void TestApplepayAndWallet()
        {
            var sale = new sale {applepay = new applepayType()};
            var applepayHeaderType = new applepayHeaderType
            {
                applicationData = "454657413164",
                ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
                publicKeyHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
                transactionId = "1234"
            };
            sale.applepay.header = applepayHeaderType;
            sale.applepay.data = "user";
            sale.applepay.signature = "sign";
            sale.applepay.version = "1";
            sale.orderId = "12344";
            sale.amount = 2;
            sale.orderSource = orderSourceType.ecommerce;
            var wallet = new wallet {walletSourceTypeId = "123"};
            sale.wallet = wallet;

            var mock = new Mock<Communications>();

            mock.Setup(communications => communications.HttpPost(It.IsRegex(".*?<litleOnlineRequest.*?<sale.*?<applepay>.*?<data>user</data>.*?</applepay>.*?<walletSourceTypeId>123</walletSourceTypeId>.*?</wallet>.*?</sale>.*?", RegexOptions.Singleline), It.IsAny<Dictionary<string, string>>()))
                .Returns("<litleOnlineResponse version='9.10' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><saleResponse><litleTxnId>123</litleTxnId></saleResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;
            _litle.setCommunication(mockedCommunication);
            _litle.Sale(sale);
        }
示例#5
0
        static void Main(string[] args)
        {
            Men.Watches w = new Men.Watches();

            wallet w1 = new wallet();

            shirt s = new shirt();
        }
示例#6
0
 public decimal AddWallet(User use, long many)
 {
     using (var context = new SteamContext())
     {
         wallet  wallet     = new wallet();
         decimal walletMamy = wallet.balance += many;
         return(walletMamy);
     }
 }
示例#7
0
        public String SignUp(VMSignup model)
        {
            List <Customer> lstCustomer = CustomerManager.GetCustomer(" EMAIL = '" + model.Email + "' OR CUSTUSERNAME='******'", null);

            if (lstCustomer.Count > 0)
            {
                return("An account already exists with the given Email/UserName");
            }


            Customer objcustomer = new Customer();

            objcustomer.EMAIL        = model.Email;
            objcustomer.PASSWORD     = model.Password;
            objcustomer.CUSTUSERNAME = model.Username;
            objcustomer.CUSTNAME     = model.FullName;

            MySqlConnection conn = Shared.BaseManager.PrimaryConnection();

            // MySqlConnection conn = new MySqlConnection("server=132.148.68.125;user id=testusr; password=Testusr123!@#; database=testdatabase");

            conn.Open();
            var    transaction = conn.BeginTransaction();
            string ret         = CustomerManager.SaveCustomer(objcustomer, conn, transaction);

            if (!ret.Equals(Shared.Constants.MSG_ERR_DBSAVE.Text))
            {
                objcustomer.CUSTID = int.Parse(ret);
                wallet objwallet = new wallet();
                objwallet.CUSTOMERID = objcustomer.CUSTID;
                objwallet.BALANCE    = 0;
                ret = walletManager.Savewallet(objwallet, conn, transaction);
                if (!ret.Equals(Shared.Constants.MSG_ERR_DBSAVE.Text))
                {
                    transaction.Commit();
                    conn.Close();
                    conn.Dispose();

                    string token = "success";
                    //string _token = (string)getVerificationURL(objcustomer);

                    return(token /*sendEmail(userobj.EMAIL, _token)*/);
                }
            }
            transaction.Rollback();
            conn.Close();
            conn.Dispose();
            return(Shared.Constants.MSG_ERR_SERVER.Text);
        }
        public void TestMethodOfPaymentApplepayAndWallet()
        {
            var auth = new authorization();

            auth.orderId     = "12344";
            auth.amount      = 2;
            auth.orderSource = orderSourceType.applepay;
            auth.reportGroup = "Planets";
            var applepay           = new applepayType();
            var applepayHeaderType = new applepayHeaderType();

            applepayHeaderType.applicationData    = "454657413164";
            applepayHeaderType.ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.publicKeyHash      = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.transactionId      = "1234";
            applepay.header    = applepayHeaderType;
            applepay.data      = "user";
            applepay.signature = "sign";
            applepay.version   = "1";
            auth.applepay      = applepay;

            var wallet = new wallet();

            wallet.walletSourceTypeId = "123";
            auth.wallet = wallet;

            var mock = new Mock <Communications>(_memoryStreams);

            mock.Setup(
                Communications =>
                Communications.HttpPost(
                    It.IsRegex(
                        ".*?<litleOnlineRequest.*?<authorization.*?<orderSource>applepay</orderSource>.*?<applepay>.*?<data>user</data>.*?</applepay>.*?<wallet>.*?<walletSourceTypeId>123</walletSourceTypeId>.*?</wallet>.*?</authorization>.*?",
                        RegexOptions.Singleline), It.IsAny <Dictionary <string, string> >()))
            .Returns(
                "<litleOnlineResponse version='8.10' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId></authorizationResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;

            litle.setCommunication(mockedCommunication);
            var authorizationResponse = litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }
示例#9
0
        public string DepositAmount(string id, int amount)
        {
            string        ret       = "";
            List <wallet> lstWallet = walletManager.Getwallet("WALLETID='" + id + "'", null);

            if (lstWallet.Count <= 0)
            {
                ret = "Incorrect Wallet ID";
            }

            transactionWallet objtrans = new transactionWallet();

            objtrans.CUSTID            = lstWallet.First().CUSTOMERID;
            objtrans.TRANSACTIONDATE   = DateTime.Now;
            objtrans.TRANSACTIONAMOUNT = amount;

            wallet objwallet = new wallet();

            objwallet.CUSTOMERID = lstWallet.First().CUSTOMERID;
            objwallet.WALLETID   = int.Parse(id);
            objwallet.BALANCE    = lstWallet.First().BALANCE + amount;
            MySqlConnection conn = Shared.BaseManager.PrimaryConnection();

            conn.Open();
            var transaction = conn.BeginTransaction();

            ret = transactionManager.Savetransaction(objtrans, conn, transaction);
            if (!ret.Equals(FoodOrder.Shared.Constants.MSG_ERR_DBSAVE.Text))
            {
                ret = walletManager.Savewallet(objwallet, null, transaction);
                if (ret.Equals(FoodOrder.Shared.Constants.MSG_OK_DBSAVE.Text))
                {
                    transaction.Commit();
                    conn.Close();
                    conn.Dispose();
                    ret = "Success";
                    return(FoodOrder.Shared.Constants.MSG_SUCCESS.Text);
                }
            }
            transaction.Rollback();
            conn.Close();
            conn.Dispose();
            return(Shared.Constants.MSG_ERR_SERVER.Text);
        }
示例#10
0
        public void TestApplepayAndWallet()
        {
            var sale = new sale();

            sale.applepay = new applepayType();
            var applepayHeaderType = new applepayHeaderType();

            applepayHeaderType.applicationData    = "454657413164";
            applepayHeaderType.ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.publicKeyHash      = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.transactionId      = "1234";
            sale.applepay.header    = applepayHeaderType;
            sale.applepay.data      = "user";
            sale.applepay.signature = "sign";
            sale.applepay.version   = "1";
            sale.orderId            = "12344";
            sale.amount             = 2;
            sale.orderSource        = orderSourceType.ecommerce;
            var wallet = new wallet();

            wallet.walletSourceTypeId = "123";
            sale.wallet = wallet;

            var mock = new Mock <Communications>(_memoryStreams);

            ;

            mock.Setup(
                Communications =>
                Communications.HttpPost(
                    It.IsRegex(
                        ".*?<litleOnlineRequest.*?<sale.*?<applepay>.*?<data>user</data>.*?</applepay>.*?<walletSourceTypeId>123</walletSourceTypeId>.*?</wallet>.*?</sale>.*?",
                        RegexOptions.Singleline), It.IsAny <Dictionary <string, string> >()))
            .Returns(
                "<litleOnlineResponse version='8.14' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><saleResponse><litleTxnId>123</litleTxnId></saleResponse></litleOnlineResponse>");

            var mockedCommunication = mock.Object;

            litle.setCommunication(mockedCommunication);
            litle.Sale(sale);
        }
示例#11
0
        public void simpleAuthWithApplepayAndSecondaryAmountAndWallet()
        {
            authorization authorization = new authorization();
            authorization.reportGroup = "Planets";
            authorization.orderId = "123456";
            authorization.amount = 110;
            authorization.secondaryAmount = 50;
            authorization.orderSource = orderSourceType.applepay;
            applepayType applepay = new applepayType();
            applepayHeaderType applepayHeaderType = new applepayHeaderType();
            applepayHeaderType.applicationData = "454657413164";
            applepayHeaderType.ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.publicKeyHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.transactionId = "1234";
            applepay.header = applepayHeaderType;
            applepay.data = "user";
            applepay.signature = "sign";
            applepay.version = "1";
            authorization.applepay = applepay;

            wallet wallet = new wallet();
            wallet.walletSourceTypeId = "123";
            wallet.walletSourceType = walletWalletSourceType.MasterPass;
            authorization.wallet = wallet;

            authorizationResponse response = litle.Authorize(authorization);
            Assert.AreEqual("Insufficient Funds", response.message);
            Assert.AreEqual("110", response.applepayResponse.transactionAmount);
        }
示例#12
0
        public string check(string paymentmethod)
        {
            foodorder objOrder = new foodorder();

            objOrder.ORDERDATE     = DateTime.Now;
            objOrder.CUSTID        = GetSessionUser().CUSTID;
            objOrder.PAYMENTMETHOD = paymentmethod;
            int amount = 0;

            foreach (var item in GetSessionCart())
            {
                amount += item.subtotal;
            }
            objOrder.AMOUNT = amount;
            orderdetails    objOrderDetails = new orderdetails();
            MySqlConnection conn            = Shared.BaseManager.PrimaryConnection();

            conn.Open();
            var transaction = conn.BeginTransaction();

            string ret = foodorderManager.Savefoodorder(objOrder, conn, transaction);
            int    orderid;

            if (!ret.Equals(Shared.Constants.MSG_ERR_DBSAVE.Text))
            {
                orderid = int.Parse(ret);
                foreach (var item in GetSessionCart())
                {
                    if (!ret.Equals(Shared.Constants.MSG_ERR_DBSAVE.Text))
                    {
                        objOrderDetails.ORDERID  = orderid;
                        objOrderDetails.ITEMID   = item.ITEMID;
                        objOrderDetails.QUANTITY = item.QUANTITY;
                        ret = orderdetailsManager.Saveorderdetails(objOrderDetails, conn, transaction);
                    }
                }
                if (paymentmethod == "Wallet")
                {
                    wallet        objwallet = new wallet();
                    List <wallet> lstwallet = walletManager.Getwallet("CustomerID='" + GetSessionUser().CUSTID + "'");

                    if (lstwallet.First().BALANCE > amount)
                    {
                        objwallet.WALLETID   = lstwallet.First().WALLETID;
                        objwallet.CUSTOMERID = GetSessionUser().CUSTID;
                        objwallet.BALANCE    = lstwallet.First().BALANCE - amount;
                        ret = walletManager.Savewallet(objwallet, conn, transaction);
                    }
                    else
                    {
                        ret = "insufficient amount in wallet";
                        transaction.Rollback();
                        conn.Close();
                        conn.Dispose();
                        return(ret);
                    }
                }
                else if (paymentmethod == "MasterCard")
                {
                }
                if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                {
                    payment objpayment = new payment();
                    objpayment.ORDERID     = orderid;
                    objpayment.PAYMENTDATE = DateTime.Now;
                    ret = paymentManager.Savepayment(objpayment, conn, transaction);
                }

                if (ret.Equals(Shared.Constants.MSG_OK_DBSAVE.Text))
                {
                    transaction.Commit();
                    conn.Close();
                    conn.Dispose();

                    return(Shared.Constants.MSG_SUCCESS.Text);
                }
            }

            transaction.Rollback();
            conn.Close();
            conn.Dispose();
            return(Shared.Constants.MSG_ERR_SERVER.Text);
        }
        public async Task <IActionResult> register([FromBody] RegisterUser RUser)
        {
            if (!services.checkExist(RUser.userName, RUser.userPassword))
            {//没有该账号密码存在
                //创建user
                var user = new users {
                };
                user.u_id        = (services.getUserNum() + 1).ToString();
                user.u_name      = RUser.userName;
                user.u_password  = RUser.userPassword;
                user.u_status    = "AC";
                user.u_type      = "US";
                user.create_time = DateTime.Now;
                context.users.Add(user);
                await context.SaveChangesAsync();

                //添加用户数
                var tableCount = context.tableCount.Find(1);
                tableCount.users += 1;
                context.tableCount.Attach(tableCount);
                context.SaveChanges();
                //创建相应userInfo
                var newUserInfo = new userInfo
                {
                    u_id         = user.u_id,
                    u_name       = user.u_name,
                    birthday     = Convert.ToDateTime("1800-01-01 00:00:00"),
                    mail         = RUser.Email,
                    phone_number = "0",
                    message      = ""
                };
                context.userInfo.Add(newUserInfo);
                await context.SaveChangesAsync();

                //创建相应钱包
                var newUserWallet = new wallet
                {
                    u_id        = user.u_id,
                    buy_num     = 0,
                    coin        = 0,
                    publish_num = 0
                };
                context.wallet.Add(newUserWallet);
                await context.SaveChangesAsync();

                //完成了注册赋予Token
                var token = services.GetToken(
                    new LoginUser {
                    userName = user.u_name, userPassword = user.u_password
                });
                return(Ok(new
                {
                    Success = true,
                    userId = user.u_id,
                    userName = user.u_name,
                    Token = token,
                    msg = "New User Registered"
                }));
            }
            else
            {//已有该账号密码存在
                return(Ok(new
                {
                    Success = false,
                    msg = "Same UserName&Password"
                }));
            }
        }
        public void TestMethodOfPaymentApplepayAndWallet()
        {
            authorization auth = new authorization();
            auth.orderId = "12344";
            auth.amount = 2;
            auth.orderSource = orderSourceType.applepay;
            auth.reportGroup = "Planets";
            applepayType applepay = new applepayType();
            applepayHeaderType applepayHeaderType = new applepayHeaderType();
            applepayHeaderType.applicationData = "454657413164";
            applepayHeaderType.ephemeralPublicKey = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.publicKeyHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
            applepayHeaderType.transactionId = "1234";
            applepay.header = applepayHeaderType;
            applepay.data = "user";
            applepay.signature = "sign";
            applepay.version = "1";
            auth.applepay = applepay;

            wallet wallet = new wallet();
            wallet.walletSourceTypeId = "123";
            auth.wallet = wallet;

            var mock = new Mock<Communications>();

            mock.Setup(Communications => Communications.HttpPost(It.IsRegex(".*?<litleOnlineRequest.*?<authorization.*?<orderSource>applepay</orderSource>.*?<applepay>.*?<data>user</data>.*?</applepay>.*?<wallet>.*?<walletSourceTypeId>123</walletSourceTypeId>.*?</wallet>.*?</authorization>.*?", RegexOptions.Singleline), It.IsAny<Dictionary<String, String>>()))
                .Returns("<litleOnlineResponse version='8.10' response='0' message='Valid Format' xmlns='http://www.litle.com/schema'><authorizationResponse><litleTxnId>123</litleTxnId></authorizationResponse></litleOnlineResponse>");

            Communications mockedCommunication = mock.Object;
            litle.setCommunication(mockedCommunication);
            authorizationResponse authorizationResponse = litle.Authorize(auth);

            Assert.NotNull(authorizationResponse);
            Assert.AreEqual(123, authorizationResponse.litleTxnId);
        }