/// <summary>
        /// Updates a list of the coupon codes from stripe.
        /// </summary>
        /// <returns>true if the list was updated.</returns>
        private async Task <bool> UpdateCouponCodes()
        {
            StripeConfiguration.ApiKey = this.RequestOptions.ApiKey;
            bool updated;

            if (DateTime.Now - StripePaymentProcessor.promotionCodesUpdated > TimeSpan.FromMinutes(1))
            {
                PromotionCodeService service = new PromotionCodeService();

                StripeList <PromotionCode> codes = await service.ListAsync(new PromotionCodeListOptions()
                {
                    Limit = 100
                });;


                lock (StripePaymentProcessor.PromotionCodes)
                {
                    StripePaymentProcessor.PromotionCodes.Clear();
                    StripePaymentProcessor.PromotionCodes.AddRange(codes.ToList());
                }

                StripePaymentProcessor.promotionCodesUpdated = DateTime.Now;
                updated = true;
            }
            else
            {
                updated = false;
            }

            return(updated);
        }
Exemple #2
0
        public coupons_fixture()
        {
            CouponCreateOptions = new StripeCouponCreateOptions()
            {
                // Add a space at the end to ensure the ID is properly URL encoded
                // when passed in the URL for other methods
                Id               = "test-coupon-" + Guid.NewGuid().ToString() + " ",
                PercentOff       = 25,
                Duration         = "repeating",
                DurationInMonths = 3,
            };

            CouponUpdateOptions = new StripeCouponUpdateOptions {
                Metadata = new Dictionary <string, string> {
                    { "key_1", "value_1" }
                }
            };

            var service = new StripeCouponService(Cache.ApiKey);

            Coupon          = service.Create(CouponCreateOptions);
            CouponRetrieved = service.Get(Coupon.Id);
            CouponUpdated   = service.Update(Coupon.Id, CouponUpdateOptions);
            CouponsList     = service.List();
            CouponDeleted   = service.Delete(Coupon.Id);
        }
        static void GetDisputedCharges(StripeDisputeService chargeService, TraceWriter log)
        {
            string lastObjectId = null;
            StripeList <StripeDispute> response = null;

            //var greaterThanCreatedFilter = GetLatestCreatedTime();
            var listOptions = new StripeDisputeListOptions()
            {
                Limit         = 100,
                StartingAfter = lastObjectId
            };

            do
            {
                response = chargeService.List(listOptions);

                foreach (var d in response.Data)
                {
                    var disputes = DisputesResponseToStripeDisputes(d);
                    UpsertStripeDispute(disputes, log);
                    log.Info($"Dispute Updated: {disputes.DisputeId.ToString()}");
                }
                lastObjectId = response.Data.LastOrDefault()?.Id;
                listOptions.StartingAfter = lastObjectId;
                log.Info($"Charge last ObjectId: {lastObjectId}. More responses? {response.HasMore}");
            }while (response.HasMore);
        }
        public async Task <List <StripeTransaction> > GetListOfTransactions()
        {
            var transactions = new List <StripeTransaction>();

            var stripeClient = new StripeClient(appSettings.ApiSecret);

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

            return(charges.Data.Select(c => new StripeTransaction()
            {
                Id = c.Id,
                Paid = c.Paid,
                ApplicationFeeAmount = MoneyExtender.ConvertToDollars(c.ApplicationFeeAmount != null ? c.ApplicationFeeAmount.Value : 0),
                Status = c.Status,
                Description = c.Description,
                PaymentType = c.Object,
                AmountRefunded = MoneyExtender.ConvertToDollars(c.AmountRefunded),
                Amount = MoneyExtender.ConvertToDollars(c.Amount),
                Created = c.Created,
                FailureCode = c.FailureCode,
                FailureMessage = c.FailureMessage,
                TotalAmount = MoneyExtender.ConvertToDollars(c.Amount) - MoneyExtender.ConvertToDollars(c.AmountRefunded)
            }).ToList());
        }
Exemple #5
0
        public IActionResult GetSubscriptionList()
        {
            StripeConfiguration.ApiKey = "*****************";
            List <object> resultList = new List <object>();

            try
            {
                var options = new SubscriptionListOptions
                {
                };
                var service = new SubscriptionService();
                StripeList <Stripe.Subscription> subscriptions = service.List(
                    options
                    );

                foreach (Stripe.Subscription s in subscriptions)
                {
                    string id     = s.Items.Data[0].Subscription;
                    float  amount = (float)s.Items.Data[0].Plan.Amount / 100;
                    resultList.Add(new
                    {
                        id     = id,
                        amount = amount,
                    });
                }
            }
            catch {
                return(BadRequest());
            }
            return(Ok(new JsonResult(resultList)));
        }
Exemple #6
0
        public listing_cards_on_customer()
        {
            var customerService    = new StripeCustomerService(Cache.ApiKey);
            var bankAccountService = new BankAccountService(Cache.ApiKey);
            var cardService        = new StripeCardService(Cache.ApiKey);

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

            var BankAccountCreateOptions = new BankAccountCreateOptions
            {
                SourceBankAccount = new SourceBankAccount()
                {
                    RoutingNumber     = "110000000",
                    AccountNumber     = "000123456789",
                    Country           = "US",
                    Currency          = "usd",
                    AccountHolderName = "Jenny Rosen",
                    AccountHolderType = BankAccountHolderType.Individual,
                }
            };
            var BankAccount = bankAccountService.Create(Customer.Id, BankAccountCreateOptions);

            ListCards = cardService.List(Customer.Id);
        }
Exemple #7
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var list = JObject.Load(reader).ToObject <StripeList <dynamic> >();

            var result = new StripeList <Source>
            {
                Data       = new List <Source>(),
                HasMore    = list.HasMore,
                Object     = list.Object,
                TotalCount = list.TotalCount,
                Url        = list.Url
            };

            foreach (var item in list.Data)
            {
                var source = new Source();

                if (item.SelectToken("object").ToString() == "bank_account")
                {
                    source.Type        = SourceType.BankAccount;
                    source.BankAccount = Mapper <StripeBankAccount> .MapFromJson(item.ToString());
                }

                if (item.SelectToken("object").ToString() == "card")
                {
                    source.Type = SourceType.Card;
                    source.Card = Mapper <StripeCard> .MapFromJson(item.ToString());
                }

                result.Data.Add(source);
            }

            return(result);
        }
Exemple #8
0
        public products_fixture()
        {
            ProductCreateOptions = new StripeProductCreateOptions
            {
                Name = $"test-product-{ Guid.NewGuid() }"
            };

            ProductTwoCreateOptions = new StripeProductCreateOptions
            {
                Name = $"test-product-{ Guid.NewGuid() }"
            };

            ProductUpdateOptions = new StripeProductUpdateOptions
            {
                Name = $"test-product-{ Guid.NewGuid() }"
            };

            var service = new StripeProductService(Cache.ApiKey);

            Product          = service.Create(ProductCreateOptions);
            ProductTwo       = service.Create(ProductTwoCreateOptions);
            ProductUpdated   = service.Update(Product.Id, ProductUpdateOptions);
            ProductRetrieved = service.Get(Product.Id);

            ProductListOptions = new StripeProductListOptions
            {
                Url = Product.Url,
                Ids = new [] { Product.Id, ProductTwo.Id }
            };

            ProductList = service.List(ProductListOptions);
        }
Exemple #9
0
        public subscription_item_fixture()
        {
            SubscriptionItemCreateOptions = new StripeSubscriptionItemCreateOptions
            {
                SubscriptionId = Cache.GetSubscription().Id,
                // GetPlan() in the cache is used to create the original subscription
                // you cannot have a subscription item with the same plan as the original sub plan
                PlanId   = Cache.GetPlan("bronze").Id,
                Quantity = 1,
                Metadata = new Dictionary <string, string>()
                {
                    { "key", "value1" }
                }
            };

            SubscriptionItemUpdateOptions = new StripeSubscriptionItemUpdateOptions
            {
                Quantity = 2,
                Metadata = new Dictionary <string, string>()
                {
                    { "key", "value2" }
                }
            };

            var service = new StripeSubscriptionItemService(Cache.ApiKey);

            SubscriptionItem          = service.Create(SubscriptionItemCreateOptions);
            SubscriptionItemUpdated   = service.Update(SubscriptionItem.Id, SubscriptionItemUpdateOptions);
            SubscriptionItemRetrieved = service.Get(SubscriptionItem.Id);
            SubscriptionItemList      = service.List(new StripeSubscriptionItemListOptions {
                SubscriptionId = Cache.GetSubscription().Id
            });
        }
        static void GetNewCharges(StripeChargeService chargeService, TraceWriter log)
        {
            string lastObjectId = null;
            StripeList <StripeCharge> response = null;

            var greaterThanCreatedFilter = GetLatestCreatedTime();

            log.Info($"Latest Created Time: {greaterThanCreatedFilter}");

            var listOptions = new StripeChargeListOptions()
            {
                Limit   = 100,
                Created = new StripeDateFilter {
                    GreaterThan = greaterThanCreatedFilter
                },
                StartingAfter = lastObjectId
            };

            do
            {
                response = chargeService.List(listOptions);

                foreach (var c in response.Data)
                {
                    var trans = StripeChargeToStripeTransaction(c);
                    UpsertStripeTransaction(trans, log);
                }
                lastObjectId = response.Data.LastOrDefault()?.Id;
                listOptions.StartingAfter = lastObjectId;
                log.Info($"Charge last ObjectId: {lastObjectId}. More responses? {response.HasMore}");
            }while (response.HasMore);
        }
Exemple #11
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            StripeList <object> stripeList  = JObject.Load(reader).ToObject <StripeList <object> >();
            StripeList <Source> stripeList2 = new StripeList <Source>
            {
                Data    = new List <Source>(),
                HasMore = stripeList.HasMore,
                Object  = stripeList.Object,
                Url     = stripeList.Url
            };

            foreach (dynamic datum in stripeList.Data)
            {
                Source source = new Source();
                if (datum.SelectToken("object").ToString() == "bank_account")
                {
                    source.Type        = SourceType.BankAccount;
                    source.BankAccount = Mapper <StripeBankAccount> .MapFromJson(datum.ToString());
                }
                if (datum.SelectToken("object").ToString() == "card")
                {
                    source.Type = SourceType.Card;
                    source.Card = Mapper <StripeCard> .MapFromJson(datum.ToString());
                }
                stripeList2.Data.Add(source);
            }
            return(stripeList2);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var list = JObject.Load(reader).ToObject<StripeList<dynamic>>();

            var result = new StripeList<Source>
            {
                Data = new List<Source>(),
                HasMore = list.HasMore,
                Object = list.Object,
                TotalCount = list.TotalCount,
                Url = list.Url
            };

            foreach (var item in list.Data)
            {
                var source = new Source();

                if (item.SelectToken("object").ToString() == "bank_account")
                {
                    source.Type = SourceType.BankAccount;
                    source.BankAccount = Mapper<StripeBankAccount>.MapFromJson(item.ToString());
                }

                if (item.SelectToken("object").ToString() == "card")
                {
                    source.Type = SourceType.Card;
                    source.Card = Mapper<StripeCard>.MapFromJson(item.ToString());
                }

                result.Data.Add(source);
            }

            return result;
        }
Exemple #13
0
        public IActionResult GetSubscription([FromQuery] string customerId)
        {
            StripeConfiguration.ApiKey = API_KEY;
            List <object> resultList = new List <object>();

            try
            {
                var options = new SubscriptionListOptions
                {
                    Customer = customerId
                };
                var service = new SubscriptionService();
                StripeList <Stripe.Subscription> subscriptions = service.List(
                    options
                    );

                foreach (Stripe.Subscription s in subscriptions)
                {
                    string id        = s.Items.Data[0].Subscription;
                    string productId = s.Items.Data[0].Price.ProductId;
                    string priceId   = s.Items.Data[0].Price.Id;
                    resultList.Add(new
                    {
                        id      = id,
                        prodId  = productId,
                        priceId = priceId
                    });
                }
            }
            catch
            {
                return(BadRequest());
            }
            return(Ok(new JsonResult(resultList)));
        }
Exemple #14
0
        public plans_fixture()
        {
            PlanCreateOptions = new StripePlanCreateOptions()
            {
                // Add a space at the end to ensure the ID is properly URL encoded
                // when passed in the URL for other methods
                Id       = "test-plan-" + Guid.NewGuid().ToString() + " ",
                Name     = "plan-name",
                Amount   = 5000,
                Currency = "usd",
                Interval = "month",
            };

            PlanUpdateOptions = new StripePlanUpdateOptions {
                Name = "plan-name-2"
            };

            var service = new StripePlanService(Cache.ApiKey);

            Plan          = service.Create(PlanCreateOptions);
            PlanRetrieved = service.Get(Plan.Id);
            PlanUpdated   = service.Update(Plan.Id, PlanUpdateOptions);
            PlansList     = service.List();
            PlanDeleted   = service.Delete(Plan.Id);
        }
Exemple #15
0
        public IActionResult GetAllProducts()
        {
            StripeConfiguration.ApiKey = "****************";
            List <object> resultList = new List <object>();

            try
            {
                var options = new PriceListOptions {
                    Currency = "sgd"
                };
                var service = new PriceService();
                StripeList <Price> prices = service.List(options);

                foreach (Price p in prices)
                {
                    float  amount = (float)p.UnitAmount / 100;
                    string id     = p.Id;
                    resultList.Add(new
                    {
                        id     = id,
                        amount = amount,
                    });
                }
            }
            catch {
                return(BadRequest());
            }
            return(Ok(new JsonResult(resultList)));
        }
Exemple #16
0
        public ActionResult <ItemResponse <StripeList <Price> > > GetProduct(string id)
        {
            int          responseCode = 200;
            BaseResponse responseData = null;

            try
            {
                StripeList <Price> prices = GetStripePricesByProductId(id);
                StripeConfiguration.ApiKey = _appKeys.StripeApiKey;
                if (prices == null)
                {
                    responseCode = 404;
                    responseData = new ErrorResponse("Item was not found");
                    return(StatusCode(responseCode, responseData));
                }
                else
                {
                    responseData = new ItemResponse <StripeList <Price> > {
                        Item = prices
                    }
                };
            }
            catch (Exception exception)
            {
                responseCode = 500;
                responseData = new ErrorResponse($"Generic Error: {exception.Message}");
                base.Logger.LogError(exception.ToString());
            }

            return(StatusCode(responseCode, responseData));
        }
        public static bool UnSubscribe(string CustId)
        {
            var subsService = new StripeSubscriptionService();

            StripeList <StripeSubscription> activeSub = subsService.List(new StripeSubscriptionListOptions()
            {
                CustomerId = CustId,
                Limit      = 10
            });

            try
            {
                if (activeSub.Count() > 0)
                {
                    foreach (var sub in activeSub)
                    {
                        StripeSubscription subs = subsService.Cancel(sub.Id);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        static void GetChargeRefunds(StripeRefundService refundService, TraceWriter log)
        {
            string lastObjectId = GetLastObjectID();
            StripeList <StripeRefund> refundItems = null;

            //DateTime greaterEqualCreated = DateTime.UtcNow.AddHours(-48);
            //var lesserThanCreatedFilter = GetMinCreatedTime();
            log.Info($"LastObjectId: {lastObjectId}");

            var listOptions = new StripeRefundListOptions()
            {
                Limit         = 100,
                StartingAfter = lastObjectId,
            };

            DateTime?lastRefundCreated = null;

            do
            {
                refundItems = refundService.List(listOptions);
                foreach (var r in refundItems.Data)
                {
                    //log.Info(r.ToString());
                    var Refunds = StripeRefundToStripeTransaction(r);
                    UpsertStripeRefunds(Refunds, log);
                }
                lastObjectId              = refundItems.Data.LastOrDefault()?.Id;
                lastRefundCreated         = refundItems.Data.LastOrDefault()?.Created;
                listOptions.StartingAfter = lastObjectId;
                log.Info($"Refund last ObjectId: {lastObjectId}. Created: {lastRefundCreated} ");
            } while (refundItems.HasMore);
        }
        static void Main(string[] args)
        {
            //Set this to a valid test API key.
            StripeConfiguration.ApiKey = "sk_test_XXX";
            Console.WriteLine("Versioning in .NET!");
            Console.WriteLine("The .NET library is using API Version: " + StripeConfiguration.ApiVersion);

            //Create and print a customer to see what the response from library's pinned version looks like.
            var customerOptions = new CustomerCreateOptions
            {
                Email       = "*****@*****.**",
                Description = "Customer created with API version pinned to library",
            };
            var customerService = new CustomerService();
            var customer        = customerService.Create(customerOptions);

            Console.WriteLine("Customer created:");
            Console.WriteLine(customer);

            // Retrieve the customer.created event
            // or look at it in the Dashboard: https://dashboard.stripe.com/test/events
            // The customer object in the event payload will be based off of the version your
            // account is set to.
            var eventOptions = new EventListOptions {
                Limit = 1
            };
            var eventService          = new EventService();
            StripeList <Event> events = eventService.List(eventOptions);

            Console.WriteLine("customer.created event:");
            Console.WriteLine(events.Data[0]);

            //Create a webhook endpoint and set it's API version.

            var endpointOptions = new WebhookEndpointCreateOptions
            {
                ApiVersion    = StripeConfiguration.ApiVersion,
                Url           = "https://example.com/my/webhook/endpoint",
                EnabledEvents = new List <String>
                {
                    "customer.created",
                },
            };
            var endpointService = new WebhookEndpointService();

            endpointService.Create(endpointOptions);

            customerOptions.Email       = "*****@*****.**";
            customerOptions.Description = "Customer created using version set on for webhook endpoint";
            customer = customerService.Create(customerOptions);

            // Visit the Dashboard page for the endpoint you just created:
            // https://dashboard.stripe.com/test/webhooks/we_XXX
            // Under "Webhook Attempts" you'll see the event data Stripe has sent to the endpoint
            // for the customer that was just created.
            // Since we created the endpoint using the 2020-08-27 API version, the customer object
            // in the payload is using that version.
            Console.WriteLine("All done, visit https://dashboard.stripe.com/test/webhooks to see what was sent to the endpoint");
        }
        public int CancelSubscription(string userMail, string plansId)
        {
            StripeConfiguration.SetApiKey("sk_test_YskwifolV97dD2Iu0v8YgDt5");


            var customerService = new StripeCustomerService();
            StripeList <StripeCustomer> customerItems = customerService.List(
                new StripeCustomerListOptions()
            {
                Limit = 300
            }
                );
            bool found = false;

            var customer = new StripeCustomer();

            foreach (StripeCustomer cus in customerItems)
            {
                if (cus.Email == userMail)
                {
                    found    = true;
                    customer = cus;
                    break;
                }
            }

            if (found)
            {
                var subscriptionService = new StripeSubscriptionService();
                StripeList <StripeSubscription> response = subscriptionService.List(new StripeSubscriptionListOptions
                {
                    Limit = 3333
                });


                found = false;

                var subscript = new StripeSubscription();

                foreach (StripeSubscription subs in response)
                {
                    if (subs.CustomerId == customer.Id && subs.StripePlan.Id == plansId)
                    {
                        found     = true;
                        subscript = subs;
                        break;
                    }
                }

                if (found)
                {
                    StripeSubscription subscription = subscriptionService.Cancel(subscript.Id, new StripeSubscriptionCancelOptions());
                }
            }



            return(0);
        }
        public async Task <Customer> GetByEmail(string email)
        {
            try
            {
                #region GetCustomersList
                var CustomerOptions = new CustomerListOptions
                {
                    Limit = 50,
                    Email = email,
                    //RnD about extra parameters
                    //Created = DateTime.Now,
                    //StartingAfter = DateTime.Now.ToString(),
                    //EndingBefore = DateTime.Now.ToString(),
                };

                var customerService = new CustomerService();
                StripeList <Customer> stripeCustomersList = customerService.List(CustomerOptions);
                #endregion

                Customer stripeCustomer = new Customer();

                if (stripeCustomersList.Any(x => x.Email.Equals(email)))
                {
                    stripeCustomer = stripeCustomersList.FirstOrDefault(x => x.Email.Equals(email));
                }

                return(stripeCustomer);
            }

            catch (StripeException e)
            {
                string errorMessage = "";
                switch (e.StripeError.Error)
                {
                case "card_error":
                    errorMessage = $"Card Error occurred on {e.StripeError.PaymentIntent.Id}, Error: {e.StripeError.Error}, Error Code: {e.StripeError.Code}, Error Description: {e.StripeError.ErrorDescription}";
                    break;

                case "api_error":
                    errorMessage = $"API Error occurred: {e.StripeError.Error}, Error Code: {e.StripeError.Code}, Error Description: {e.StripeError.ErrorDescription}";
                    break;

                case "api_connection_error":
                    errorMessage = $"API Connection Error occurred: {e.StripeError.Error}, Error Code: {e.StripeError.Code}, Error Description: {e.StripeError.ErrorDescription}";
                    break;

                case "invalid_request_error	":
                    errorMessage = $"Invalid request Error occurred: {e.StripeError.Error}, Error Code: {e.StripeError.Code}, Error Description: {e.StripeError.ErrorDescription}";
                    break;

                default:
                    errorMessage = $"Some Error occurred: {e.StripeError.Error}, Error Code: {e.StripeError.Code}, Error Description: {e.StripeError.ErrorDescription}";
                    break;
                }

                throw new InvalidOperationException(errorMessage);
            }
        }
    protected void AnalyseData_Click(object sender, EventArgs e)
    {
        string source1 = string.Empty;

        source1 = FileSource1.Value.ToString();
        table   = "<div class=\"table-responsive pre-scrollable\"><h3>Matching Shopify to Stripe result</h3><div class=\"row clear_1m\"></div><table class=\"table\"><thead><th>#</th><th>Product/Item</th><th>Email</th><th>Payment Method</th><th> Currency </th><th>Amount</th><th>Order ID(Stripe)</th><th>Tool</th></tr></thead><tbody>";
        List <string> listA = new List <string>();

        try
        {
            //using (var reader = new StreamReader(@"C:\\XeroApp\\Requirements\\orders_export\\orders_export.csv"))
            int ctr = 0;
            using (var reader = new StreamReader(source1))
            {
                // List<string> listB = new List<string>();
                while (!reader.EndOfStream)
                {
                    var line   = reader.ReadLine();
                    var values = line.Split(',');

                    listA.Add(values[16]); // Item
                    listA.Add(values[1]);  // email
                    listA.Add(values[47]); // Method
                    listA.Add(values[6]);  // Currency
                    listA.Add(values[2]);  // Amount
                    listA.Add(values[48]); // Order ID
                                           //listB.Add(values[1]);

                    if (ctr == 0)
                    {
                    }
                    else
                    {
                        table += " <tr><td>" + ctr + "</td><td>" + values[16].ToString() + "</td><td>" + values[1].ToString() + "</td><td>" + values[47].ToString() + "</td><td>" + values[6].ToString() + "</td><td>" + values[2].ToString() + "</td><td>" + values[48].ToString() + "</td><td><a href=\"#\">[Import to Xero]</a>&nbsp;&nbsp;<a href=\"#\">[View Details</a>]</td></tr>";
                    }
                    ctr += 1;
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }

        mut.WaitOne();

        StripeConfiguration.SetApiKey("rk_live_TAhKeciddUKS2Jj955vshk6h");
        var chargeService = new StripeChargeService();
        StripeList <StripeCharge> chargeItems = chargeService.List(



            Thread th = new Thread(new StripeChargeListOptions())
        {
            Limit = 100
                    th.Start();
        });
Exemple #23
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);
        }
Exemple #24
0
 public when_listing_plans()
 {
     Cache.GetPlan();
     Cache.GetPlan();
     Cache.GetPlan();
     Cache.GetPlan();
     result = new StripePlanService(Cache.ApiKey).List(new StripePlanListOptions {
         Limit = 3
     });
 }
Exemple #25
0
 public when_listing_events()
 {
     Cache.GetCustomer();
     Cache.GetCustomer();
     Cache.GetCustomer();
     Cache.GetCustomer();
     result = new StripeEventService(Cache.ApiKey).List(new StripeEventListOptions {
         Limit = 3
     });
 }
        public override Task Execute(MessageData data)
        {
            var options = new PriceListOptions {
                Limit = 10
            };
            var service = new PriceService();
            StripeList <Price> prices = service.List(options);

            return(data.SendBack(new MessageData("pricesResponse", JsonConvert.SerializeObject(prices), A_HOUR)));
        }
Exemple #27
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);
        }
        public IEnumerable <StripeCustomer> Index()
        {
            StripeList <StripeCustomer> customerItems = customerService.List(
                new StripeCustomerListOptions()
            {
                Limit = 3
            }
                );

            return(customerItems);
        }
        public when_listing_balance_transactions()
        {
            // todo: minimize this happening every time. it only needs 4 charges present to test the list

            Cache.GetStripeCharge(Cache.ApiKey);
            Cache.GetStripeCharge(Cache.ApiKey);
            Cache.GetStripeCharge(Cache.ApiKey);
            Cache.GetStripeCharge(Cache.ApiKey);

            result = new StripeBalanceService(Cache.ApiKey).List();
        }
Exemple #30
0
        private StripeList <Plan> GetProductPlans(string productId)
        {
            var service        = new PlanService();
            var serviceOptions = new PlanListOptions
            {
                Product = productId
            };
            StripeList <Plan> plans = service.List(serviceOptions);

            return(plans);
        }
Exemple #31
0
        public JsonResult OnGetProducts(string productId)
        {
            if (string.IsNullOrEmpty(productId))
            {
                return(new JsonResult(null));
            }
            StripeList <Plan> plans = GetProductPlans(productId);

            SubscriptionPlans = new SelectList(plans, "Id", "Nickname");
            return(new JsonResult(SubscriptionPlans));
        }