Chargebee subscriptions plugin

AI-generated summary

The Chargebee subscriptions plugin for Discourse allows integration with Chargebee as a third-party billing service. The plugin creates an endpoint to listen for Chargebee events, records these events in a database table, and adds a chargebee_id field to users and invites. After installation, users must generate an API key and configure a Chargebee webhook.

The plugin currently supports the following event handlers:

  • Creating a customer triggers a Discourse invitation, associating the chargebee customer ID with the user upon invitation acceptance.
  • Cancelling a subscription suspends the corresponding user.
  • Reactivating a subscription unsuspends the user.

ky_metro suggests refining the plugin to tie paid subscriptions to specific group memberships, allowing users to retain access to public areas after their membership expires. riking recommends replacing database migrations with PluginStoreRow to avoid potential issues.

A little rough but seems to work, feedback appreciated: GitHub - liliakai/discourse-chargebee · GitHub

This plugin creates an endpoint that listens for Events from Chargebee. The migrations create a table for recording chargebee events, as well as adding a chargebee_id field to users and invites.

After installing, generate an api key in Discourse for the system user and configure a webhook in Chargebee that points at <site_url>/chargebee?api_key=<api_key>.

The intended use case is a paywalled Discourse instance using Chargebee as a third party billing service. Hence, the following event handlers:

When a customer is created, they are invited to Discourse. If they accept the invitation, their chargebee customer id is associated with the resulting Discourse user. This is handled by storing chargebee_id on the invite and then cloning it over to the resulting User in an :after_create hook.

When a subscription is cancelled, the corresponding Discourse User is suspended.

When a subscription is reactivated, the corresponding Discourse User is unsuspended.

4개의 좋아요

A little refinement you might consider… instead of straight up suspending/unsuspending people, have an option to tie their paid subscription to a specific group membership.

For example our forum has a public area and a paid Premium area. Members in the Premium group can access special discussion areas. When the membership expires, they are removed from the Premium group. But they still have access to the public area.

1개의 좋아요

Using database migrations in a plugin is a recipe for disaster. I highly suggest you change to using PluginStoreRow.

1개의 좋아요