Exemplo n.º 1
0
 public virtual async Task <IEnumerable <StripeCustomer> > ListAsync(StripeCustomerListOptions listOptions = null, StripeRequestOptions requestOptions = null, CancellationToken cancellationToken = default)
 {
     return(Mapper <StripeCustomer> .MapCollectionFromJson(
                await Requestor.GetStringAsync(this.ApplyAllParameters(listOptions, Urls.Customers, true),
                                               SetupRequestOptions(requestOptions),
                                               cancellationToken)
                ));
 }
Exemplo n.º 2
0
 public void CleanCustomers()
 {
     try
     {
         StripeCustomerService stripeService = new StripeCustomerService("sk_0JDG46M1ff0yZRqZjz9CNKtW2Aj14");
         var options = new StripeCustomerListOptions();
         options.Limit = 10000;
         var customers = stripeService.List(options);
         foreach (var customer in customers)
         {
             stripeService.Delete(customer.Id);
         }
     }
     catch
     {
     }
 }
        private async Task <StripeCustomer> getOrCreateCustomer(string email)
        {
            var service     = new StripeCustomerService();
            var listOptions = new StripeCustomerListOptions
            {
                Limit = 1
            };

            listOptions.AddExtraParam("email", email);
            var customer = (await service.ListAsync(listOptions)).Data.FirstOrDefault();

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

            var customerCreateOptions = new StripeCustomerCreateOptions
            {
                Email = email
            };

            return(await service.CreateAsync(customerCreateOptions));
        }
Exemplo n.º 4
0
        public StripeCustomerServiceTest()
        {
            this.service = new StripeCustomerService();

            this.createOptions = new StripeCustomerCreateOptions()
            {
                Email       = "*****@*****.**",
                SourceToken = "tok_123",
            };

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

            this.listOptions = new StripeCustomerListOptions()
            {
                Limit = 1,
            };
        }
Exemplo n.º 5
0
        private async Task <StripeCustomer> getOrCreateCustomer(Domain.Order order)
        {
            var service     = new StripeCustomerService();
            var listOptions = new StripeCustomerListOptions
            {
                Limit = 1
            };

            listOptions.AddExtraParam("email", order.CustomerEmail ?? order.User.Email);
            var customer = (await service.ListAsync(listOptions)).Data.FirstOrDefault();

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

            var customerCreateOptions = new StripeCustomerCreateOptions
            {
                Email         = order.CustomerEmail ?? order.User.Email,
                BusinessVatId = order.CustomerVatNumber
            };

            return(await service.CreateAsync(customerCreateOptions));
        }
Exemplo n.º 6
0
        private static async Task <StripeCustomer> GetOrCreateCustomer(InvoiceInfo info)
        {
            var service     = new StripeCustomerService();
            var listOptions = new StripeCustomerListOptions
            {
                Limit = 1
            };

            listOptions.AddExtraParam("email", info.CustomerEmail);
            var customer = (await service.ListAsync(listOptions)).Data.FirstOrDefault();

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

            var customerCreateOptions = new StripeCustomerCreateOptions
            {
                Email         = info.CustomerEmail,
                BusinessVatId = info.CustomerVatNumber
            };

            return(await service.CreateAsync(customerCreateOptions));
        }
 public virtual IEnumerable <StripeCustomer> List(StripeCustomerListOptions listOptions = null, StripeRequestOptions requestOptions = null)
 {
     return(Mapper <StripeCustomer> .MapCollectionFromJson(Requestor.GetString(this.ApplyAllParameters(listOptions, Urls.Customers, isListMethod: true), SetupRequestOptions(requestOptions))));
 }