Discourse 订阅插件

:discourse: 摘要 Discourse 订阅 插件允许站点所有者销售定期和一次性购买的订阅,从而授予用户访问 Discourse 实例中特定分组的权限。
:open_book: 安装指南 此插件已随 Discourse 核心捆绑提供。无需单独安装该插件。

Discourse 订阅插件允许您创建一次性以及定期订阅,用户可以通过付费来访问受限内容。这是为您的社区承担托管成本的一种极佳方式。

功能

Discourse 订阅插件支持以下功能:

位于顶部导航栏中的“订阅”按钮将带您进入订阅页面 /s,该页面列出了您为站点配置的订阅:

当用户点击特定计划的“订阅”按钮后,将打开该计划的付款页面:

当用户填写其付款详情和地址并点击“订阅”后,他们会看到一条“谢谢!”消息,并被带到其账单页面:

用户还会被自动添加到您选择的分组中,以便您可以轻松查看哪些用户已订阅,并在仅该分组可见的分类中提供受限内容。

术语

  • 订阅 (Subscription) - 订阅是一种定期付款计划,允许您控制社区内容的访问权限。当创建或删除订阅时,用户会被添加或移除出与您订阅计划关联的用户分组。订阅由产品和计划组成。
  • 产品 (Product) - 在 Stripe 的术语中,产品是您销售的内容。一个产品可以包含一个或多个计划。
    • 要为您的产品添加描述,请添加一个名为 “description” 的元数据字段,并改用该字段。您可以使用 Markdown。
  • 计划 (Plan) - 计划包含价格、定期周期,并关联到一个分组,您的订阅者将获得该分组的访问权限。

:police_car_light: 请务必始终妥善且安全地保管您的 Stripe 私钥。

:warning: 如果您关闭了 Discourse 实例、卸载了此插件或您的站点离线,Stripe 将继续向您的客户收取服务费,直到订阅被取消。

配置

  1. 安装并启用插件
  2. 配置支付网关 (Stripe)
  3. 在 Stripe 中配置 Webhooks 和事件
  4. 管理 > 插件 > 已安装 > 订阅 > 设置 下添加您的 Stripe 密钥(公钥、私钥、Webhook 密钥) /admin/site_settings/category/discourse_subscriptions?filter=plugin%3Adiscourse-subscriptions.
  5. 创建一个分组,供用户通过购买加入
  6. 管理 > 插件 > 订阅 下创建产品和计划
  7. 盈利!

设置您的支付网关。

首先,您需要拥有一个 Stripe 支付网关账户。要开始使用,您可以设置一个测试模式账户,查看其工作原理,而无需进行任何真实交易或设置银行账户。插件中没有测试模式切换开关;相反,请确保使用您的开发者密钥(它们以 pk_testsk_test 开头)

在您的 Stripe 账户中设置 Webhooks 和事件

:bomb: Webhooks 对于完全实现订阅取消功能是必需的。请确保您已正确配置它们。

一旦您在 Stripe 上有了账户,您需要告诉 Stripe 您网站的地址,以便它可以通知您某些交易。您可以在 Stripe 仪表板的 Endpoints > URL 下输入此信息。

Webhooks 地址[您的服务器地址]/s/hooks – 其中 [您的服务器地址] 是您的 Discourse 安装的 URL。

您还需要告诉 Stripe 它应该通过 Webhook URL 通知您哪些事件。

目前,Discourse 订阅响应以下事件:

  • customer.subscription.deleted
  • customer.subscription.updated
  • checkout.session.completed
  • checkout.session.async_payment_succeeded

将 Stripe API 和 Webhook 密钥添加到您的插件设置中

Stripe 需要获得授权与您的网站通信。为此,它会发布一对私人和公开 API 密钥 以及用于 Web 钩子的 签名密钥

要授权 Webhooks,请将 Stripe 的 API 密钥和 Webhook 密钥添加到您的设置页面(在 Developers 下)。

:warning: 添加生产密钥将启用实时支付。如果您计划测试,请确保切换到 View test data 模式,并在 Developers 下获取 pk_testsk_test 密钥。

在您的 Stripe 账户设置中,参见:

将这些密钥添加到 管理 > 插件 > 已安装 > 订阅 > 设置 中的相应设置 /admin/site_settings/category/discourse_subscriptions?filter=plugin%3Adiscourse-subscriptions.

在 Discourse 中设置您的用户分组

当用户成功订阅您的 Discourse 应用程序后,在信用卡交易处理完成后,他们将被添加到一个用户分组中。通过将用户分配给一个用户分组,您可以管理您的用户在网站上的访问权限。用户分组是 Discourse 的核心功能,此插件除了将用户添加或移除出与您计划关联的分组外,不对其执行任何其他操作。

创建一个或多个带有计划的产品。

在 管理 > 插件 > 订阅 下,点击添加新产品。一旦您保存了产品,就可以向其添加计划。请记住,计划的价格和计费间隔在创建后无法更改。这是为了避免订阅管理方面的混淆。

如果您查看您的 Stripe 仪表板,您将看到所有这些产品和计划都被列出了。Discourse 订阅不会在本地创建它们。它们是在 Stripe 中创建的。

测试

使用以下信用卡号进行测试:

  • 4242 4242 4242 4242
  • 4111 1111 1111 1111 (无需身份验证)
  • 4000 0027 6000 3184 (需要身份验证)

更多测试卡号:Test card numbers | Stripe Documentation

访问 /s 并输入几个测试交易。

上线

当您准备上线时,请将您的 API 和 Webhook 密钥更改为生产密钥。您将需要在实时模式下创建新的产品和计划。

请注意,如果您未正确配置 Stripe Webhooks,并且定期付款因任何原因(如信用卡过期等)处理失败,用户仍将拥有分组的访问权限。要让 Stripe 自动取消订阅,请确保按照下图所示设置您的 管理失败付款 设置,并如上所述配置 Webhooks。

更新付款信息

用户可以通过访问账单页面并点击订阅旁边的编辑按钮来更新用于单个订阅的银行卡,这将打开此屏幕:

使用 Stripe 定价表的 Stripe Checkout

您还可以选择替换订阅插件的产品和结账页面,转而使用 Stripe Checkout 配合 Stripe 定价表

在您的 Stripe 仪表板中:

  1. 在 Discourse 上创建产品后,前往 Products > Product catalog
  2. 点击您想要包含在定价表中的产品
  3. 点击 Edit product
  4. 点击 More Options 并在 Metadata 下输入以下内容:
    • Key: group_name
    • Value: Discourse 上的分组名称(例如 trust_level_0
  5. 点击 Update product 保存

:red_exclamation_mark: 确保分组名称与 Discourse 上 User_Groups 下选择的分组相匹配

创建您的 Stripe 定价表

  1. 前往 Products > Pricing tables
  2. 创建一个新的表并添加您刚刚创建的产品
  3. 发布表格后,复制嵌入代码中找到的定价表 ID(它以 prctbl_... 开头)
  4. 将定价表 ID 粘贴到您的 discourse_subscriptions_pricing_table_id 中,并启用订阅定价表设置。
  5. 点击绿色对勾以保存这两个设置。

建议步骤:

在 Stripe 内部设置定价表时,建议在结账完成后将用户重定向到您的站点,否则他们将停留在 Stripe 确认页面上,而没有返回您站点的链接。

重定向到 https://<your-site>/my/billing/subscriptions 是订阅的好选择。对于一次性付款,您可以直接链接到 https://<your-site>/my/billing/payments

自动收取税款

要启用自动收取税款,请勾选站点设置中的 discourse_subscriptions_enable_automatic_tax 复选框。

如果您启用了此功能,但未正确配置您的 Stripe 实例以收取税款,用户在完成结账流程后可能会看到此弹出窗口:

这里有此指南提供更多详细信息,但由于插件现在正在传入适当的 automatic_tax[enabled]=true 参数(步骤 5),所以不需要做太多事情。

请确保您也配置了您的注册信息(步骤 4):

这是一个 Stripe 中 Discourse 订阅插件交易的示例,显示税款已自动收取:

设置

名称 描述
discourse subscriptions enabled 启用 Discourse 订阅插件。
discourse subscriptions extra nav subscribe 在主导航中显示订阅按钮
discourse subscriptions public key Stripe 可发布密钥
discourse subscriptions secret key Stripe 秘密密钥
discourse subscriptions webhook secret Stripe Webhook 密钥
discourse subscriptions currency 默认货币代码。在创建订阅计划时可以覆盖此设置。
discourse subscriptions campaign enabled 启用一个活动横幅,以推广对该社区的财务支持。
discourse subscriptions campaign goal 您的支持活动的数值目标(订阅者数量或筹集金额)。
discourse subscriptions campaign type 选择要运行的活动类型(订阅者数量或每月筹集金额)。
discourse subscriptions campaign banner location 选择活动横幅的位置(顶部或侧边栏)。
discourse subscriptions campaign banner bg image 上传自定义图像用作活动横幅的背景。
discourse subscriptions campaign banner shadow color 选择活动横幅投影的颜色。
discourse subscriptions campaign show contributors 显示最近购买订阅产品的用户头像。
discourse subscriptions campaign product 当支持者点击活动上的按钮时,要发送给他们的 Stripe 产品 ID。如果此设置为空,支持者将被引导至主要产品页面。
discourse subscriptions campaign grant 授予用户一个月的免费订阅
discourse subscriptions pricing table id 来自嵌入代码的 Stripe 定价表 ID
discourse subscriptions pricing table enabled 启用使用 Stripe 定价表并替换现有的订阅页面
discourse_subscriptions_enable_automatic_tax 切换是否收取销售税。需要在 Stripe 中进行一些设置。
discourse_subscriptions_enable_verbose_logging 启用更详细的日志记录以辅助调试。请勿在生产环境中永久启用。

:discourse2: 由我们托管? 此插件在我们的 Pro、Business 和 Enterprise 托管计划中可用 Subscriptions | Discourse - Civilized Discussion

139 个赞
Steady plugin for community funding
ProCourse Memberships :money_with_wings:
Group membership subscriptions with profit split
Email drip campaign
How to give unpaid users limited access without making Discourse private?
Super simple Discourse-Wordpress-membership integration
Discourse for Membership Association Members?
Please suggest a good Discourse Plugin for Membership that supports Indian Payment Gateway
Allow users to donate to pay hosting fees for a site
Login required after some days of free access
User can't repurchase a subscription product after canceling
User Card Directory
Subscription Access To Discourse
Multiple paywalls with common communication hub
Discourse Subscriptions + btcpayserver
Do I need Wordpress? Or Discourse can be my solution to ALL?
Send an invite to a user but complete their profile programmatically
Discourse subscriptions - changing price during recurring subscription
Any good Memberpress alternatives for wordpress?
Add user to group after purchase
How to move Topics in Category into their own Pinned Topic inside new Categories?
Discourse Subscriptions - user not removed from group when subscription cancelled
Discourse Subscriptions - user not removed from group when subscription cancelled
Discourse vs Skool
Subscription Access To Discourse
Tax implication of funding a forum
Discourse Unlock
Tick badge for username?
Subscription update problem
Setting up a subscription group
How would I install a cryptocurrency paywall?
Charging a membership fee
Discourse Subscriptions with Thrive Cart
Admin creating subscription for user
Plugin for charity donations?
Allow subscription of predetermined length
Link Sign Up to Subscriptions Plugin
User monetization with group access?
Discourse Category Lockdown
Allow option to open Stripe payment website
Is it possible to use the subscription plugin to limit creating topics in a category to subscribers?
Best approach to a landing page/payment front end
Managing consumable AI costs
Allow multiple ‘new topic’ drafts
Stripe iframe causes a blank page on my print layout
No 'deleted' event in Stripe?
Tell us how you manage subscriptions on Discourse
Addding a paid group who can reply to topics but not create them
Integration with WP membership Pro
Alternative sign up pathways
Control Category Visibility and Access by User Levels
Tighter integration of account-creation and subscriptions?
Does the Subscriptions plugin work with "one-off" payment pricing tables?
Subscriber group automation (Remove and Add users to specific group with subscription)
"Support Us" Banner Not Updating
Tip or Pay Button - for user post/content, does it exist already?
May I or can I monetize my forum?
May I or can I monetize my forum?
Bundling more popular plugins with Discourse core
Guest Gate Theme Component
Error loading route Caused by plugin 'discourse-subscriptions'
Embed a list of Discourse topics onto an external site
Blank page when resuming discourse app
Why doesn't Discourse hosting include the Subscriptions plugin on the Starter plan?
Hosting questions
Discourse Category Lockdown
Rebuild fails when these plugins are present
Changing excerpt length
Installing discourse for free?
Just migrated a Xenforo site to Discourse
Just migrated a Xenforo site to Discourse
Options to manage payments for paid Discourse communities
Using a plug-in to monetize my Discourse
ProCourse Memberships :money_with_wings:
UX: Add metadata to subscription page to improve SEO and link UI design
A feature request related to this plugin. Pointed questions or rewarded questions
Plugin to use Discourse for classified ads or as a job board?
Subscription Plugin not working (Error)
How to set message limits for user groups?
API POST for New User
ProCourse Memberships :money_with_wings:
Steady plugin for community funding
New customer setup
Making group joins automatic to an external pricing plan
Platform integration - videos
Any way to accept paypal or stripe payment at signup?
Looking for feedback on Discourse Subscriptons
WooCommerce Discourse Website newbie help
Switching to Discourse Subscriptions from WordPress Subscriptions
Integration with Wix.com membership to only let the paid member can access to Discourse
2020: The Year in Review
Managing Subscriptions through Wordpress (Ultimate Member + Paid Memberships Pro)
How does uninstalling the Subscriptions plugin affect Stripe billing?
Memberful opinions?
Is there an E-commerce plugin for Discourse?
Memberful opinions?
Prefill custom html with user's email address?
Can't make the subscription plugin work
How to charge members for my Discourse website?
Pay or Play usage?
Latest topics on homepage with only members to read in detail?
Banner text customization for Subscriptions plugin
Subscriptions: Change User's Plan
Donation Bar for House Ad
Can I use the Subscriptions plugin on my own server?
Limiting Subscription Length
Discourse Subscriptions - use API to find out product, plan and renewal date

5 个帖子已拆分为新主题:测试模式中存在类似对象错误

设置 Sidebar 似乎无效(最新 Discourse aeb3d717dc,最新插件 cc43d32a)。

1 个赞

我也收到了这个日志消息:

弃用通知:图标名称“donate”已更新为“circle-dollar-to-slot”。请在您的代码中使用新名称。旧名称将在 2025 年第二季度移除。[deprecation id: discourse.fontawesome-6-upgrade] [info: https://meta.discourse.org/t/325349]

编辑:为此创建了一个 PR

3 个赞

2 篇帖子已合并到现有主题:"Support Us" Banner Not Updating

嗯……在本地,当我切换到侧边栏时,它会显示在侧边栏中。

如果您将其放在侧边栏中,我们会添加此 CSS 类,您可以检查您的页面并搜索 subscription-campain-sidebar

它只是停留在顶部吗?

我现在明白了。我将“类别”页面设为了默认页面。它显然不会显示在那里。它在“最新”列表中显示。所以它工作正常。谢谢!

3 个赞

它应该真的显示在“类别”页面(或其他默认页面)上,不是吗?

1 个赞

由于中国大陆的限制,Stripe 通过审核较为困难。您能考虑集成支付宝或微信支付的接口吗?

2 个赞

过去类似的问题的答案是“要做的是为支付宝或微信支付创建一个插件”。discourse.org 的收入来自付费托管的用户,我不认为他们有很多想要支付宝或微信支付的企业客户,所以你需要询问 Marketplace 或自己开发。也许你可以让支付宝或微信支付资助开发。

3 个赞

我已经完成了 1-5,但我猜我是笨蛋或者瞎了。我似乎找不到在我的服务器上设置产品和计划的界面。

哎呀,算了……我找到了。最后一块拼图是我不理解这个:

  • 要为您的产品添加描述,请添加一个名为“description”的元数据字段,并改用该字段。您可以使用 Markdown。

我相信我已经正确设置了一切。如果我检查设置:
订阅按钮将显示嵌入式定价表,并将使用 Stripe Checkout。
然后购买可以正常工作,但是,如果我不选中它并使用内置界面,我会收到错误框,例如:

\u003e期望存在类型为 card 的付款方式,但此 PaymentIntent 没有付款方式且未提供任何付款方式。请尝试再次提供 payment_method 或 payment_method_data 参数。

或者

\u003e此客户没有附加的付款来源或默认付款方式。请考虑添加默认付款方式。有关更多信息,请访问 https://stripe.com/docs/billing/subscriptions/payment-methods-setting#payment-method-priority.

顶部的错误是非定期计划,底部是定期计划。\n有什么线索可以解决它吗?我更喜欢内置界面。

我解决了这个问题,看起来在我测试环境中玩弄用户时,Stripe 不喜欢我将同一个 Discourse 用户与不同的“订阅用户”一起使用。

另外,楼主应该澄清一下

\u003e要为您的产品添加描述,请添加一个名为“description”的元数据字段,然后改用该字段。您可以使用 Markdown。

转到 Stripe Dashboard,单击产品目录,单击产品,然后单击价格。在这里,您将找到可以添加描述的元数据字段。

但是,对我来说似乎不起作用。我添加了一个测试描述,在使用 Stripe 表格或内置布局时都没有任何变化。

已将 6 篇帖子合并到一个现有主题中:向 Discourse 订阅添加不同的支付方式

一篇帖子被合并到一个现有主题中:向 Discourse 订阅添加不同的支付方式

当我尝试创建产品时,我只会收到“500”错误。我正在测试环境中进行配置。我能检查什么来找出服务器错误的原因?

优惠券上也有类似的情况

是否在 {YOURFORUM}/logs 中同时创建了一个条目?

2 个赞

哇哦.. 真不知道有这样一个页面。显示无效的 API 密钥。我输入了一些垃圾内容作为密钥,以便现在可以继续前进并配置订阅包,稍后在我准备好测试时再回到密钥。

1 个赞

插件配置得很顺利,但后来我才意识到,这个插件只支持定期订阅,不支持一次性订阅(在规定期限后过期)。

例如,收取 X 金额 30 天。 30 天后,用户将从高级群组中移除。如果他们愿意,可以再次购买。通常我提供 1 个月、3 个月、12 个月的会员资格。

Stripe 要求我注册为公司才能支持定期付款。我在 XenForo 上进行一次性付款,XenForo 的原生功能会处理订阅过期和从群组成员资格中移除。

这完全打乱了我一个月内迁移到 discourse 的计划。 :cry:

我有一个解决方案。我可以帮助你创建一个 github action,它将从数据浏览器中提取数据,其中包括用户名和组 ID,以便将他们从中移除,然后相应地更改他们的组。

我正在为一个迁移到 Discourse 的客户做这件事,他们有一个包含日期的自定义字段。因此,我们需要将用户移动到一个即将过期的组,给他们一个横幅,然后在时间到期时将他们从付费组中移除。

如果你有预算,你可以联系我或在 Marketplace 中提问。我计划写一篇关于它的博客文章,其中包含一个通用示例,如果我能抽出时间的话。

6 个赞

你好,直到 Stripe 回调成功之前,订阅功能都能正常工作。我正在使用 Stripe 定价表。

我可以在 admin/plugins/discourse-subscriptions/subscriptions 页面看到订阅已成功注册。

但是,用户尚未被移至所需的用户组。

我已经配置了产品,其产品名称与 Stripe 上的完全一致,并且我还创建了一个已选择用户组的定价计划。我将定价计划的价格设置为零,因为我认为对于 Stripe 定价表配置来说,价格无关紧要。

我还遗漏了什么?