Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/riazahmad0027/my-subscription-system/archive/refs/heads/main.zipA custom WooCommerce plugin that adds recurring subscriptions with Stripe. It's built from scratch, with no third-party subscription plugin.
Status: working in test mode. Being prepared for live use.
What works now
- "Billing period" option on any WooCommerce product: none, monthly or yearly
- A subscription is created automatically when an order is paid or completed
- Customers start monthly or yearly payments through Stripe Checkout, from the order thank-you page
- Stripe webhooks with signature verification. Activation, renewals, failed payments and cancellations update subscriptions automatically
- Next billing date updated from Stripe on every renewal
- Admin page (WP Admin → Subscriptions) listing all subscriptions with their status
- REST API endpoint
kashif-bakers/v1/subscriptions, restricted to shop managers - Private debug log, protected from public access
Architecture
my-subscription-system.php: main file, autoloader, database table on activationincludes/Plugin.php: loads all parts, admin menu and order hooksincludes/ProductFields.php: billing period field on productsincludes/Subscription.php: creates and cancels subscriptionsincludes/SubscriptionCheckout.php: "Start payments" button and Stripe Checkout sessionincludes/StripeClient.php: small client for the Stripe APIincludes/WebhookHandler.php: verifies Stripe signatures and updates subscriptionsincludes/RestApi.php: REST endpointincludes/Logger.php: debug logging
Setup
-
Upload the plugin folder to
wp-content/plugins/and activate it (WooCommerce required). -
Add your Stripe keys to
wp-config.php(never put keys in the plugin code):define('MSS_STRIPE_SECRET_KEY', 'sktest...'); define('MSS_STRIPE_WEBHOOKSECRET', 'whsec...');
-
In Stripe, add a webhook pointing to:
https://yoursite.com/wp-json/kashif-bakers/v1/webhooks/stripewith the eventscheckout.session.completed,invoice.paid,invoice.payment_failedandcustomer.subscription.deleted. -
Edit a product, choose a billing period, and save.
Tested with
WordPress 7.1, WooCommerce 11, PHP 8.3, Stripe test mode.
Author
Riaz Ahmad, WordPress and WooCommerce developer Riaz Ahmad · Portfolio
License
GPL-2.0-or-later