public creating_and_updating_invoices_with_manual_invoicing()
        {
            var customerService    = new StripeCustomerService(Cache.ApiKey);
            var invoiceItemService = new StripeInvoiceItemService(Cache.ApiKey);
            var invoiceService     = new StripeInvoiceService(Cache.ApiKey);

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

            var InvoiceItemCreateOptions = new StripeInvoiceItemCreateOptions
            {
                Amount     = 1000,
                Currency   = "usd",
                CustomerId = Customer.Id
            };
            var InvoiceItem = invoiceItemService.Create(InvoiceItemCreateOptions);

            var InvoiceCreateOptions = new StripeInvoiceCreateOptions
            {
                Billing      = StripeBilling.SendInvoice,
                DaysUntilDue = 7,
            };

            InvoiceCreated = invoiceService.Create(Customer.Id, InvoiceCreateOptions);

            var InvoiceUpdateOptions = new StripeInvoiceUpdateOptions
            {
                Paid = true,
            };

            InvoiceUpdated = invoiceService.Update(InvoiceCreated.Id, InvoiceUpdateOptions);
        }
Example #2
0
        public async Task <bool> CreateInvoiceAsync(Domain.Order order)
        {
            var customer = await getOrCreateCustomer(order);

            var service = new StripeInvoiceItemService();

            foreach (var line in order.OrderLines)
            {
                var createInvoiceLineOptions = new StripeInvoiceItemCreateOptions
                {
                    Amount      = (int)(line.LineTotal * 100m), // inclusive of quantity & tax
                    Currency    = "nok",                        // TODO: read this from config
                    CustomerId  = customer.Id,
                    Description = !string.IsNullOrWhiteSpace(line.ProductVariantName) ? $"{line.ProductName} ({line.ProductVariantName})" : line.ProductName,
                };
                var invoiceLineItem = await service.CreateAsync(createInvoiceLineOptions);
            }

            var eventInfo            = order.Registration.EventInfo;
            var createInvoiceOptions = new StripeInvoiceCreateOptions
            {
                Billing      = StripeBilling.SendInvoice,
                DaysUntilDue = eventInfo.DateStart.HasValue ? ((eventInfo.LastCancellationDate ?? eventInfo.LastRegistrationDate ?? eventInfo.DateStart) - DateTime.UtcNow).Value.Days : 30,
                Description  = $"Deltakelse for {order.Registration.ParticipantName} på {order.Registration.EventInfo.Title} "
            };
            var createInvoiceService = new StripeInvoiceService();
            await createInvoiceService.CreateAsync(customer.Id, createInvoiceOptions);

            return(true);
        }
        public static StripeInvoiceItemCreateOptions Valid(string customerId)
        {
			var stripeInvoiceItemCreateOptions = new StripeInvoiceItemCreateOptions()
            {
				AmountInCents = 1000,
				Currency = "usd",
				CustomerId = customerId,
				Description = "Test Invoice Item"
            };

			return stripeInvoiceItemCreateOptions;
        }
        public static StripeInvoiceItemCreateOptions Valid(string customerId)
        {
            var stripeInvoiceItemCreateOptions = new StripeInvoiceItemCreateOptions()
            {
                AmountInCents = 1000,
                Currency      = "usd",
                CustomerId    = customerId,
                Description   = "Test Invoice Item"
            };

            return(stripeInvoiceItemCreateOptions);
        }
Example #5
0
        public static StripeInvoiceItemCreateOptions Valid(string customerId)
        {
            var stripeInvoiceItemCreateOptions = new StripeInvoiceItemCreateOptions()
            {
                Amount      = 1000,
                Currency    = "usd",
                CustomerId  = customerId,
                Description = "Test Invoice Item",
                Metadata    = new Dictionary <string, string>
                {
                    { "A", "Value-A" },
                    { "B", "Value-B" }
                }
            };

            return(stripeInvoiceItemCreateOptions);
        }
		public static StripeInvoiceItemCreateOptions Valid(string customerId)
		{
			var stripeInvoiceItemCreateOptions = new StripeInvoiceItemCreateOptions()
			{
				Amount = 1000,
				Currency = "usd",
				CustomerId = customerId,
				Description = "Test Invoice Item",
				Metadata = new Dictionary<string, string>
				{
					{ "A", "Value-A" },
					{ "B", "Value-B" }
				}
			};

			return stripeInvoiceItemCreateOptions;
		}
Example #7
0
        public StripeInvoiceItemServiceTest()
        {
            this.service = new StripeInvoiceItemService();

            this.createOptions = new StripeInvoiceItemCreateOptions()
            {
                Amount     = 123,
                Currency   = "usd",
                CustomerId = "cus_123",
            };

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

            this.listOptions = new StripeInvoiceItemListOptions()
            {
                Limit = 1,
            };
        }