Exemple #1
0
        public payouts_fixture()
        {
            // make sure the account has sufficient funds first
            new StripeChargeService(Cache.ApiKey).Create(new StripeChargeCreateOptions
            {
                Amount     = 2000,
                Currency   = "usd",
                SourceCard = new SourceCard
                {
                    Number          = "4000000000000077",
                    ExpirationMonth = 10,
                    ExpirationYear  = 2019,
                    Cvc             = "123"
                }
            });

            PayoutCreateOptions = new StripePayoutCreateOptions
            {
                Amount   = 1000,
                Currency = "usd"
            };

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

            var service = new StripePayoutService(Cache.ApiKey);

            Payout          = service.Create(PayoutCreateOptions);
            PayoutUpdated   = service.Update(Payout.Id, PayoutUpdateOptions);
            PayoutRetrieved = service.Get(Payout.Id);

            PayoutListOptions = new StripePayoutListOptions
            {
                Created = new StripeDateFilter {
                    EqualTo = Payout.Created
                },
                ArrivalDate = new StripeDateFilter {
                    EqualTo = Payout.ArrivalDate
                }
            };

            PayoutList = service.List(PayoutListOptions).ToList();
        }
Exemple #2
0
        public payouts_fixture()
        {
            // make sure the account has sufficient funds first
            new StripeChargeService(Cache.ApiKey).Create(new StripeChargeCreateOptions
            {
                Amount   = 2000,
                Currency = "usd",
                SourceTokenOrExistingSourceId = "tok_bypassPending"
            });

            PayoutCreateOptions = new StripePayoutCreateOptions
            {
                Amount   = 1000,
                Currency = "usd"
            };

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

            var service = new StripePayoutService(Cache.ApiKey);

            Payout          = service.Create(PayoutCreateOptions);
            PayoutUpdated   = service.Update(Payout.Id, PayoutUpdateOptions);
            PayoutRetrieved = service.Get(Payout.Id);

            PayoutListOptions = new StripePayoutListOptions
            {
                Created = new StripeDateFilter {
                    EqualTo = Payout.Created
                },
                ArrivalDate = new StripeDateFilter {
                    EqualTo = Payout.ArrivalDate
                }
            };

            PayoutList = service.List(PayoutListOptions);
        }
Exemple #3
0
        public UpdatePayoutsData()
        {
            try
            {
                // Get active Stripe keys
                var getStripeKeys = db.stripes.GroupBy(s => s.SecretKey).Select(x => x.FirstOrDefault()).ToList();

                foreach (var stripe in getStripeKeys)
                {
                    StripeConfiguration.SetApiKey(stripe.SecretKey);
                    // Get Payouts
                    var payoutService = new StripePayoutService();
                    StripeList <StripePayout> payoutItems = payoutService.List(
                        new StripePayoutListOptions()
                    {
                        Limit = 100
                    }
                        );
                    foreach (var payout in payoutItems)
                    {
                        if (payout.Status == "paid")
                        {
                            var checkPayout = db.stripepayouts.Where(p => p.StripePayoutID == payout.Id).ToList();
                            if (checkPayout.Count == 0)
                            {
                                // Insert Payout
                                stripepayout insertPayout = new stripepayout();
                                insertPayout.StripePayoutID = payout.Id;
                                insertPayout.PaidDate       = payout.ArrivalDate;
                                insertPayout.PropertyID     = stripe.PropertyID;
                                db.stripepayouts.Add(insertPayout);
                                db.SaveChanges();

                                // Get Payouts Payments
                                var balanceService = new StripeBalanceService();
                                StripeList <StripeBalanceTransaction> balanceTransactions = balanceService.List(
                                    new StripeBalanceTransactionListOptions()
                                {
                                    Limit    = 100,
                                    PayoutId = payout.Id
                                }
                                    );
                                foreach (var transaction in balanceTransactions)
                                {
                                    if (transaction.Description != "STRIPE PAYOUT")
                                    {
                                        stripepayoutdetail payoutDetails = new stripepayoutdetail();
                                        payoutDetails.AmountGross    = (transaction.Amount / 100.0M);
                                        payoutDetails.Fee            = (transaction.Fee / 100.0M);
                                        payoutDetails.AmountNet      = (transaction.Net / 100.0M);
                                        payoutDetails.Description    = transaction.Description;
                                        payoutDetails.StripePayoutID = insertPayout.ID;
                                        db.stripepayoutdetails.Add(payoutDetails);
                                        db.SaveChanges();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                SendUsEmail error = new SendUsEmail();
                error.sendError(e.ToString(), "Error getting iRent Payouts");
            }
        }