예제 #1
0
        public async Task <StripeList <PaymentIntent> > GetPayments(string customerId, string startingAfter = null)
        {
            var service = new PaymentIntentService();
            var items   = await service.ListAsync(new PaymentIntentListOptions
            {
                Customer      = customerId,
                Limit         = 100,
                StartingAfter = startingAfter
            });

            return(items);
        }
예제 #2
0
        public async Task <PaymentIntentDao> GetPaymentIntentByCustomerId(string paymentCustomerId, CancellationToken cancellationToken)
        {
            Guard.Argument(paymentCustomerId, nameof(paymentCustomerId)).NotNull().NotEmpty().NotWhiteSpace();

            var options = new PaymentIntentListOptions
            {
                Customer = paymentCustomerId
            };

            var paymentIntent = await _paymentIntentService.ListAsync(options : options, cancellationToken : cancellationToken);

            return(paymentIntent?.FirstOrDefault().ToPaymentIntentDao());
        }
        /// <summary>
        /// Get a list of payments for an user
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <dynamic> GetPayments(string id)
        {
            try
            {
                Models.Customer customer = await context.customers.Where(c => c.accountId == id).FirstOrDefaultAsync();

                if (customer == null)
                {
                    return(null);
                }

                StripeConfiguration.ApiKey = key;
                var options = new PaymentIntentListOptions
                {
                    Limit    = 50,
                    Customer = customer.customerId
                };
                var service = new PaymentIntentService();
                StripeList <PaymentIntent> payments = await service.ListAsync(
                    options
                    );

                List <PaymentIntentInformation> pi = new List <PaymentIntentInformation>();
                foreach (var p in payments)
                {
                    pi.Add(new PaymentIntentInformation {
                        id = p.Id, description = p.Description, value = (double)p.Amount / 100
                    });
                }

                return(pi);
            }
            catch (Exception)
            {
                return(null);
            }
        }