Exemplo n.º 1
0
        public charging_from_another_account()
        {
            var anotherAccount = new StripeAccountService(Cache.ApiKey).Create(new StripeAccountCreateOptions
            {
                DefaultCurrency = "usd",
                Email           = "*****@*****.**",
                Managed         = true
            }
                                                                               );

            var chargeService = new StripeChargeService(Cache.ApiKey);

            chargeService.ExpandApplicationFee = true;

            var charge = chargeService.Create(
                new StripeChargeCreateOptions
            {
                SourceTokenOrExistingSourceId = Cache.GetToken().Id,
                ApplicationFee = 10,
                Amount         = 100,
                Currency       = "usd"
            },
                new StripeRequestOptions
            {
                StripeConnectAccountId = anotherAccount.Id
            }
                );

            var appFeeService = new StripeApplicationFeeService(Cache.ApiKey);

            appFeeService.ExpandApplication = true;

            _appFee = appFeeService.Get(charge.ApplicationFeeId);
        }
        public when_creating_charges_with_multiple_expand()
        {
            var accountService = new StripeAccountService(Cache.ApiKey);
            var account        = accountService.Create(new StripeAccountCreateOptions
            {
                Type = StripeAccountType.Custom
            });

            var chargeOptions = new StripeChargeCreateOptions
            {
                SourceTokenOrExistingSourceId = "tok_visa",
                ApplicationFee = 10,
                Amount         = 100,
                Currency       = "usd",
                Destination    = account.Id,
            };

            chargeOptions.AddExpand("balance_transaction");
            chargeOptions.AddExpand("transfer.balance_transaction.source");
            chargeOptions.AddExpand("destination");

            Charge = new StripeChargeService(Cache.ApiKey).Create(chargeOptions);

            accountService.Delete(account.Id);
        }
        public getting_external_accounts()
        {
            var newAccount = new StripeAccountService(_stripe_api_key).Create(
                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               = "Joe Meatballs",
                    Number             = "4000056655665556",
                    Currency           = "usd",
                    DefaultForCurrency = true
                }
            }
                );

            RetrievedAccount = new StripeAccountService(_stripe_api_key).Get(newAccount.Id);
        }
        public when_updating_legal_entity_additional_owners()
        {
            var newAccount = new StripeAccountService(_stripe_api_key).Create(
                new StripeAccountCreateOptions
                {
                    Email = $"merry{ Guid.NewGuid() }@christmas.com",
                    Managed = true,
                    LegalEntity = new StripeAccountLegalEntityOptions
                    {
                        AdditionalOwners = new List<StripeAccountAdditionalOwner>
                        {
                            new StripeAccountAdditionalOwner { FirstName = "Big", LastName = "Little" },
                            new StripeAccountAdditionalOwner { FirstName = "Trouble", LastName = "China" }
                        }
                    }
                }
            );

            RetrievedAccount = new StripeAccountService(_stripe_api_key).Get(newAccount.Id);

            new StripeAccountService(_stripe_api_key).Update(newAccount.Id,
                new StripeAccountUpdateOptions
                {
                    LegalEntity = new StripeAccountLegalEntityOptions
                    {
                        AdditionalOwners = new List<StripeAccountAdditionalOwner>
                        {
                            new StripeAccountAdditionalOwner { FirstName = "BigUpdated", LastName = "Little" },
                            //new StripeAccountAdditionalOwner { BirthDay = 25, BirthMonth = 12, BirthYear = 2000 }
                        }
                    }
                }
            );
        }
        public adding_additional_owners()
        {
            var newAccount = new StripeAccountService(_stripe_api_key).Create(
                new StripeAccountCreateOptions
            {
                Email       = $"*****@*****.**",
                Managed     = true,
                LegalEntity = new StripeAccountLegalEntityOptions
                {
                    AdditionalOwners = new List <StripeAccountAdditionalOwner>
                    {
                        new StripeAccountAdditionalOwner
                        {
                            FirstName = "Big", LastName = "Little",
                            BirthDay  = 25, BirthMonth = 12, BirthYear = 2000
                        },
                        new StripeAccountAdditionalOwner
                        {
                            FirstName = "Trouble", LastName = "China",
                            State     = "CA", CityOrTown = "A",
                            Line1     = "B", Line2 = "C", PostalCode = "27635",
                            Country   = "US"
                        }
                    }
                }
            }
                );

            RetrievedAccount = new StripeAccountService(_stripe_api_key).Get(newAccount.Id);
        }
        public getting_external_accounts()
        {
            var newAccount = new StripeAccountService(_stripe_api_key).Create(
                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 = "Joe Meatballs",
                        Number = "4000056655665556",
                        Currency = "usd",
                        DefaultForCurrency = true
                    }
                }
            );

            RetrievedAccount = new StripeAccountService(_stripe_api_key).Get(newAccount.Id);
        }
        public adding_additional_owners()
        {
            var newAccount = new StripeAccountService(_stripe_api_key).Create(
                new StripeAccountCreateOptions
                {
                    Email = $"*****@*****.**",
                    Managed = true,
                    LegalEntity = new StripeAccountLegalEntityOptions
                    {
                        AdditionalOwners = new List<StripeAccountAdditionalOwner>
                        {
                            new StripeAccountAdditionalOwner
                            {
                                FirstName = "Big", LastName = "Little",
                                BirthDay = 25, BirthMonth = 12, BirthYear = 2000
                            },
                            new StripeAccountAdditionalOwner
                            {
                                FirstName = "Trouble", LastName = "China",
                                State = "CA", CityOrTown = "A",
                                Line1 ="B", Line2 = "C", PostalCode = "27635",
                                Country = "US"
                            }
                        }
                    }
                }
            );

            RetrievedAccount = new StripeAccountService(_stripe_api_key).Get(newAccount.Id);
        }
        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,
            };
        }
Exemplo n.º 9
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 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);
        }
Exemplo n.º 11
0
        public external_account_fixture()
        {
            Account = new StripeAccountService(Cache.ApiKey).Create(new StripeAccountCreateOptions
            {
                Country = "US",
                Type    = StripeAccountType.Custom
            });

            ExernalAccountCreateOptionsBankAccount = new StripeExternalAccountCreateOptions
            {
                ExternalAccountBankAccount = new StripeAccountBankAccountOptions
                {
                    AccountNumber = "000123456789",
                    Country       = "US",
                    Currency      = "usd",
                    RoutingNumber = "110000000"
                }
            };

            ExernalAccountBankAccountUpdateOptions = new StripeExternalAccountUpdateOptions
            {
                Metadata = new Dictionary <string, string>()
                {
                    { "key", "value" }
                }
            };

            ExernalAccountCardUpdateOptions = new StripeExternalAccountUpdateOptions
            {
                ExternalAccountCard = new StripeExternalAccountCardUpdateOptions
                {
                    ExpirationMonth = 01,
                    ExpirationYear  = 2028,
                    Name            = "Updated Name"
                }
            };

            var service = new StripeExternalAccountService(Cache.ApiKey);

            ExternalAccountCard = service.Create(Account.Id, new StripeExternalAccountCreateOptions
            {
                ExternalAccountTokenId = "tok_visa_debit"
            });
            ExternalAccountBankAccount        = service.Create(Account.Id, ExernalAccountCreateOptionsBankAccount);
            ExternalAccountBankAccountUpdated = service.Update(Account.Id, ExternalAccountBankAccount.Id, ExernalAccountBankAccountUpdateOptions);
            ExternalAccountCardUpdated        = service.Update(Account.Id, ExternalAccountCard.Id, ExernalAccountCardUpdateOptions);
            ExternalAccountRetrieved          = service.Get(Account.Id, ExternalAccountCard.Id);
            ExternalAccountList    = service.List(Account.Id);
            ExternalAccountDeleted = service.Delete(Account.Id, ExternalAccountBankAccount.Id);
        }
Exemplo n.º 12
0
 public AccountService(IWorkContext workContext,
                       ILogger logger,
                       StripeConnectPaymentSettings stripeConnectPaymentSettings,
                       IWebHelper webHelper,
                       HttpClient httpClient,
                       ICustomerEntityService customerEntityService)
 {
     _workContext = workContext;
     _logger      = logger;
     _stripeConnectPaymentSettings = stripeConnectPaymentSettings;
     _webHelper             = webHelper;
     _httpClient            = httpClient;
     _customerEntityService = customerEntityService;
     _stripeAccountService  = new StripeAccountService(_stripeConnectPaymentSettings.SecretKey);
 }
        public PaymentStripeService(
            StripeSourceService stripeSourceService,
            StripeChargeService stripeChargeService,
            StripeAccountService stripeAccountService,
            StripeFileUploadService stripeFileUploadService,
            StripeExternalAccountService externalAccountService)
        {
            // Set your secret key: remember to change this to your live secret key in production
            // See your keys here: https://dashboard.stripe.com/account/apikeys
            StripeConfiguration.SetApiKey(_privateKey);

            _stripeSourceService     = stripeSourceService;
            _stripeChargeService     = stripeChargeService;
            _stripeAccountService    = stripeAccountService;
            _stripeFileUploadService = stripeFileUploadService;
            _externalAccountService  = externalAccountService;
        }
Exemplo n.º 14
0
        public static StripeAccount GetCustomAccountWithCard()
        {
            if (_customAccountWithCard != null)
            {
                return(_customAccountWithCard);
            }

            var options = test_data.stripe_account_create_options.ValidAccountWithCard();

            options.Country                = "US";
            options.Email                  = $"joe{ Guid.NewGuid() }@blahblah.com";
            options.Type                   = StripeAccountType.Custom;
            options.TosAcceptanceDate      = DateTime.UtcNow.Date;
            options.TosAcceptanceIp        = "8.8.8.8";
            options.TosAcceptanceUserAgent = "user-agent-7";

            CustomAccountWithCardOptions = options;

            return(_customAccountWithCard = new StripeAccountService().Create(options));
        }
Exemplo n.º 15
0
        public when_updating_legal_entity_additional_owners()
        {
            var newAccount = new StripeAccountService(_stripe_api_key).Create(
                new StripeAccountCreateOptions
            {
                Email       = $"merry{ Guid.NewGuid() }@christmas.com",
                Managed     = true,
                LegalEntity = new StripeAccountLegalEntityOptions
                {
                    AdditionalOwners = new List <StripeAccountAdditionalOwner>
                    {
                        new StripeAccountAdditionalOwner {
                            FirstName = "Big", LastName = "Little"
                        },
                        new StripeAccountAdditionalOwner {
                            FirstName = "Trouble", LastName = "China"
                        }
                    }
                }
            }
                );

            RetrievedAccount = new StripeAccountService(_stripe_api_key).Get(newAccount.Id);

            new StripeAccountService(_stripe_api_key).Update(newAccount.Id,
                                                             new StripeAccountUpdateOptions
            {
                LegalEntity = new StripeAccountLegalEntityOptions
                {
                    AdditionalOwners = new List <StripeAccountAdditionalOwner>
                    {
                        new StripeAccountAdditionalOwner {
                            FirstName = "BigUpdated", LastName = "Little"
                        },
                        //new StripeAccountAdditionalOwner { BirthDay = 25, BirthMonth = 12, BirthYear = 2000 }
                    }
                }
            }
                                                             );
        }
 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.º 17
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.º 18
0
 public StripeAccountCreateOptionsTest()
 {
     this.service = new StripeAccountService();
 }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
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();
        }