public void CouponCreateArguments_GetAllKeys()
        {
            // Arrange
            _args.AmountOff        = 1;
            _args.DurationInMonths = 12;
            _args.MaxRedemptions   = 1;
            _args.Metadata         = Data.Metadata;
            _args.PercentOff       = 10;
            _args.RedeemBy         = DateTime.UtcNow;

            var epoch = _args.RedeemBy.Value.ToEpoch().ToString();

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(10)
            .And.Contain(x => x.Key == "duration")
            .And.Contain(x => x.Key == "amount_off")
            .And.Contain(x => x.Key == "currency")
            .And.Contain(x => x.Key == "amount_off")
            .And.Contain(x => x.Key == "duration_in_months")
            .And.Contain(x => x.Key == "max_redemptions")
            .And.Contain(x => x.Key == "metadata[key1]")
            .And.Contain(x => x.Key == "metadata[key2]")
            .And.Contain(x => x.Key == "percent_off")
            .And.Contain(x => x.Key == "redeem_by" && x.Value == epoch);
        }
Esempio n. 2
0
        private static void Main(string[] args)
        {
            var apiKey = "";
            var stripe = new StripeClient(apiKey);

            var chargeService = new ChargeService(stripe);
            var chargeId      = "";
            var charge        = chargeService.Get(chargeId);

            Console.WriteLine("Charge");
            Console.WriteLine($"Amount: ${charge.Amount}");

            var payoutService = new PayoutService(stripe);
            var payoutId      = "";
            var payout        = payoutService.Get(payoutId);

            Console.WriteLine($"Payout: {payoutId}");
            Console.WriteLine($"Date Paid: {payout.ArrivalDate.ToString()}");


            var balanceTransactionService = new BalanceTransactionService(stripe);
            var requestOptions            = new BalanceTransactionListOptions {
                Payout = payoutId, Limit = 100
            };
            var transactionList = balanceTransactionService.List(requestOptions);

            Console.WriteLine($"Transactions: {transactionList.Count()}");
        }
Esempio n. 3
0
        public async Task <string> GetCardToken(string cardName, string cardNumber, int expiryMonth, int expiryYear, string cvc)
        {
            var card = new Card
            {
                Name        = cardName,
                Number      = cardNumber,
                ExpiryMonth = expiryMonth,
                ExpiryYear  = expiryYear,
                CVC         = cvc
            };

            Console.WriteLine("stripe credit card request params:\n" + card.ToString());

            try
            {
                var token = await StripeClient.CreateToken(card);

                return(token.Id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(null);
        }
Esempio n. 4
0
        public void SkuListFilter_GetAllKeys()
        {
            // Arrange
            _filter.Limit      = 10;
            _filter.Active     = true;
            _filter.InStock    = true;
            _filter.Attributes = new Dictionary <string, string>
            {
                { "color", "red" },
                { "size", "medium" }
            };

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_filter).ToList();

            // Assert
            keyValuePairs.Should().Contain(x => x.Key == "active")
            .And.Contain(x => x.Key == "in_stock")
            .And.Contain(x => x.Key == "product")
            .And.Contain(x => x.Key == "attributes[color]" && x.Value == "red")
            .And.Contain(x => x.Key == "attributes[size]" && x.Value == "medium")
            .And.Contain(x => x.Key == "ending_before")
            .And.Contain(x => x.Key == "starting_after")
            .And.Contain(x => x.Key == "limit")
            .And.HaveCount(8);
        }
        public void PlanCreateArguments_GetAllKeys()
        {
            // Arrange
            _args.Amount              = 1;
            _args.Currency            = "USD";
            _args.Id                  = "Plan Id";
            _args.Interval            = "month";
            _args.IntervalCount       = 1;
            _args.Metadata            = Data.Metadata;
            _args.Name                = "Generic Plan";
            _args.StatementDescriptor = "The descriptor";
            _args.TrialPeriodDays     = 30;

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(10)
            .And.Contain(x => x.Key == "amount")
            .And.Contain(x => x.Key == "currency")
            .And.Contain(x => x.Key == "id")
            .And.Contain(x => x.Key == "interval")
            .And.Contain(x => x.Key == "interval_count")
            .And.Contain(x => x.Key == "metadata[key1]")
            .And.Contain(x => x.Key == "metadata[key2]")
            .And.Contain(x => x.Key == "name")
            .And.Contain(x => x.Key == "statement_descriptor")
            .And.Contain(x => x.Key == "trial_period_days");
        }
Esempio n. 6
0
        public void CardTokenCreateArguments_Card()
        {
            // Arrange
            _args.Card          = GenFu.GenFu.New <CardCreateArguments>();
            _args.Card.ExpMonth = 3;
            _args.Card.ExpYear  = DateTime.UtcNow.Year;

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(13)
            .And.Contain(x => x.Key == "card[address_city]")
            .And.Contain(x => x.Key == "card[address_line1]")
            .And.Contain(x => x.Key == "card[address_line2]")
            .And.Contain(x => x.Key == "card[address_state]")
            .And.Contain(x => x.Key == "card[address_zip]")
            .And.Contain(x => x.Key == "card[currency]")
            .And.Contain(x => x.Key == "card[cvc]")
            .And.Contain(x => x.Key == "card[exp_month]")
            .And.Contain(x => x.Key == "card[exp_year]")
            .And.Contain(x => x.Key == "card[name]")
            .And.Contain(x => x.Key == "card[number]")
            .And.Contain(x => x.Key == "card[object]");
        }
Esempio n. 7
0
        public async Task <string> MakePayment(string apiSecretKey, string currencyCode, double amount,
                                               string cardToken, string description, string memberName)
        {
            StripeClient client = new StripeClient(apiSecretKey);

            PaymentIntentService intentService = new PaymentIntentService(client);
            PaymentIntent        intent        = await intentService.CreateAsync(new PaymentIntentCreateOptions
            {
                Amount      = (int)(amount * 100),
                Currency    = currencyCode.ToLowerInvariant(),
                Description = $"{memberName}: {description}",
                ExtraParams = new Dictionary <string, object>
                {
                    {
                        "payment_method_data", new Dictionary <string, object>
                        {
                            { "type", "card" },
                            {
                                "card", new Dictionary <string, object>
                                {
                                    { "token", cardToken }
                                }
                            }
                        }
                    }
                }
            });

            intent = await intentService.ConfirmAsync(intent.Id);

            return(intent.Id);
        }
        // GET: /<controller>/


        public CustomersController(IConfiguration config)
        {
            // test commit
            customerService = new StripeCustomerService();
            this.client     = new StripeClient("sk_test_4eC39HqLyjWDarjtT1zdp7dc");
            _config         = config;
        }
Esempio n. 9
0
        public void SkuCreateArguments_GetAllKeys()
        {
            // Arrange
            _args.Metadata          = Data.Metadata;
            _args.Inventory         = GenFu.GenFu.New <InventoryArguments>();
            _args.PackageDimensions = GenFu.GenFu.New <PackageDimensions>();

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(14)
            .And.Contain(x => x.Key == "currency")
            .And.Contain(x => x.Key == "image")
            .And.Contain(x => x.Key == "id")
            .And.Contain(x => x.Key == "inventory[quantity]")
            .And.Contain(x => x.Key == "inventory[type]")
            .And.Contain(x => x.Key == "inventory[value]")
            .And.Contain(x => x.Key == "metadata[key1]")
            .And.Contain(x => x.Key == "metadata[key2]")
            .And.Contain(x => x.Key == "package_dimensions[height]")
            .And.Contain(x => x.Key == "package_dimensions[length]")
            .And.Contain(x => x.Key == "package_dimensions[weight]")
            .And.Contain(x => x.Key == "package_dimensions[width]")
            .And.Contain(x => x.Key == "price")
            .And.Contain(x => x.Key == "product");
        }
Esempio n. 10
0
        public void Ctor_RequestOptions()
        {
            var client         = new StripeClient("sk_test_123");
            var requestOptions = new RequestOptions
            {
                ApiKey         = "sk_override",
                IdempotencyKey = "idempotency_key",
                StripeAccount  = "acct_456",
                BaseUrl        = "https://override.example.com",
                StripeVersion  = "2012-12-21",
            };
            var request = new StripeRequest(
                this.stripeClient,
                HttpMethod.Get,
                "/get",
                null,
                requestOptions);

            Assert.Equal(HttpMethod.Get, request.Method);
            Assert.Equal($"{requestOptions.BaseUrl}/get", request.Uri.ToString());
            Assert.Equal($"Bearer {requestOptions.ApiKey}", request.AuthorizationHeader.ToString());
            Assert.True(request.StripeHeaders.ContainsKey("Stripe-Version"));
            Assert.Equal("2012-12-21", request.StripeHeaders["Stripe-Version"]);
            Assert.True(request.StripeHeaders.ContainsKey("Idempotency-Key"));
            Assert.Equal("idempotency_key", request.StripeHeaders["Idempotency-Key"]);
            Assert.True(request.StripeHeaders.ContainsKey("Stripe-Account"));
            Assert.Equal("acct_456", request.StripeHeaders["Stripe-Account"]);
            Assert.Null(request.Content);
        }
Esempio n. 11
0
        public void CardCreateArguments_GetAllKeys()
        {
            // Arrange
            _args.ExpMonth = 2;
            _args.ExpYear  = 2012;
            _args.Metadata = Data.Metadata;

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args, "external_account").ToList();

            // Assert
            keyValuePairs.Should().HaveCount(15)
            .And.Contain(x => x.Key == "external_account[address_city]")
            .And.Contain(x => x.Key == "external_account[address_line1]")
            .And.Contain(x => x.Key == "external_account[address_line2]")
            .And.Contain(x => x.Key == "external_account[address_state]")
            .And.Contain(x => x.Key == "external_account[address_zip]")
            .And.Contain(x => x.Key == "external_account[currency]")
            .And.Contain(x => x.Key == "external_account[cvc]")
            .And.Contain(x => x.Key == "external_account[exp_month]")
            .And.Contain(x => x.Key == "external_account[exp_year]")
            .And.Contain(x => x.Key == "external_account[metadata][key1]")
            .And.Contain(x => x.Key == "external_account[metadata][key2]")
            .And.Contain(x => x.Key == "external_account[name]")
            .And.Contain(x => x.Key == "external_account[number]")
            .And.Contain(x => x.Key == "external_account[object]");
        }
Esempio n. 12
0
        public void NoTelemetryWhenDisabled()
        {
            var mockHandler = new Mock <HttpClientHandler> {
                CallBase = true
            };
            var httpClient = new SystemNetHttpClient(
                new System.Net.Http.HttpClient(mockHandler.Object),
                enableTelemetry: false);
            var stripeClient = new StripeClient("sk_test_123", httpClient: httpClient);

            mockHandler.Reset();
            var fakeServer = FakeServer.ForMockHandler(mockHandler);

            fakeServer.Delay = TimeSpan.FromMilliseconds(20);

            var service = new BalanceService(stripeClient);

            service.Get();
            fakeServer.Delay = TimeSpan.FromMilliseconds(40);
            service.Get();
            service.Get();

            mockHandler.Protected()
            .Verify(
                "SendAsync",
                Times.Exactly(3),
                ItExpr.Is <HttpRequestMessage>(m =>
                                               !m.Headers.Contains("X-Stripe-Client-Telemetry")),
                ItExpr.IsAny <CancellationToken>());
        }
Esempio n. 13
0
        public void Ctor_DoesNotThrowsIfApiKeyIsNull()
        {
            var client = new StripeClient(null);

            Assert.NotNull(client);
            Assert.Null(client.ApiKey);
        }
        public void CustomerUpdateArguments_GetOtherKeys()
        {
            // Arrange
            _args.Metadata                 = Data.Metadata;
            _args.Shipping                 = GenFu.GenFu.New <ShippingArguments>();
            _args.Shipping.Address         = GenFu.GenFu.New <AddressArguments>();
            _args.Shipping.Address.Country = "US";

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(16)
            .And.Contain(x => x.Key == "coupon")
            .And.Contain(x => x.Key == "default_source")
            .And.Contain(x => x.Key == "description")
            .And.Contain(x => x.Key == "email")
            .And.Contain(x => x.Key == "metadata[key1]")
            .And.Contain(x => x.Key == "metadata[key2]")
            .And.Contain(x => x.Key == "shipping[address][city]")
            .And.Contain(x => x.Key == "shipping[address][country]")
            .And.Contain(x => x.Key == "shipping[address][line1]")
            .And.Contain(x => x.Key == "shipping[address][line2]")
            .And.Contain(x => x.Key == "shipping[address][postal_code]")
            .And.Contain(x => x.Key == "shipping[address][state]")
            .And.Contain(x => x.Key == "shipping[address][town]")
            .And.Contain(x => x.Key == "shipping[name]")
            .And.Contain(x => x.Key == "shipping[phone]")
            .And.Contain(x => x.Key == "source");
        }
Esempio n. 15
0
        public decimal?Process(PizzaOrderModel pizzaOrderDto)
        {
            // calculate total
            var total = 10 * pizzaOrderDto.Pizzas.Count;
            //todo: add sales tax
            //todo: enable coupons and specials

            // charge credit card
            var apiKey = "MyPizza API Key";
            var api    = new StripeClient(apiKey);
            var card   = Mapper.Map <CreditCard>(pizzaOrderDto.CreditCard);

            //dynamic response = api.CreateCharge(
            //    total,
            //    "usd", //todo: expand to other currencies
            //    card);

            //todo: credit card processing isn't working yet
            dynamic response = new
            {
                IsError = false,
                Paid    = true
            };

            if (response.IsError || !response.Paid)
            {
                return(null);
            }

            return(total);
        }
Esempio n. 16
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. 17
0
        public async Task <List <StripeTransaction> > GetListOfTransactions()
        {
            var transactions = new List <StripeTransaction>();

            var stripeClient = new StripeClient(appSettings.ApiSecret);

            var options = new ChargeListOptions {
                Limit = 100
            };
            var service = new ChargeService(stripeClient);
            StripeList <Charge> charges = await service.ListAsync(
                options
                );

            return(charges.Data.Select(c => new StripeTransaction()
            {
                Id = c.Id,
                Paid = c.Paid,
                ApplicationFeeAmount = MoneyExtender.ConvertToDollars(c.ApplicationFeeAmount != null ? c.ApplicationFeeAmount.Value : 0),
                Status = c.Status,
                Description = c.Description,
                PaymentType = c.Object,
                AmountRefunded = MoneyExtender.ConvertToDollars(c.AmountRefunded),
                Amount = MoneyExtender.ConvertToDollars(c.Amount),
                Created = c.Created,
                FailureCode = c.FailureCode,
                FailureMessage = c.FailureMessage,
                TotalAmount = MoneyExtender.ConvertToDollars(c.Amount) - MoneyExtender.ConvertToDollars(c.AmountRefunded)
            }).ToList());
        }
        void BeginPayment()
        {
            var merchantId = AppDelegate.APPLE_MERCHANT_ID;

            var paymentRequest = StripeClient.PaymentRequest(merchantId, new NSDecimalNumber("10"), "USD", "Premium Llama Food");

            // Check if we can use apple pay
            if (StripeClient.CanSubmitPaymentRequest(paymentRequest))
            {
                UIViewController paymentController;

                if (AppDelegate.STRIPE_ISTEST)
                {
                    paymentController = StripeClient.TestPaymentController(paymentRequest, this);
                }
                else
                {
                    paymentController = StripeClient.PaymentController(paymentRequest, this);
                }

                PresentViewController(paymentController, true, null);
            }
            else
            {
                // TODO: Non-Apple flow
                var avMsg = new UIAlertView("Todo: Apple Pay Not supported!",
                                            "You need to use a traditional method of collecting credit card information instead!", null, "OK");
                avMsg.Show();
            }
        }
        public void SubscriptionUpdateArguments_GetAllKeys()
        {
            // Arrange
            _args.ApplicationFeePercent = 1;
            _args.Metadata      = Data.Metadata;
            _args.Quantity      = 1;
            _args.TaxPercent    = 8.2m;
            _args.TrialEnd      = DateTime.UtcNow;
            _args.ProrationDate = DateTime.UtcNow;

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(11)
            .And.Contain(x => x.Key == "application_fee_percent")
            .And.Contain(x => x.Key == "coupon")
            .And.Contain(x => x.Key == "prorate")
            .And.Contain(x => x.Key == "proration_date")
            .And.Contain(x => x.Key == "metadata[key1]")
            .And.Contain(x => x.Key == "metadata[key2]")
            .And.Contain(x => x.Key == "plan")
            .And.Contain(x => x.Key == "quantity")
            .And.Contain(x => x.Key == "source")
            .And.Contain(x => x.Key == "tax_percent")
            .And.Contain(x => x.Key == "trial_end");
        }
        async Task HandlePaymentAuthorization(PKPayment payment, Action <PKPaymentAuthorizationStatus> completion, bool isTest = false, bool shouldTestFail = false)
        {
            try {
                Token token = null;

                if (isTest)
                {
                    token = await StripeClient.CreateTestToken(payment, shouldTestFail);
                }
                else
                {
                    token = await StripeClient.CreateToken(payment);
                }

                var msg = string.Format("Good news! Stripe turned your credit card into a token: \n{0} \n\nYou can follow the instructions in the README to set up Parse as an example backend, or use this token to manually create charges at dashboard.stripe.com .",
                                        token.Id);

                var avMsg = new UIAlertView("Todo: Submit this token to your backend", msg, null, "OK");
                avMsg.Show();

                completion(PKPaymentAuthorizationStatus.Success);
            } catch (Exception ex) {
                var avMsg = new UIAlertView("Payment Failed", ex.Message, null, "OK");
                avMsg.Show();
            }
        }
        public async Task GetUriTest()
        {
            // Arrange
            var stripeClient = new StripeClient(null, null);
            var uri          = await stripeClient.GetUri("test", _testModel);

            // Act
            var path = uri.PathAndQuery.Split('?')[0];

            var queryString = HttpUtility.ParseQueryString(uri.Query);

            // Assert
            var match = (from key in queryString.AllKeys
                         join e in _expected on new
            {
                Key = key,
                Value = queryString[key]
            } equals new
            {
                e.Key,
                e.Value
            }
                         select key).ToList();

            path.Should().Be("/v1/test");
            match.Should().HaveCount(_expected.Count());
        }
Esempio n. 22
0
 public ConnectApiController(IStripeConnectService service, ILogger <ConnectApiController> logger, IAuthenticationService <int> authService, IOptions <AppKeys> appKeys) : base(logger)
 {
     _service     = service;
     _authService = authService;
     _appKeys     = appKeys.Value;
     _client      = new StripeClient(_appKeys.StripeApiKey);
 }
Esempio n. 23
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. 24
0
        public StripePaymentService(IOptions <PaymentOptions> options)
        {
            var secretKey    = options.Value.StripeOptions?.SecretKey;
            var stripeClient = new StripeClient(secretKey);

            _customerService = new CustomerService(stripeClient);
            _chargeService   = new ChargeService(stripeClient);
        }
Esempio n. 25
0
 public StripeController(ApplicationDbContext context, UserManager <ApplicationUser> userManager, IConfiguration configuration)
 {
     _context     = context;
     _userManager = userManager;
     // Set your secret key: remember to switch to your live secret key in production
     // See your keys here: https://dashboard.stripe.com/account/apikeys
     _client = new StripeClient(configuration.GetValue <string>("StripeApiKey"));
 }
        public CardTokenTests()
        {
            _card = new CreditCard {
                Number = "4111111111111111",
                ExpMonth = 3,
                ExpYear = 2015
            };

            _client = new StripeClient(Constants.ApiKey);
        }
Esempio n. 27
0
        public void Setup()
        {
            _card = new CreditCardRequest {
                Number   = "4111111111111111",
                ExpMonth = 3,
                ExpYear  = 2015
            };

            _client = new StripeClient(Constants.ApiKey);
        }
Esempio n. 28
0
        public void AccountRejectArguments_GetAllKeys()
        {
            // Arrange

            // Act
            var keyValuePairs = StripeClient.GetModelKeyValuePairs(_args).ToList();

            // Assert
            keyValuePairs.Should().HaveCount(1).And.Contain(x => x.Key == "reason");
        }
Esempio n. 29
0
        public AccountTests()
        {
            _email = Guid.NewGuid().ToString() + "@test.com";
               _managedEmail = Guid.NewGuid().ToString() + "@test.com";
               _newEmail = Guid.NewGuid().ToString() + "@test.com";

            _client = new StripeClient(Constants.ApiKey);
            _account = _client.CreateAccount(false, "US", _email);
            _managedAccount = _client.CreateAccount(true, "US", _managedEmail);
        }
Esempio n. 30
0
        public CustomerTests()
        {
            _card = new CreditCard {
                Number   = "4242424242424242",
                ExpMonth = 3,
                ExpYear  = 2015
            };

            _client = new StripeClient(Constants.ApiKey);
        }
Esempio n. 31
0
        public AccountTests()
        {
            _email        = Guid.NewGuid().ToString() + "@test.com";
            _managedEmail = Guid.NewGuid().ToString() + "@test.com";
            _newEmail     = Guid.NewGuid().ToString() + "@test.com";

            _client         = new StripeClient(Constants.ApiKey);
            _account        = _client.CreateAccount(false, "US", _email);
            _managedAccount = _client.CreateAccount(true, "US", _managedEmail);
        }
Esempio n. 32
0
        public void Setup()
        {
            _card = new CreditCard {
                Number = "4111111111111111",
                ExpMonth = 3,
                ExpYear = 2015
            };

            _client = new StripeClient(Constants.ApiKey);
        }
Esempio n. 33
0
        public void Ctor_ThrowsIfApiKeyIsNull()
        {
            var client         = new StripeClient(null);
            var requestOptions = new RequestOptions();

            var exception = Assert.Throws <StripeException>(() =>
                                                            new StripeRequest(client, HttpMethod.Get, "/get", null, requestOptions));

            Assert.Contains("No API key provided.", exception.Message);
        }
Esempio n. 34
0
        public CustomerTests()
        {
            _card = new CreditCard {
                Number = "4242424242424242",
                ExpMonth = 3,
                ExpYear = 2015
            };

            _client = new StripeClient(Constants.ApiKey);
        }
Esempio n. 35
0
        public CardTokenTests()
        {
            _card = new CreditCard
            {
                Number = "4242424242424242",
                ExpMonth = 3,
                ExpYear = (DateTime.Now.Year + 2)
            };

            _client = new StripeClient(Constants.ApiKey);
        }
Esempio n. 36
0
        public ChargeTests()
        {
            _card = new CreditCard {
                Number = "4242 4242 4242 4242",
                ExpMonth = DateTime.Now.Month,
                ExpYear = DateTime.Now.AddYears(1).Year
            };

            _client = new StripeClient(Constants.ApiKey);
            _customer = _client.CreateCustomer(_card);
        }
Esempio n. 37
0
        public ChargeTests()
        {
            _card = new CreditCard {
                Number = "4242 4242 4242 4242",
                ExpMonth = 3,
                ExpYear = 2015
            };

            _client = new StripeClient(Constants.ApiKey);
            _customer = _client.CreateCustomer(_card);
        }
Esempio n. 38
0
        public void Setup()
        {
            _card = new CreditCardRequest {
                Number = "4111111111111111",
                ExpMonth = 3,
                ExpYear = 2015
            };

            _client = new StripeClient(Constants.ApiKey);
            _customer = _client.CreateCustomer(_card);
        }
Esempio n. 39
0
        public InvoiceTests()
        {
            _card = new CreditCard
            {
                Number = "4242424242424242",
                ExpMonth = 3,
                ExpYear = (DateTime.Now.Year + 2)
            };

            _client = new StripeClient(Constants.ApiKey);
            _customer = _client.CreateCustomer(_card);
        }
        public SubscriptionTests()
        {
            _client = new StripeClient(Constants.ApiKey);

            var id = Guid.NewGuid().ToString();
            var card = new CreditCard {
                Number = "4111111111111111",
                ExpMonth = 3,
                ExpYear = 2015
            };

            _plan = _client.CreatePlan(id, 400M, "usd", PlanFrequency.Month, id);
            _customer = _client.CreateCustomer(card);
        }
Esempio n. 41
0
        public SubscriptionTests()
        {
            _client = new StripeClient(Constants.ApiKey);

            var id = Guid.NewGuid().ToString();
            var card = new CreditCard
            {
                Number = "4242424242424242",
                ExpMonth = 3,
                ExpYear = (DateTime.Now.Year + 2)
            };

            _plan = _client.CreatePlan(id, 400M, "usd", PlanFrequency.Month, id);
            _customer = _client.CreateCustomer(card);
            _subscription = _client.CreateCustomersSubscription(_customer.Id, _plan.Id);
        }
Esempio n. 42
0
        public RecipientTests()
        {
            _name = "sir unit testing";
            _email = "*****@*****.**";
            _type = "individual";

            _card = new CreditCard
            {
                Number = "4000056655665556",
                ExpMonth = 3,
                ExpYear = 2020
            };

            _bankAccount = new BankAccount
            {
                AccountNumber = "000123456789",
                Country = "US",
                Currency = "USD",
                RoutingNumber = "110000000"
            };

            _client = new StripeClient(Constants.ApiKey);
        }
Esempio n. 43
0
 public AccountTests()
 {
     _client = new StripeClient(Constants.ApiKey);
 }
Esempio n. 44
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);
        }
        public void ExpandablesTest()
        {
            // Arrange
            var stripeClient = new StripeClient(null,null);
            stripeClient.Expandables = new List<string> {Expandables.Invoice, Expandables.Customer, Expandables.Charge};

            // Act
            var keys = stripeClient.GetAllKeyValuePairs<object>(null);

            // Assert
            keys.Should()
                .Contain(x => x.Key == "expand[]" && x.Value == "invoice")
                .And.Contain(x => x.Key == "expand[]" && x.Value == "customer")
                .And.Contain(x => x.Key == "expand[]" && x.Value == "charge");
        }
        public async Task GetUriTest()
        {
            // Arrange
            var stripeClient = new StripeClient(null, null);
            var uri = await stripeClient.GetUri("test", _testModel);

            // Act
            var path = uri.PathAndQuery.Split('?')[0];

            var queryString = HttpUtility.ParseQueryString(uri.Query);

            // Assert
            var match = (from key in queryString.AllKeys
                         join e in _expected on new
                         {
                             Key = key,
                             Value = queryString[key]
                         } equals new
                         {
                             e.Key,
                             e.Value
                         }
                         select key).ToList();

            path.Should().Be("/v1/test");
            match.Should().HaveCount(_expected.Count());
        }
Esempio n. 47
0
 public PlanTests()
 {
     _client = new StripeClient(Constants.ApiKey);
 }
Esempio n. 48
0
 public EventTest()
 {
     _client = new StripeClient(Constants.ApiKey);
 }
Esempio n. 49
0
 public OAuthTests()
 {
     _client = new StripeClient(Constants.ApiKey);
 }
Esempio n. 50
0
 public void Setup()
 {
     _client = new StripeClient(Constants.ApiKey);
 }