Esempio n. 1
0
        public void CreateCharge_Card_Test()
        {
            dynamic response = _client.CreateCharge(100M, "usd", _card);

            Assert.NotNull(response);
            Assert.False(response.IsError);
            Assert.True(response.Paid);
        }
Esempio n. 2
0
        public void CreateCharge_Card_Test()
        {
            dynamic response = _client.CreateCharge(200M, "usd", _card);

            Assert.NotNull(response);
            Assert.False(response.IsError);
            Assert.True(response.Paid);
            Console.Write("yes money " + response);
        }
Esempio n. 3
0
        public void Create_Refund_Card_Charge_Test()
        {
            dynamic charge = _client.CreateCharge(100M, "usd", _card);

            dynamic response = _client.CreateRefund(charge.Id);

            Assert.NotNull(response);
            Assert.False(response.IsError);
            Assert.Equal(charge.Id, response.charge);
            Assert.NotNull(response.balance_transaction);
        }
Esempio n. 4
0
        public static void Main()
        {
            var apiKey = "Your API Key";             // can be found here https://manage.stripe.com/#account/apikeys
            var api    = new StripeClient(apiKey);   // you can learn more about the api here https://stripe.com/docs/api

            var card = new CreditCard {
                Number   = "4111111111111111",
                ExpMonth = 3,
                ExpYear  = 2015
            };

            dynamic response = api.CreateCharge(
                amount: 10000,                 // $100
                currency: "usd",
                card: card);

            if (response.Paid)
            {
                Console.WriteLine("Whoo Hoo...  We made our first sale!");
            }
            else
            {
                Console.WriteLine("Payment failed. :(");
            }

            Console.Read();
        }
Esempio n. 5
0
        public void SecurityCharge_Test()
        {
            _client = new StripeClient(Constants.ApiKey, null, "https://api-tls12.stripe.com/");
            dynamic response = _client.CreateCharge(100M, "usd", _customer.Id);

            Assert.NotNull(response);
            Assert.False(response.IsError);
        }
Esempio n. 6
0
        public ActionResult CompleteCheckout()
        {
            if (User.Identity.IsAuthenticated)
            {
                var packageId = Convert.ToInt32(Request.Form["packageId"]);
                var package   = packageRepository.FindPackageById(packageId);
                var user      = userRepository.FindUserByEmail(User.Identity.Name);

                var api   = new StripeClient("2JeZdhBfTR4b1pMH4d9O0S58YtalPDbf");
                var token = Request.Form["stripeToken"];

                var     creditCard = new CreditCardToken(token);
                dynamic response   = api.CreateCharge(package.Costo, "usd", creditCard);

                if (response.Paid)
                {
                    // Give the user the amount of lances in his bought package.
                    user.LanceCreditBalance += package.CreditAmount;
                    userRepository.SaveChanges();

                    // Save a record of the purchase of the package.
                    BoughtPackage boughtPackage = new BoughtPackage();
                    boughtPackage.DateOfPurchase = DateTime.Now;
                    boughtPackage.UserId         = user.UserId;
                    boughtPackage.LancePackageId = package.LancePackageId;
                    boughtPackage.Total          = package.Costo;
                    packageRepository.CreateNewPackagePurchase(boughtPackage);
                    packageRepository.SaveChanges();

                    // Redirect to purchase complete page.
                    return(RedirectToAction("PurchaseComplete", "Shop"));
                }
                else
                {
                    return(RedirectToAction("BuyLances", "Shop"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Esempio n. 7
0
        public void SecurityCharge_Test()
        {
            _client = new StripeClient(Constants.ApiKey, null, "https://api-tls12.stripe.com/");
            dynamic response = _client.CreateCharge(100M, "usd", _customer.Id);

            Assert.NotNull(response);
            Assert.False(response.IsError);
        }