Kirby Memberkit - A subscription-based membership Plug-In powered by Stripe

A versatile Kirby User Membership Plug-In powered by Stripe Subscriptions for Kirby CMS.

For a couple of ideas with Kirby CMS, I thought it would be nice to have a lean membership functionality powered by Stripe (Checkout & Customer Portal).

I put a lot of effort into the README file to describe as most straightforward and easy as possible how to use the Plug-In and how the Plug-In is working. In case I missed anything please feel free to ask! :v:t2:

Attached some screenshots (since pictures say more than words) …

1. User registration with Kirby Userkit Add-On on top of Kirby´s Starterkit v3.5.3.1:


2. Show (debug) information within the intro.php snippet:


3. Stripe Checkout:


4. Redirect after successful checkout:


  1. Start the Stripe CLI within VS Code:


6. Stripe Customer Portal:


7. Stripe Customer Portal - Change plan to yearly:


8. Stripe Customer Portal - Change Email:


9. Redirect after successful Stripe Customer Portal

5 Likes

Bravo :clap:

You need to migrate existing users otherwise, the Plug-In may fail at some point.
To support you, you can now call a dedicated users method for this:

$kirby->users()->migrateStripeCustomers();

:v:t2:

I’m currently building a membership site with Kirby + Memberstack. This looks fantastic!

When a Kirby user has been created, the Kirby hook (“user.create:after”) writes the stripe customer id into the Kirby user. → Check out the source code

Stripe-customer: cus_JFnUXXXXXXX
----
Tier: Basic

(Also, the user will be logged in after successful creation.)

Recently, I added another hook within the config.php (“user.login:after”) to capture the last login within the Kirby user:

'hooks' => [
    'user.login:after' => function ($user, $session) {
      $user->update([
        'lastLogin' => date("m.d.Y")
      ]);
    }
  ],

Now, the Plug-In hook (“user.create:after”) is able to create the stripe customer successfully but fails to update the Kirby user (no exception/error), and surprisingly the hook (“user.login:after”) is able update the Kirby user! :exploding_head:

I have no clue what is going on …

@texnixe @lukasbestle

… Do you have an idea?
Or could you tell me more about the execution sequence of Kirby hooks please?
(Is it possible that one hook blocks the other to update the user?)

Where in your code is the user logged in?

Unfortunately that’s a known issue that’s very hard to fix with our current immutable objects:

In the “registration” controller.php that equals the process from the userkit Add-On.

Oh, damn. Sounds very hard to fix as well :expressionless:.

Thanks, both to you for the quick response! :clap:t2: