Complete documentation of the free 1-month trial lifecycle (activation on approval, start/end dates, status, upgrade, expiration) and monthly/annual subscription plans with annual discounts.
Purpose of FunctionExplain the exact trial and subscription plan rules implemented in Kariahku.com.
PrerequisitesAn `active` mosque with `subscriptions.view` permission at `/mosque-admin/subscription`.
Required User PermissionsMosque Scope: subscriptions.view (/mosque-admin/subscription) | Institution Scope: subscription.view
A. Free One-Month Trial
Mosque Registration & Trial Activation: When a mosque application is approved at /admin/mosques, subscription_start_mosque_trial() automatically provisions a billing customer (billing_customers) and activates a trialing subscription on the Mosque Standard Plan (mosque-standard).
Trial Start & End Dates: The trial spans exactly 1 calendar month from approval (trial_starts_at to trial_ends_at), clamped accurately to month-end dates via subscription_add_month_count().
One-Trial-Per-Mosque Rule: Setting mosques.trial_consumed = 1 ensures each mosque receives the free trial once.
Subscription Upgrade: At any point during trialing, the Mosque Administrator can open /{lang}/mosque-admin/subscription, select a billing interval, and generate a paid invoice.
Trial Expiration: When trial_ends_at passes without payment:
Subscriptions with an open invoice transition to past_due and then a 7-day grace_period before becoming expired.
When expired or suspended, paid management features (`microsite_customization`, `announcements`, `activity_publishing`, `committee_management`, `editorial_publishing`, `kariah_membership`) are write-locked while all existing data and prayer times remain preserved.
B. Subscription Plans & Annual Payment Discounts
The table below lists the seeded subscription plans and pricing intervals in subscription_plans and subscription_plan_prices (configurable by Super Admin at /admin/subscriptions):
Viewing Current Plans: Visit /{lang}/mosque-admin/subscription (or /main/subscription / /jakim/subscription) to view current plan status, period end date, and interval pricing.
Changing Plans or Renewing: Select a Plan and Billing Interval (monthly, quarterly, semiannual, or annual) and click Generate Renewal Invoice.
Free One-Month Trial Status, Subscription Plans, and Annual Discounts (/mosque-admin/subscription).
Input Fields & Options Reference
Plan Code
Customer Type
Billing Interval
List Price
Discount
Net Payable
mosque-standard
Mosque (mosque)
Monthly (monthly)
RM 50.00
0%
RM 50.00
mosque-standard
Mosque (mosque)
Quarterly (quarterly)
RM 150.00
0%
RM 150.00
mosque-standard
Mosque (mosque)
Semi-Annual (semiannual)
RM 300.00
0%
RM 300.00
mosque-standard
Mosque (mosque)
Annual (annual)
RM 600.00
10% (RM 60.00)
RM 540.00
main-standard
MAIN (main)
Monthly / Annual
RM 500.00 / RM 6,000.00
0% / 10%
RM 500.00 / RM 5,400.00
jakim-standard
JAKIM (jakim)
Monthly / Annual
RM 2,000.00 / RM 24,000.00
0% / 10%
RM 2,000.00 / RM 21,600.00
Expected Results: Mosque and institutional administrators understand trial dates, plan pricing, annual discounts, and how to generate renewal invoices.
Important Notes & Data Boundaries: Already-issued invoices lock in their subtotal, discount, and amount due at issuance time.
Common Errors & Troubleshooting
If paid mosque management forms return HTTP 402, open /mosque-admin/subscription and pay the open renewal invoice to immediately restore full access.
SEC-11C · Section 11: Subscription and Billing Management✓ Fully Implemented
Step-by-step instructions for paying subscription invoices via toyyibPay (FPX, DuitNow QR, Card) or Manual Bank Transfer, downloading PDF invoices and receipts, and resolving failed or overdue payments.
Purpose of FunctionGuide Mosque Administrators and Institutional Officers through completing subscription payments and retrieving official billing documents.
PrerequisitesAn open invoice (`issued` or `overdue`) at `/mosque-admin/subscription`, `/main/subscription`, or `/jakim/subscription`.
Manual Bank Transfer (manual_transfer — Internal): Direct bank transfer accompanied by proof-of-payment file upload (PDF, JPG, or PNG, max 5 MB) for platform verification.
Institutional Invoice (institutional_invoice — Internal): Purchase Order / credit terms workflow for MAIN and JAKIM government authorities.
2. Making Subscription Payments
Open /{lang}/mosque-admin/subscription (or /main/subscription / /jakim/subscription).
Locate your open invoice (status issued or overdue) in the Invoices and Payment History table.
Online Gateway Checkout (toyyibPay): Select FPX, DuitNow QR, or Card and click Pay. After completing checkout on toyyibPay, you return to /payment/return while the server callback (/payment/toyyibpay-callback) verifies the MD5 signature and activates your subscription.
Manual Bank Transfer (Mosque): Enter the Bank Reference, upload your Payment Proof (PDF/JPG/PNG ≤ 5 MB), and submit. The payment enters pending_verification until approved at /admin/payments.
3. Viewing Payment History & Downloading Invoices / Receipts
Download Invoice PDF: Click Invoice PDF (/payment/invoice?id={invoice_id}) on any invoice row.
Download Official Receipt PDF: Once an invoice is settled (paid), click Receipt PDF (/payment/receipt?id={receipt_id}) to download the official receipt numbered RCP-YYYYMMDD-....
Failed Payments: If a gateway checkout fails or a manual transfer is rejected, the invoice remains open so you can initiate a fresh payment attempt.
Overdue & Grace Period: Unpaid invoices past due_at move the subscription through past_due → 7-day grace_period → expired.
Automatic Reactivation: As soon as payment is confirmed, payment_apply_settled_invoice() automatically transitions the subscription back to active and advances the service period dates.
Customer owner (Mosque / Institution) or Platform Billing Admin.
/payment/receipt?id={id}
RCP-YYYYMMDD-XXXXXX
Customer owner (Mosque / Institution) or Platform Billing Admin.
/payment/proof?id={id}
Uploaded Proof File
Customer owner or Platform Admin with payments.manage.
Expected Results: Subscription payments are processed securely, PDF invoices and receipts are downloadable on demand, and expired subscriptions reactivate upon settlement.
Important Notes & Data Boundaries: Invoices remain accessible even when a mosque or institutional subscription has expired so administrators can always download invoices and complete renewal.
Common Errors & Troubleshooting
If you uploaded a manual bank transfer proof and the subscription is not yet active, wait for a Platform Administrator to verify the transfer at /admin/payments.
SEC-11D · Section 11: Subscription and Billing Management✓ Fully Implemented
Step-by-step instructions for Super Administrators to manage subscription plans, configure fees and annual discounts, manage trial accounts, verify manual payments, and review revenue reports.
Purpose of FunctionEnable Platform Billing Administrators to govern pricing, verify bank transfer proofs, configure gateway credentials, and monitor billing revenue.
PrerequisitesSigned in as `super_admin` (`subscriptions.manage` and `payments.manage`).
Required User PermissionsGlobal Scope: subscriptions.manage (/admin/subscriptions) & payments.manage (/admin/payments)
In the plan pricing form, configure the list prices for monthly, quarterly, semiannual, and annual intervals and set the Annual Discount Percentage (0% to 90%, default 10%).
Click Save Pricing.
In the customer subscriptions table, you can inspect trial accounts, issue invoices, or apply administrative lifecycle transitions with a mandatory reason note. You can also run daily lifecycle maintenance via CLI:
In the Pending Payment Verification queue (`pending_verification`):
Click Proof to inspect the uploaded bank slip via /payment/proof?id={payment_id}.
Enter a Verification Note and click Verify (marks the invoice `paid`, generates an official receipt, and activates the subscription) or Reject.
In the Payment Gateway Configuration panel, configure toyyibPay mode (`sandbox` or `production`), category code, and secret key (encrypted at rest using AES-256-GCM).
3. Generating Revenue Reports
At the top of /{lang}/admin/payments, the revenue summary cards report settled revenue (`paid_total`), pending verification total (`pending_total`), failed payments (`failed_total`), and overdue invoice balances (`overdue_total`).
Subscription Plan Administration (/admin/subscriptions) and Payment Verification & Revenue Reports (/admin/payments).
Input Fields & Options Reference
Administrative Capability
Route
Required Permission
Configure Plan Fees & Annual Discounts
/admin/subscriptions
subscriptions.manage
Manage Trial Accounts & Lifecycle Status
/admin/subscriptions
subscriptions.manage
Verify Manual Transfers & Issue Receipts
/admin/payments
payments.manage
Configure toyyibPay & View Revenue Reports
/admin/payments
payments.manage
Expected Results: Subscription plans, fees, discounts, manual payment verifications, and revenue summaries are managed with full audit logging.
Important Notes & Data Boundaries: Gateway secret keys are encrypted at rest with AES-256-GCM via `payment_encrypt_secret()`.
Common Errors & Troubleshooting
Schedule php database/manage.php subscription-maintenance daily to automatically process trial expirations, overdue transitions, and 30/14/7/1-day renewal reminders.