コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #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 IActionResult Get([FromQuery] StripePaymentResponse request)
        {
            var    source = new StripeSourceService(stripeSettings.StripePrivateKey).Get(request.source);
            string status = null;

            if (source.Status != "chargeable")
            {
                // remove custom;
                //var customer = new StripeSourceService(stripeSettings.StripePrivateKey).Delete(request.source);
                status = source.Status;
            }
            else
            {
                var charge = new StripeChargeService(stripeSettings.StripePrivateKey).Create(
                    new StripeChargeCreateOptions
                {
                    Amount     = request.amount,
                    Currency   = request.currency,
                    CustomerId = request.customerid,
                    SourceTokenOrExistingSourceId = request.source
                });
                status = charge.Status;
            }
            //return Json(status);
            return(Redirect($"{request.returnUrl.Replace("_qm_", "?").Replace("_amp_", "&")}{(request.returnUrl.Contains("_qm_") ? "&" : "?")}status={status}"));
        }
コード例 #5
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,
            };
        }
コード例 #6
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);
            }
        }
コード例 #7
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
            //    }
            //);
        }
コード例 #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 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);
        }
コード例 #9
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);
        }
コード例 #10
0
        public static StripeOutcome ChargeSource(string source, bool livemode, string client_secret, long id, string idType)
        {
            // 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(MasterStrings.StripeSecretKey);

            var          service       = new StripeSourceService();
            StripeSource sourceService = service.Get(source);

            if (sourceService.Status == "chargeable")
            {
                var options = new StripeChargeCreateOptions
                {
                    Amount   = sourceService.Amount,
                    Currency = sourceService.Currency,
                    SourceTokenOrExistingSourceId = source,
                    Description = "Charge for Order Id " + id.ToString(),
                    Metadata    = new Dictionary <String, String>()
                    {
                        { idType, id.ToString() }
                    }
                };

                var serviceCharge = new StripeChargeService();

                try
                {
                    StripeCharge charge = serviceCharge.Create(options);

                    if (charge.Outcome.Reason == "approve_with_id" || charge.Outcome.Reason == "issuer_not_available" ||
                        charge.Outcome.Reason == "processing_error" || charge.Outcome.Reason == "reenter_transaction" ||
                        charge.Outcome.Reason == "try_again_later")
                    {
                        charge = serviceCharge.Create(options);
                    }

                    charge.Outcome.Id = charge.Id;
                    return(charge.Outcome);
                }
                catch (Exception ex)
                {
                    throw new StripeException(ex.Message);
                }
            }

            return(new StripeOutcome()
            {
                NetworkStatus = MasterStrings.StripeNotSent,
                SellerMessage = "Card not yet chargeable.",
                Type = "pending"
            });
        }
コード例 #11
0
        public creating_and_updating_sofort_source()
        {
            SourceCreateOptions = new StripeSourceCreateOptions
            {
                Type                = StripeSourceType.Sofort,
                SofortCountry       = "DE",
                StatementDescriptor = "soforty!",
                Amount              = 500,
                Currency            = "eur",
                RedirectReturnUrl   = "http://no.where/webhooks"
            };

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

            Source = new StripeSourceService(Cache.ApiKey).Create(SourceCreateOptions);
        }
コード例 #13
0
ファイル: _fixture.cs プロジェクト: seangwright/stripe-dotnet
        public topups_fixture()
        {
            StripeSource source = new StripeSourceService(Cache.ApiKey).Create(new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.AchCreditTransfer,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Email = "*****@*****.**"
                }
            });

            // Sleep for 5 seconds to ensure the Source is chargeable
            // 1 or 2 seconds are unfortunately not enough.
            System.Threading.Thread.Sleep(5000);

            TopupCreateOptions = new StripeTopupCreateOptions
            {
                Amount              = 1000,
                Currency            = "usd",
                Description         = "Test Topup",
                SourceId            = source.Id,
                StatementDescriptor = "Descriptor",
            };

            TopupUpdateOptions = new StripeTopupUpdateOptions
            {
                Metadata = new Dictionary <string, string>()
                {
                    { "some-key", "some-value" }
                }
            };

            var service = new StripeTopupService(Cache.ApiKey);

            Topup          = service.Create(TopupCreateOptions);
            TopupUpdated   = service.Update(Topup.Id, TopupUpdateOptions);
            TopupRetrieved = service.Get(Topup.Id);

            TopupListOptions = new StripeTopupListOptions
            {
                Created = new StripeDateFilter {
                    EqualTo = Topup.Created
                },
            };

            TopupList = service.List(TopupListOptions);
        }
コード例 #14
0
        public topups_fixture()
        {
            StripeSource source = new StripeSourceService(Cache.ApiKey).Create(new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.AchCreditTransfer,
                Currency = "usd",
                Owner    = new StripeSourceOwner
                {
                    Email = "*****@*****.**"
                }
            });

            TopupCreateOptions = new StripeTopupCreateOptions
            {
                Amount              = 1000,
                Currency            = "usd",
                Description         = "Test Topup",
                SourceId            = source.Id,
                StatementDescriptor = "Descriptor",
            };

            TopupUpdateOptions = new StripeTopupUpdateOptions
            {
                Metadata = new Dictionary <string, string>()
                {
                    { "some-key", "some-value" }
                }
            };

            var service = new StripeTopupService(Cache.ApiKey);

            // We have to disable that part of the fixture. Creating a Topup requires a
            // chargeable Source. In Test mode this can take a random time though which
            // breaks the tests unfortunately.
            // Since the feature is in private beta, we're just skipping the tests
            // anyway.

            //Topup = service.Create(TopupCreateOptions);
            //TopupUpdated = service.Update(Topup.Id, TopupUpdateOptions);
            //TopupRetrieved = service.Get(Topup.Id);

            //TopupListOptions = new StripeTopupListOptions
            //{
            //    Created = new StripeDateFilter { EqualTo = Topup.Created },
            //};

            //TopupList = service.List(TopupListOptions);
        }
コード例 #15
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));
        }
コード例 #16
0
        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;
        }
        public creating_and_updating_bancontact_source()
        {
            SourceCreateOptions = new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.Bancontact,
                Amount   = 500,
                Currency = "eur",
                Owner    = new StripeSourceOwner {
                    Name = "Joe Biden"
                },
                RedirectReturnUrl           = "http://no.where/webhooks",
                StatementDescriptor         = "test statement descriptor",
                BancontactPreferredLanguage = "FR"
            };

            Source = new StripeSourceService(Cache.ApiKey).Create(SourceCreateOptions);
        }
コード例 #18
0
        public override StripeSource Create(StripeSettings stripeSettings, FirstPaymentData data)
        {
            var source = new StripeSourceService(stripeSettings.StripePrivateKey).Create(new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.Bancontact,
                Amount   = data.Amount,
                Currency = data.Currency,
                Owner    = new StripeSourceOwner
                {
                    Name = data.OwnerName
                },
                RedirectReturnUrl = data.RedirectReturnUrl,
                Metadata          = data.Metadata
            });

            return(source);
        }
        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);
        }
コード例 #20
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);
        }
コード例 #21
0
        public override StripeSource Create(StripeSettings stripeSettings, FirstPaymentData data)
        {
            var source = new StripeSourceService(stripeSettings.StripePrivateKey).Create(new StripeSourceCreateOptions
            {
                Type     = StripeSourceType.Sofort,
                Amount   = data.Amount,
                Currency = data.Currency,
                Owner    = new StripeSourceOwner
                {
                    Name = data.OwnerName
                },
                RedirectReturnUrl         = data.RedirectReturnUrl,
                SofortCountry             = data.CountryCode,
                SofortStatementDescriptor = "", // define statement description
                Metadata = data.Metadata
            });

            return(source);
        }
コード例 #22
0
        public creating_three_d_secure_source()
        {
            Source = new StripeSourceService(Cache.ApiKey).Create(
                new StripeSourceCreateOptions
            {
                Type              = StripeSourceType.Card,
                Amount            = 8675309,
                Currency          = "eur",
                RedirectReturnUrl = "http://no.where/webhooks",
                Card              = new StripeCreditCardOptions
                {
                    Number          = "4000000000003063",
                    ExpirationMonth = 12,
                    ExpirationYear  = 2020
                }
            }
                );

            ThreeDSecure = new StripeSourceService(Cache.ApiKey).Create(
                new StripeSourceCreateOptions
            {
                Type                       = StripeSourceType.ThreeDSecure,
                Amount                     = 8675309,
                Currency                   = "eur",
                RedirectReturnUrl          = "http://no.where/webhooks",
                ThreeDSecureCardOrSourceId = Source.Id
            }
                );

            // 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
            //    }
            //);
        }
コード例 #23
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);
        }
コード例 #24
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);
        }
コード例 #25
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,
            };
        }
コード例 #26
0
        public Transaction_Result Sale(Sale_Details details)
        {
            StripeConfiguration.SetApiKey(secretKey);
            //ONCE-OFF PAYMENT
            if (details.ProviderToken == null || details.ProviderToken.Length <= 1)
            {
                try
                {
                    StripeSource source = createStripeSource(details.CardNumber, details.CardExpiryYear, details.CardExpiryMonth, details.CardCCV, details.CardHolderName + " " + details.CardHolderLastName, false);
                    details.ProviderToken = source.Id;
                }
                catch (StripeException e)
                {
                    return(new Transaction_Result()
                    {
                        isApproved = false,
                        hasServerError = true,
                        ErrorCode = e.StripeError.Code,
                        ErrorText = e.StripeError.Message,
                        FullResponse = e.StripeError.StripeResponse.ResponseJson
                    });
                }
            }

            //INITIATING A CHARGE
            var          chargeOptions = new StripeChargeCreateOptions();
            var          chargeService = new StripeChargeService();
            StripeCharge charge        = new StripeCharge();

            chargeOptions.Capture = true;
            bool isApproved = false;
            bool isPending  = false;

            try
            {
                //IF A SOURCE TOKEN IS PROVIDED >>>> ONCE-OFF PAYMENT

                if (details.ProviderToken.IndexOf("src") > -1)
                {
                    var          sourceService = new StripeSourceService();
                    StripeSource source        = sourceService.Get(details.ProviderToken);
                    chargeOptions.SourceTokenOrExistingSourceId = source.Id;
                    chargeOptions.Amount   = calculateAmount(details.Amount, details.CurrencyCode); // $1.00 = 100 cents
                    chargeOptions.Currency = details.CurrencyCode.ToLower();                        //SHOULD BE LOWER CASE
                    charge = chargeService.Create(chargeOptions);
                }

                //ONCE-OFF PAYMENT

                else if (details.ProviderToken.IndexOf("tok") > -1)
                {
                    var sourceService = new StripeSourceService();
                    chargeOptions.SourceTokenOrExistingSourceId = details.ProviderToken;
                    chargeOptions.Amount   = calculateAmount(details.Amount, details.CurrencyCode); // $1.00 = 100 cents
                    chargeOptions.Currency = details.CurrencyCode.ToLower();                        //SHOULD BE LOWER CASE
                    charge = chargeService.Create(chargeOptions);
                }

                //A REUSABLE CUSTOMER (OR A CARD)

                else if (details.ProviderToken.IndexOf("cus") > -1)
                {
                    var            customerService = new StripeCustomerService();
                    StripeCustomer customer        = customerService.Get(details.ProviderToken);
                    chargeOptions.SourceTokenOrExistingSourceId = customer.DefaultSourceId;
                    chargeOptions.CustomerId = details.ProviderToken;
                    chargeOptions.Amount     = calculateAmount(details.Amount, details.CurrencyCode); // $1.00 = 100 cents
                    chargeOptions.Currency   = details.CurrencyCode.ToLower();                        //SHOULD BE LOWER CASE
                    charge = chargeService.Create(chargeOptions);
                }
                string status = charge.Status;
                if (status.Contains("succeeded"))
                {
                    isApproved = true;
                }
                else if (status.Contains("pending"))
                {
                    isPending = true;
                }
                return(new Transaction_Result
                {
                    isApproved = isApproved,
                    hasServerError = isPending,
                    ErrorText = charge.FailureMessage,
                    ErrorCode = charge.FailureCode,
                    TransactionIndex = charge.BalanceTransactionId,
                    ProviderToken = charge.Id,
                    ResultText = charge.Status,
                    FullResponse = charge.StripeResponse.ResponseJson
                });
            }
            catch (StripeException e)
            {
                return(new Transaction_Result
                {
                    isApproved = false,
                    hasServerError = true,
                    ErrorText = e.StripeError.Message,
                    ProviderToken = null,
                    ErrorCode = e.StripeError.Code,
                    FullResponse = e.StripeError.StripeResponse.ResponseJson
                });
            }
        }