【问题标题】:stripe recurring payments per cycle for quantity plans为数量计划划分每个周期的定期付款
【发布时间】:2021-03-02 15:58:15
【问题描述】:

亲爱的,

我正在开发一个具有每月和每年订阅两个计划间隔的系统 每个数量的订阅成本,以便客户可以根据需要增加和减少订阅

我有一个包含以下列的订阅表

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;

我需要为每个订阅周期的发票制作月度报告

我的问题是续订时究竟发生了什么current_period_startcurrent_period_end 列已更新为新的订阅周期我如何获取每个周期的发票,因为订阅的开始和结束日期并不总是从当月的第一天开始

谢谢

【问题讨论】:

    标签: laravel stripe-payments


    【解决方案1】:

    最简单的方法是列出属于特定订阅 [1] 的发票。这些月度/年度发票将按时间倒序排列。最上面的发票将始终是为当前计费周期创建的(假设许可而不是使用报告计费)。

    您还可以在订阅周期中侦听 invoice.created 事件的 webhook 事件,并在发票到达时在您自己的系统中处理它们 [2]。

    [1]https://stripe.com/docs/api/invoices/list#list_invoices-subscription

    [2]https://stripe.com/docs/webhooks

    【讨论】:

      猜你喜欢
      • 2018-06-17
      • 2018-01-10
      • 2020-06-01
      • 2013-09-02
      • 2020-03-06
      • 2021-03-16
      • 2015-10-04
      • 2014-12-07
      • 2015-02-09
      相关资源
      最近更新 更多