static void GetRefundsForLast24Hours(StripeChargeService chargeService, TraceWriter log)
        {
            StripeRefundService refundService = new StripeRefundService();

            refundService.ExpandBalanceTransaction = true;
            refundService.ExpandCharge             = true;

            StripeRefundListOptions refundListOptions = new StripeRefundListOptions()
            {
                Limit = 50
            };

            DateTime greaterEqualCreated = DateTime.UtcNow.AddHours(-24);

            IEnumerable <StripeRefund> refunds;
            string   lastObjectId      = null;
            DateTime?lastRefundCreated = null;

            do
            {
                refunds = refundService.List(refundListOptions);
                foreach (var r in refunds)
                {
                    //var c = chargeService.Get(r.ChargeId);
                    //var trans = StripeChargeToStripeTransaction(c);

                    var trans = StripeRefundToStripeTransaction(r);
                    UpsertStripeTransaction(trans, log);
                }
                lastObjectId      = refunds.LastOrDefault()?.Id;
                lastRefundCreated = refunds.LastOrDefault()?.Created;
                refundListOptions.StartingAfter = lastObjectId;
                log.Info($"Refund last ObjectId: {lastObjectId}. Created: {lastRefundCreated} ");
            } while (refunds.Count() == 10 && lastRefundCreated.HasValue && lastRefundCreated.Value >= greaterEqualCreated);
        }
Exemplo n.º 2
0
        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);
        }
 public virtual async Task <IEnumerable <StripeRefund> > ListAsync(StripeRefundListOptions listOptions = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default)
 {
     return(Mapper <StripeRefund> .MapCollectionFromJson(
                await Requestor.GetStringAsync(
                    this.ApplyAllParameters(listOptions, $"{Urls.BaseUrl}/refunds", true),
                    SetupRequestOptions(requestOptions),
                    cancellationToken
                    )
                ));
 }
Exemplo n.º 4
0
        public StripeRefundServiceTest()
        {
            this.service = new StripeRefundService();

            this.createOptions = new StripeRefundCreateOptions()
            {
                Amount = 123,
            };

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

            this.listOptions = new StripeRefundListOptions()
            {
                Limit = 1,
            };
        }
Exemplo n.º 5
0
 public virtual IEnumerable <StripeRefund> List(StripeRefundListOptions listOptions = null, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeRefund> .MapCollectionFromJson(Requestor.GetString(this.ApplyAllParameters(listOptions, Urls.BaseUrl + "/refunds", isListMethod: true), SetupRequestOptions(requestOptions))));
 }