コード例 #1
0
        public static StripeSource CreateSource(string token, int amount, string redirectUrl)
        {
            StripeConfiguration.SetApiKey(MasterStrings.StripeSecretKey);

            var sourceOptions = new StripeSourceCreateOptions
            {
                Amount   = amount,
                Currency = "gbp",
                Type     = "three_d_secure",
                ThreeDSecureCardOrSourceId = token,
                RedirectReturnUrl          = redirectUrl
            };

            var sourceService = new StripeSourceService();

            try
            {
                StripeSource source = sourceService.Create(sourceOptions);

                return(source);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #2
0
        public StripeSourceServiceTest()
        {
            this.service = new StripeSourceService();

            this.createOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.AchCreditTransfer,
                Currency = "usd",
                Mandate  = new StripeSourceMandateOptions
                {
                    MandateAcceptanceDate      = DateTime.Parse("Mon, 01 Jan 2001 00:00:00Z"),
                    MandateAcceptanceIp        = "127.0.0.1",
                    MandateAcceptanceStatus    = "accepted",
                    MandateAcceptanceUserAgent = "User-Agent",
                    MandateNotificationMethod  = "manual",
                },
                Receiver = new StripeSourceReceiverOptions
                {
                    RefundAttributesMethod = "manual",
                },
            };

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

            this.listOptions = new StripeSourceListOptions()
            {
                Limit = 1,
            };
        }
コード例 #3
0
        public attaching_and_detaching_sources()
        {
            var SourceCardCreateOptions = new StripeSourceCreateOptions
            {
                Type  = StripeSourceType.Card,
                Token = "tok_visa"
            };

            var CustomerCreateOptions = new StripeCustomerCreateOptions
            {
                Email = "*****@*****.**",
            };

            var sourceService   = new StripeSourceService(Cache.ApiKey);
            var customerService = new StripeCustomerService(Cache.ApiKey);

            var SourceCard = sourceService.Create(SourceCardCreateOptions);

            Customer = customerService.Create(CustomerCreateOptions);

            var SourceAttachOptions = new StripeSourceAttachOptions
            {
                Source = SourceCard.Id
            };

            SourceAttached = sourceService.Attach(Customer.Id, SourceAttachOptions);
            SourceDetached = sourceService.Detach(Customer.Id, SourceAttached.Id);
        }
コード例 #4
0
        public sources_fixture()
        {
            SourceCreateOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.AchCreditTransfer,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Email      = "*****@*****.**",
                    CityOrTown = "Mayberry",
                    State      = "NC"
                }
            };

            SourceUpdateOptions = new StripeSourceUpdateOptions
            {
                Owner = new StripeSourceOwner
                {
                    Email = "*****@*****.**"
                }
            };

            var service = new StripeSourceService(Cache.ApiKey);

            Source          = service.Create(SourceCreateOptions);
            SourceUpdated   = service.Update(Source.Id, SourceUpdateOptions);
            SourceRetrieved = service.Get(Source.Id);
        }
コード例 #5
0
ファイル: _fixture.cs プロジェクト: rentler/stripe-net
        public sources_fixture()
        {
            SourceCreateOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.Bitcoin,
                Amount   = 1,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Email      = "*****@*****.**",
                    CityOrTown = "Mayberry",
                    State      = "NC"
                }
            };

            SourceUpdateOptions = new StripeSourceUpdateOptions
            {
                Owner = new StripeSourceOwner
                {
                    Email = "*****@*****.**"
                }
            };

            var service = new StripeSourceService(Cache.ApiKey);

            Source          = service.Create(SourceCreateOptions);
            SourceUpdated   = service.Update(Source.Id, SourceUpdateOptions);
            SourceRetrieved = service.Get(Source.Id);
        }
コード例 #6
0
        public creating_three_d_secure_source()
        {
            var sourceCreateOptions = new StripeSourceCreateOptions
            {
                Type              = StripeSourceType.Card,
                Amount            = 1234,
                Currency          = "eur",
                RedirectReturnUrl = "http://no.where/webhooks",
                Card              = new StripeCreditCardOptions
                {
                    // Using PAN as we don't have a 3DS test token yet
                    Number          = "4000000000003063",
                    ExpirationMonth = 12,
                    ExpirationYear  = 2020
                }
            };

            var threeDSCreateOptions = new StripeSourceCreateOptions
            {
                Type              = StripeSourceType.ThreeDSecure,
                Amount            = 8675309,
                Currency          = "eur",
                RedirectReturnUrl = "http://no.where/webhooks",
            };

            var sourceService   = new StripeSourceService(Cache.ApiKey);
            var customerService = new StripeCustomerService(Cache.ApiKey);

            Customer = customerService.Create(new StripeCustomerCreateOptions {
            });

            Source = sourceService.Create(sourceCreateOptions);
            threeDSCreateOptions.ThreeDSecureCardOrSourceId = Source.Id;
            ThreeDSecure = sourceService.Create(threeDSCreateOptions);

            SourceCustomer = sourceService.Create(sourceCreateOptions);
            var SourceAttachOptions = new StripeSourceAttachOptions
            {
                Source = SourceCustomer.Id
            };

            sourceService.Attach(Customer.Id, SourceAttachOptions);

            threeDSCreateOptions.ThreeDSecureCardOrSourceId = SourceCustomer.Id;
            threeDSCreateOptions.ThreeDSecureCustomer       = Customer.Id;
            ThreeDSecureCustomer = sourceService.Create(threeDSCreateOptions);


            // from here, you have to go to the threeDSecure.Redirect.Url and click success

            //var charge = new StripeChargeService(Cache.ApiKey).Create(
            //    new StripeChargeCreateOptions
            //    {
            //        Amount = 8675309,
            //        Currency = "eur",
            //        SourceTokenOrExistingSourceId = threeDSecure.Id
            //    }
            //);
        }
コード例 #7
0
        public listing_sources_on_customer()
        {
            var sourceService   = new StripeSourceService(Cache.ApiKey);
            var customerService = new StripeCustomerService(Cache.ApiKey);

            // Create customer
            var CustomerCreateOptions = new StripeCustomerCreateOptions
            {
                Email = "*****@*****.**",
            };
            var Customer = customerService.Create(CustomerCreateOptions);

            // Create card source and attach it to customer
            var SourceCardCreateOptions = new StripeSourceCreateOptions
            {
                Type  = StripeSourceType.Card,
                Token = "tok_visa"
            };
            var SourceCard = sourceService.Create(SourceCardCreateOptions);

            var SourceAttachOptions = new StripeSourceAttachOptions
            {
                Source = SourceCard.Id
            };

            SourceCard = sourceService.Attach(Customer.Id, SourceAttachOptions);

            // Create bitcoin source and attach it to customer
            var SourceBitcoinCreateOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.Bitcoin,
                Amount   = 1000,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Email = "*****@*****.**",
                },
            };
            var SourceBitcoin = sourceService.Create(SourceBitcoinCreateOptions);

            SourceAttachOptions.Source = SourceBitcoin.Id;
            SourceBitcoin = sourceService.Attach(Customer.Id, SourceAttachOptions);

            // List sources on customer
            SourceListAll = sourceService.List(Customer.Id);

            var SourceListOptions = new StripeSourceListOptions
            {
                Type = StripeSourceType.Card
            };

            SourceListCard = sourceService.List(Customer.Id, SourceListOptions);

            SourceListOptions.Type = StripeSourceType.Bitcoin;
            SourceListBitcoin      = sourceService.List(Customer.Id, SourceListOptions);
        }
コード例 #8
0
        public listing_sources_on_customer()
        {
            var sourceService   = new StripeSourceService(Cache.ApiKey);
            var customerService = new StripeCustomerService(Cache.ApiKey);

            // Create customer
            var CustomerCreateOptions = new StripeCustomerCreateOptions
            {
                Email = "*****@*****.**",
            };
            var Customer = customerService.Create(CustomerCreateOptions);

            // Create card source and attach it to customer
            var SourceCardCreateOptions = new StripeSourceCreateOptions
            {
                Type  = StripeSourceType.Card,
                Token = "tok_visa"
            };
            var SourceCard = sourceService.Create(SourceCardCreateOptions);

            var SourceAttachOptions = new StripeSourceAttachOptions
            {
                Source = SourceCard.Id
            };

            SourceCard = sourceService.Attach(Customer.Id, SourceAttachOptions);

            // Create ACH Credit Transfer source and attach it to customer
            var SourceACHCreditCreateOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.AchCreditTransfer,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Email = "*****@*****.**",
                },
            };
            var SourceACHCredit = sourceService.Create(SourceACHCreditCreateOptions);

            SourceAttachOptions.Source = SourceACHCredit.Id;
            SourceACHCredit            = sourceService.Attach(Customer.Id, SourceAttachOptions);

            // List sources on customer
            SourceListAll = sourceService.List(Customer.Id);

            var SourceListOptions = new StripeSourceListOptions
            {
                Type = StripeSourceType.Card
            };

            SourceListCard = sourceService.List(Customer.Id, SourceListOptions);

            SourceListOptions.Type = StripeSourceType.AchCreditTransfer;
            SourceListACHCredit    = sourceService.List(Customer.Id, SourceListOptions);
        }
コード例 #9
0
        public creating_reusable_card_source()
        {
            var options = new StripeSourceCreateOptions
            {
                Type  = StripeSourceType.Card,
                Usage = StripeSourceUsage.Reusable,
                Token = "tok_visa",
            };

            Source = new StripeSourceService(Cache.ApiKey).Create(options);
        }
コード例 #10
0
        public creating_and_updating_card_source()
        {
            var options = new StripeSourceCreateOptions
            {
                Type              = StripeSourceType.Card,
                Amount            = 100,
                Currency          = "usd",
                Token             = Cache.GetToken().Id,
                RedirectReturnUrl = "http://no.where/webhooks"
            };

            Source = new StripeSourceService(Cache.ApiKey).Create(options);
        }
コード例 #11
0
        public creating_and_updating_ideal_source()
        {
            var options = new StripeSourceCreateOptions
            {
                Type      = StripeSourceType.Ideal,
                IdealBank = "ing",
                IdealStatementDescriptor = "finished",
                Amount            = 1,
                Currency          = "eur",
                RedirectReturnUrl = "http://no.where/webhooks"
            };

            Source = new StripeSourceService(Cache.ApiKey).Create(options);
        }
コード例 #12
0
        public creating_and_updating_sofort_source()
        {
            var options = new StripeSourceCreateOptions
            {
                Type                      = StripeSourceType.Sofort,
                SofortCountry             = "DE",
                SofortStatementDescriptor = "soforty!",
                Amount                    = 500,
                Currency                  = "eur",
                RedirectReturnUrl         = "http://no.where/webhooks"
            };

            Source = new StripeSourceService(Cache.ApiKey).Create(options);
        }
        public creating_and_updating_bancontact_source()
        {
            var options = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.Bancontact,
                Amount   = 500,
                Currency = "eur",
                Owner    = new StripeSourceOwner {
                    Name = "Joe Biden"
                },
                RedirectReturnUrl             = "http://no.where/webhooks",
                BancontactStatementDescriptor = "test statement descriptor"
            };

            Source = new StripeSourceService(Cache.ApiKey).Create(options);
        }
コード例 #14
0
        public StripeSource CreateSource(int amount, string owner)
        {
            var options = new StripeSourceCreateOptions
            {
                Type     = "ideal",
                Amount   = amount,
                Currency = "eur",
                Owner    = new StripeSourceOwner {
                    Name = owner
                },
                RedirectReturnUrl = "http://Home/Index",
            };

            var source = new StripeSourceService();

            return(source.Create(options));
        }
コード例 #15
0
        public creating_and_updating_bitcoin_source()
        {
            var options = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.Bitcoin,
                Amount   = 100101,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Name  = "Satoshi Nakamoto",
                    Email = "*****@*****.**"
                },
                RedirectReturnUrl = "http://no.where/webhooks"
            };

            Source = new StripeSourceService(Cache.ApiKey).Create(options);
        }
        public creating_ach_credit_transfers_sources_and_listing_transactions()
        {
            var SourceCreateOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.AchCreditTransfer,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Email = "*****@*****.**"
                }
            };

            var sourceService            = new StripeSourceService(Cache.ApiKey);
            var sourceTransactionService = new StripeSourceTransactionService(Cache.ApiKey);

            Source       = sourceService.Create(SourceCreateOptions);
            Transactions = sourceTransactionService.List(Source.Id);
        }
コード例 #17
0
        private StripeSource createStripeSource(string cardNo, int?expirationYear, int?expirationMonth, string ccv, string cardHolderFullName, bool isReusable)
        {
            StripeSource source = new StripeSource();

            try
            {
                var tokenOptions = new StripeTokenCreateOptions()
                {
                    Card = new StripeCreditCardOptions()
                    {
                        Number          = cardNo,
                        ExpirationYear  = expirationYear,
                        ExpirationMonth = expirationMonth,
                        Cvc             = ccv
                    }
                };
                var         tokenService = new StripeTokenService(secretKey);
                StripeToken stripeToken  = tokenService.Create(tokenOptions);
                string      usage        = "reusable";
                if (!isReusable)
                {
                    usage = "single_use";
                }
                var sourceOptions = new StripeSourceCreateOptions()
                {
                    Type  = StripeSourceType.Card,
                    Owner = new StripeSourceOwner()
                    {
                        Name = cardHolderFullName
                    },
                    Token = stripeToken.Id,
                    Usage = usage
                };
                var sourceService = new StripeSourceService(secretKey);
                //CREATE A SOURCE
                source = sourceService.Create(sourceOptions);
            }
            catch (StripeException e)
            {
                throw new StripeException(e.HttpStatusCode, e.StripeError, e.Message);
            }
            return(source);
        }
コード例 #18
0
        public creating_charge_with_card_source()
        {
            var sourceCardCreateOptions = new StripeSourceCreateOptions
            {
                Type  = StripeSourceType.Card,
                Token = "tok_visa",
            };

            var sourceService = new StripeSourceService(Cache.ApiKey);

            SourceCard = sourceService.Create(sourceCardCreateOptions);

            var chargeCreateOptions = new StripeChargeCreateOptions
            {
                Amount   = 400,
                Currency = "usd",
                SourceTokenOrExistingSourceId = SourceCard.Id,
            };
            var chargeService = new StripeChargeService(Cache.ApiKey);

            Charge = chargeService.Create(chargeCreateOptions);
        }
コード例 #19
0
        public creating_and_updating_card_source()
        {
            SourceCardCreateOptions = new StripeSourceCreateOptions
            {
                Type  = StripeSourceType.Card,
                Token = "tok_visa"
            };

            SourceCardUpdateOptions = new StripeSourceUpdateOptions
            {
                Card = new StripeSourceCardUpdateOptions
                {
                    ExpirationMonth = 12,
                    ExpirationYear  = 2028
                }
            };

            var service = new StripeSourceService(Cache.ApiKey);

            SourceCard        = service.Create(SourceCardCreateOptions);
            SourceCardUpdated = service.Update(SourceCard.Id, SourceCardUpdateOptions);
        }
コード例 #20
0
        public StripeSourceServiceTest()
        {
            this.service = new StripeSourceService();

            this.createOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.AchCreditTransfer,
                Currency = "usd"
            };

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

            this.listOptions = new StripeSourceListOptions()
            {
                Limit = 1,
            };
        }