Dears,
I'm working on a system with tow plans interval monthly and yearly subscriptions the cost of the subscription per quantity so the customer can increment and decrement the subscriptions as he wants
I have a subscriptions table with the following column
CREATE TABLE `subscriptions` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`company_company_id` int NOT NULL,
`plan_name` varchar(191) NOT NULL,
`product_id` varchar(100) DEFAULT NULL,
`subscription_stripe_id` varchar(191) NOT NULL,
`stripe_status` varchar(191) NOT NULL,
`stripe_price_id` varchar(191) DEFAULT NULL,
`quantity` int DEFAULT NULL,
`amount` float DEFAULT NULL,
`trial_ends_at` timestamp NULL DEFAULT NULL,
`ended_at` timestamp NULL DEFAULT NULL,
`ends_at` timestamp NULL DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`interval` varchar(20) DEFAULT NULL,
`current_period_start` timestamp NULL DEFAULT NULL,
`current_period_end` timestamp NULL DEFAULT NULL,
`cancelled_at` timestamp NULL DEFAULT NULL,
`cancellation_reason_id` int DEFAULT NULL,
`cancellation_notes` text,
PRIMARY KEY (`id`),
KEY `subscriptions_company_id_stripe_status_index` (`stripe_status`)
) ENGINE=InnoDB AUTO_INCREMENT=75 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
I need to make a monthly report for invoices for each subscription cycle
my questions what happened exactly when renewing subscriptions current_period_start and current_period_end column is updated to the new subscriptions cycle how I can get invoices per cycle because the subscriptions start and end date not always start from the first day of the month
thanks
The simplest thing would be to list the Invoices that belong to a particular Subscription [1]. Those monthly/yearly Invoices will be listed in reverse chronological order. The topmost Invoice will always be the on created for the current billing period (assuming licensing and not usage reported billing).
You could also listen for webhook events for invoice.created
events as the Subscription cycles and process the Invoices in your own system as they arrive [2].
[1] https://stripe.com/docs/api/invoices/list#list_invoices-subscription
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.