Exemplo n.º 1
0
        public connect_fixture()
        {
            var accountService       = new StripeAccountService(Cache.ApiKey);
            var accountCreateOptions = new StripeAccountCreateOptions
            {
                DefaultCurrency = "usd",
                Email           = "*****@*****.**",
                Type            = StripeAccountType.Custom
            };

            Account = accountService.Create(accountCreateOptions);

            var chargeService = new StripeChargeService(Cache.ApiKey);

            chargeService.ExpandApplication    = true;
            chargeService.ExpandApplicationFee = true;
            Charge = chargeService.Create(
                new StripeChargeCreateOptions
            {
                SourceTokenOrExistingSourceId = "tok_visa",
                ApplicationFee = 10,
                Amount         = 100,
                Currency       = "usd"
            },
                new StripeRequestOptions
            {
                StripeConnectAccountId = Account.Id
            }
                );

            var applicationFeeService = new StripeApplicationFeeService(Cache.ApiKey);

            applicationFeeService.ExpandApplication = true;
            ApplicationFee = applicationFeeService.Get(Charge.ApplicationFeeId);
        }
        public StripeAccountServiceTest()
        {
            this.service = new StripeAccountService();

            this.createOptions = new StripeAccountCreateOptions
            {
                Type = StripeAccountType.Custom,
                ExternalCardAccount = new StripeAccountCardOptions()
                {
                    TokenId = "tok_visa_debit"
                },
                LegalEntity = new StripeAccountLegalEntityOptions
                {
                    AdditionalOwners = new List <StripeAccountAdditionalOwner>
                    {
                        new StripeAccountAdditionalOwner
                        {
                            FirstName                = "John",
                            LastName                 = "Doe",
                            BirthDay                 = 1,
                            BirthMonth               = 1,
                            BirthYear                = 1980,
                            VerificationDocument     = "file_123",
                            VerificationDocumentBack = "file_234",
                        },
                        new StripeAccountAdditionalOwner
                        {
                            FirstName  = "Jenny",
                            LastName   = "Rosen",
                            State      = "CA",
                            CityOrTown = "City",
                            Line1      = "Line1",
                            Line2      = "Line2",
                            PostalCode = "90210",
                            Country    = "US",
                        }
                    },
                    VerificationDocumentFileId     = "file_abc",
                    VerificationDocumentFileBackId = "file_bcd",
                }
            };

            this.updateOptions = new StripeAccountUpdateOptions()
            {
                Metadata = new Dictionary <string, string>()
                {
                    { "key", "value" },
                },
            };

            this.rejectOptions = new StripeAccountRejectOptions
            {
                Reason = "terms_of_service"
            };

            this.listOptions = new StripeAccountListOptions()
            {
                Limit = 1,
            };
        }
        public virtual StripeAccount Create(StripeAccountCreateOptions createOptions)
        {
            var url = this.ApplyAllParameters(createOptions, Urls.Accounts, false);

            var response = Requestor.PostString(url, ApiKey);

            return Mapper<StripeAccount>.MapFromJson(response);
        }
Exemplo n.º 4
0
        public virtual StripeAccount Create(StripeAccountCreateOptions createOptions, StripeRequestOptions requestOptions = null)
        {
            requestOptions = SetupRequestOptions(requestOptions);

            var url = this.ApplyAllParameters(createOptions, Urls.Accounts, false);

            var response = Requestor.PostString(url, requestOptions);

            return(Mapper <StripeAccount> .MapFromJson(response));
        }
        public virtual StripeAccount Create(StripeAccountCreateOptions createOptions, StripeRequestOptions requestOptions = null)
        {
            requestOptions = SetupRequestOptions(requestOptions);

            var url = this.ApplyAllParameters(createOptions, Urls.Accounts, false);

            var response = Requestor.PostString(url, requestOptions);

            return Mapper<StripeAccount>.MapFromJson(response);
        }
        public when_deleting_an_account()
        {
            _stripeAccountService       = new StripeAccountService(Cache.ApiKey);
            _stripeAccountCreateOptions = new StripeAccountCreateOptions()
            {
                Email = "joe@" + Guid.NewGuid() + ".com",
                Type  = StripeAccountType.Custom
            };
            _stripeAccountId = _stripeAccountService.Create(_stripeAccountCreateOptions).Id;

            _stripeAccountService.Delete(_stripeAccountId);
        }
        public static StripeAccountCreateOptions ValidUser(string countryCode = null, string email = null, string ip = null)
        {
            var accountCreateOptions = new StripeAccountCreateOptions
            {
                Country = countryCode ??"US",
                Email = email??"*****@*****.**",
                TosAcceptanceIp = ip??"2.168.0.1",
                Managed = "true",
                TosAcceptanceDate = DateTime.Now.Ticks
            };

            return accountCreateOptions;
        }
Exemplo n.º 8
0
        public void SerializeAdditionalOwnersProperly()
        {
            var options = new StripeAccountCreateOptions
            {
                LegalEntity = new StripeAccountLegalEntityOptions
                {
                    AdditionalOwners = new List <StripeAccountAdditionalOwner>()
                },
            };

            var url = this.service.ApplyAllParameters(options, string.Empty, false);

            Assert.Equal("?legal_entity[additional_owners]=", url);
        }
 public static string CreateStripeAccount(string email, string country)
 {
     try
     {
         var stripekey = ConfigurationManager.AppSettings["AdminStripeApiKey"];
         StripeConfiguration.SetApiKey(stripekey);
         var accountOptions = new StripeAccountCreateOptions()
         {
             Email   = email,
             Type    = StripeAccountType.Standard,
             Country = country
         };
         var accountService = new StripeAccountService();
         var account        = accountService.Create(accountOptions);
         return(account.Id);
     }
     catch (Exception ex)
     {
         Common.ExcepLog(ex);
         return(string.Empty);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Gets a managed account. If one is not available, it will be created.
        /// </summary>
        public static StripeAccount GetManagedAccount()
        {
            if (ManagedAccount != null)
            {
                return(ManagedAccount);
            }

            ManagedAccountCreateOptions = new StripeAccountCreateOptions
            {
                BusinessName              = "Subtracts",
                BusinessPrimaryColor      = "#" + new Random().Next(0, 6).ToString("D6"),
                BusinessUrl               = "http://subtracts.io",
                DebitNegativeBalances     = true,
                DeclineChargeOnAvsFailure = false,
                DeclineChargeOnCvcFailure = true,
                DefaultCurrency           = "usd",
                Email               = $"*****@*****.**",
                Managed             = true,
                ExternalCardAccount = new StripeAccountCardOptions()
                {
                    AddressCountry     = "US",
                    AddressLine1       = "24 Main St",
                    AddressLine2       = "Apt 24",
                    AddressCity        = "Raleigh",
                    AddressState       = "NC",
                    AddressZip         = "27617",
                    Cvc                = "1223",
                    ExpirationMonth    = "10",
                    ExpirationYear     = "2021",
                    Name               = "Julius Turing",
                    Number             = "4000056655665556",
                    Currency           = "usd",
                    DefaultForCurrency = true
                }
            };

            return(ManagedAccount = new StripeAccountService(ApiKey).Create(ManagedAccountCreateOptions));
        }
Exemplo n.º 11
0
        public AccountPayment CreateAccount(IlevusUser user)
        {
            var accountLocal = Mapper.Map <AccountPayment>(user);
            var legalPayment = Mapper.Map <StripeAccountLegalEntityOptions>(accountLocal);

            var accountOptions = new StripeAccountCreateOptions()
            {
                Email           = accountLocal.Email,
                Type            = StripeAccountType.Custom,
                Country         = accountLocal.Country,
                DefaultCurrency = accountLocal.DefaultCurrency,
                TransferScheduleWeeklyAnchor = "monday",
                TransferScheduleInterval     = "weekly",
                TosAcceptanceDate            = DateTime.Now,
                TosAcceptanceIp = GetLocalIPAddress(),
                LegalEntity     = legalPayment
            };

            StripeAccount account = accountService.Create(accountOptions);

            user.Professional.AccountPayment = Mapper.Map <AccountPayment>(account);

            return(Mapper.Map <AccountPayment>(account));
        }
Exemplo n.º 12
0
        public account_fixture()
        {
            // create a file to attach to the additional owner as a verification document
            var fileService = new StripeFileUploadService(Cache.ApiKey);
            var fileStream  = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.Xunit._resources.bumble.jpg");
            var file        = fileService.Create("bumble.jpg", fileStream, StripeFilePurpose.IdentityDocument);

            AccountCreateOptions = new StripeAccountCreateOptions
            {
                BusinessName              = "Subtracts",
                BusinessPrimaryColor      = "#" + new Random().Next(0, 6).ToString("D6"),
                BusinessUrl               = "http://subtracts.io",
                DebitNegativeBalances     = true,
                DeclineChargeOnAvsFailure = false,
                DeclineChargeOnCvcFailure = true,
                DefaultCurrency           = "usd",
                Email               = "*****@*****.**",
                Managed             = true,
                ExternalCardAccount = new StripeAccountCardOptions()
                {
                    AddressCountry     = "US",
                    AddressLine1       = "24 Main St",
                    AddressLine2       = "Apt 24",
                    AddressCity        = "Raleigh",
                    AddressState       = "NC",
                    AddressZip         = "27617",
                    Cvc                = "1223",
                    ExpirationMonth    = "10",
                    ExpirationYear     = "2021",
                    Name               = "Julius Turing",
                    Number             = "4000056655665556",
                    Currency           = "usd",
                    DefaultForCurrency = true
                },
                LegalEntity = new StripeAccountLegalEntityOptions
                {
                    AdditionalOwners = new List <StripeAccountAdditionalOwner>
                    {
                        new StripeAccountAdditionalOwner
                        {
                            FirstName            = "Bumble", LastName = "B",
                            BirthDay             = 29, BirthMonth = 8, BirthYear = 2013,
                            VerificationDocument = file.Id
                        },
                        new StripeAccountAdditionalOwner
                        {
                            FirstName = "Trouble", LastName = "China",
                            State     = "CA", CityOrTown = "RockAndWheat",
                            Line1     = "B", Line2 = "C", PostalCode = "27635",
                            Country   = "US"
                        }
                    }
                }
            };

            AccountUpdateOptions = new StripeAccountUpdateOptions
            {
                BusinessUrl = "https://subtracts.io"
            };

            var service = new StripeAccountService(Cache.ApiKey);

            Account          = service.Create(AccountCreateOptions);
            AccountUpdated   = service.Update(Account.Id, AccountUpdateOptions);
            AccountRetrieved = service.Get(Account.Id);
            AccountList      = service.List();
        }
Exemplo n.º 13
0
        public account_fixture()
        {
            // create a file to attach to the additional owner as a verification document
            var fileService = new StripeFileUploadService(Cache.ApiKey);
            var fileStream  = GetType().GetTypeInfo().Assembly.GetManifestResourceStream("Stripe.Tests.XUnit._resources.bumble.jpg");
            var file        = fileService.Create("bumble.jpg", fileStream, StripeFilePurpose.IdentityDocument);

            AccountCreateOptions = new StripeAccountCreateOptions
            {
                BusinessName              = "Subtracts",
                BusinessPrimaryColor      = "#" + new Random().Next(0, 6).ToString("D6"),
                BusinessUrl               = "http://subtracts.io",
                DebitNegativeBalances     = true,
                DeclineChargeOnAvsFailure = false,
                DeclineChargeOnCvcFailure = true,
                DefaultCurrency           = "usd",
                Email = "*****@*****.**",
                Type  = StripeAccountType.Custom,
                ExternalCardAccount = new StripeAccountCardOptions()
                {
                    TokenId = "tok_visa_debit"
                },
                LegalEntity = new StripeAccountLegalEntityOptions
                {
                    AdditionalOwners = new List <StripeAccountAdditionalOwner>
                    {
                        new StripeAccountAdditionalOwner
                        {
                            FirstName = "Bumble", LastName = "B",
                            // Ensure the owner is older than 18 to avoid API issues.
                            BirthDay             = 29, BirthMonth = 8, BirthYear = 1980,
                            VerificationDocument = file.Id
                        },
                        new StripeAccountAdditionalOwner
                        {
                            FirstName = "Trouble", LastName = "China",
                            State     = "CA", CityOrTown = "RockAndWheat",
                            Line1     = "B", Line2 = "C", PostalCode = "27635",
                            Country   = "US"
                        }
                    }
                }
            };

            AccountUpdateOptions = new StripeAccountUpdateOptions
            {
                BusinessUrl = "https://subtracts.io"
            };

            var _rejectOptions = new StripeAccountRejectOptions
            {
                Reason = "terms_of_service"
            };

            var service = new StripeAccountService(Cache.ApiKey);

            Account          = service.Create(AccountCreateOptions);
            AccountUpdated   = service.Update(Account.Id, AccountUpdateOptions);
            AccountRetrieved = service.Get(Account.Id);
            AccountList      = service.List();
            AccountRejected  = service.Reject(Account.Id, _rejectOptions);
        }