aimeos / pagible-cashier
Pagible CMS - Payment integration via Laravel Cashier
Requires
- php: ^8.2
- aimeos/pagible-core: 0.14.*
Requires (Dev)
None
Suggests
- aimeos/pagible-cashier-mollie: Mollie payment provider
- aimeos/pagible-cashier-paddle: Paddle payment provider
- aimeos/pagible-cashier-stripe: Stripe payment provider
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-04 16:50:25 UTC
README
Payment-backed frontend access for PagibleAI CMS through Laravel Cashier. Choose one provider package per application:
Installation
PagibleAI CMS, the aimeos/pagible-theme package providing the pricing
element, Laravel authentication, and a named login route must already be
available. Checkout requires a stored, authenticated Eloquent user. Guests who
click a pricing button are sent to login, and their checkout resumes after
authentication.
composer require aimeos/pagible-cashier-stripe # or: aimeos/pagible-cashier-paddle # or: aimeos/pagible-cashier-mollie php artisan cms:install:cashier
cms:install:cashier detects the single installed provider, checks for an
application-owned users.access conflict, publishes its upstream Cashier and
adapter migrations, and runs all outstanding migrations. Use --no-migrate
only when the deployment pipeline runs migrations separately. Add --force
when migrations must run non-interactively in production. The Stripe package
can also create its webhook endpoint during installation, see its README.
The migration adding the JSON users.access column is loaded automatically
from this package and fails if the column already exists in the application.
The installer finishes with a local readiness report. Run the same idempotent, read-only check again after changing the model or configuration:
php artisan cms:cashier:check
It returns a non-zero status until the provider registration, APP_KEY,
APP_URL, named login route, checkout and webhook routes, authentication
model traits, Cashier schema, access catalog, API credentials, and webhook
verification are ready. Its Developer next steps section combines failed
local checks with the dashboard and end-to-end tasks that cannot be performed
locally.
Add Aimeos\Cms\Concerns\CashierAccess beside the provider's Billable trait
on the application user model. The trait reserves, guards, casts, and hides the
users.access attribute. Do not add access to the user model's $fillable
list or accept it in profile/account input; only Pagible Cashier may write it.
For Stripe and Mollie, the model setup is:
use Aimeos\Cms\Concerns\CashierAccess; use Illuminate\Foundation\Auth\User as Authenticatable; use Laravel\Cashier\Billable; class User extends Authenticatable { use CashierAccess; use Billable; }
Paddle uses Laravel\Paddle\Billable instead. Keep any provider-specific model
customization required by the upstream Cashier package.
Pagible's normal tenancy rule still applies. Without tenancy configuration, any
authenticated user belongs to the default tenant. In a tenant-aware application,
the user's tenant_id must match the active tenant unless the application
deliberately overrides the check with Tenancy::allowsUsing().
The installed provider package is the configuration. Complete the credential, webhook, and (for Mollie) scheduler setup described in the README of the installed provider package before creating pricing content.
Frontend access catalog
Cashier adds payment-derived grants to Pagible's existing frontend access system; it does not define the available role names. Configure an access catalog in an application service provider before assigning roles to pricing packages or pages. A fixed catalog is sufficient for a simple installation:
use Aimeos\Cms\Access; public function boot(): void { Access::using(fn() => [ 'course-buyers', 'premium-members', ]); }
The callback may return different values for the active tenant. This example is
read-only: editors can select its values but cannot create or delete them in the
admin. Use the add and delete callbacks, or configure the Bouncer, Laratrust,
or Spatie adapter described in the
core access-catalog documentation,
when editors should manage the catalog.
The pricing package and every page sold by that package must use the same exact catalog value. Payment roles are tenant-specific and are ignored if they are not part of the current tenant's catalog.
Selling restricted pages
- Finish the selected provider's credential and webhook setup. Webhooks are authoritative for granting, renewing, refunding, and revoking access.
- In the CMS admin, add a
pricingelement to a public sales page. Add a package, choose its frontend access role, add one or more prices, and publish the page or shared element. - Open each page being sold, choose Access, select Restricted, select
the same role, and apply the change. Applying recursively protects the page's
descendants too. This action requires
page:access. - Keep the sales page public. Use a public account or payment-status page as the target URL because the browser can return before the verified webhook has granted access.
- Test the complete flow in the provider's sandbox: guest login, checkout, webhook delivery, authorized page access, cancellation, and a full refund or chargeback.
Restricting a page does not make files on a public storage URL private. Configure
CMS_PRIVATE_DISK to a non-public Laravel disk and enable Protect with page
access for files that must only be delivered with the restricted page.
Pricing products
Products live in each tenant's published pricing content, not application
configuration. This keeps products tenant-editable in SaaS installations. A
package owns one frontend access role and contains up to five prices. The
installed adapter supplies the provider for every price. Editors fill in these
values in the admin; the stored structure of a package looks like this:
{
"id": "professional",
"name": "Professional",
"access": "premium-members",
"url": "/account",
"prices": [
{
"id": "monthly",
"reference": "price_123",
"kind": "subscription",
"currency": "EUR",
"amount": 19.00,
"unit": "month"
},
{
"id": "lifetime",
"reference": "price_456",
"kind": "once",
"currency": "EUR",
"amount": 199.00,
"unit": "once"
}
]
}
Package and price identifiers are generated automatically and stored with the pricing content, but aren't shown as editable fields. Copying a package creates new package and price identifiers; cutting and pasting preserves them.
The frontend derives its toggle captions from the distinct non-empty unit
values and selects matching prices across packages. Packages without the
selected unit keep their first price.
For packages with access, url is the local page shown after checkout. Without
access, it is rendered directly as a page, fragment, or contact link and the
package may omit reference, kind, and currency; those fields remain
mandatory at runtime for packages that start checkout.
Pricing uses the ordinary CMS permissions. Editors with page:save can control
the access role and prices of inline pricing content; shared pricing elements
use element:save. Publication and scheduling continue to use the normal page
and element publication permissions. Checkout accepts an access role only when
it exists in the current tenant's Access catalog.
The CMS pricing fields have these meanings:
- Payment type: Use
subscriptionoronce. - Payment reference: The provider-specific value that is charged, e.g. a provider price ID. Its format is described in the provider package README.
- Currency: A three-letter uppercase currency code.
- Billing interval: Only used by providers without their own price objects (Mollie); see the provider package README.
- Amount, displayed price, and price unit: These fields control only the rendered pricing display. The provider price or payment reference remains authoritative for the charge.
The target URL must be a local URL beginning with /. It is used after checkout;
invalid or external values fall back to /.
With cms.multidomain enabled, checkout only accepts pricing content
published for the request's domain or for all domains. The domain is taken
from the Host header, so configure Laravel's trusted hosts (the TrustHosts
middleware, e.g. $middleware->trustHosts() in bootstrap/app.php) or
restrict the accepted host names in your web server. Otherwise, a buyer could
send another domain's host name and pay that domain's price.
Checkout route
The pricing element's buttons submit to GET|POST cmsapi/cashier (route name
cms.cashier) with these fields:
page: ID of the published page containing the pricing contentlang: language of the page (optional)element: ID of the pricing element or inline contentpackage: package IDprice: price ID
The server resolves the payment reference, access role, payment kind, and target
URL from the published content; the browser cannot change them. Guests are
redirected to login and the submitted fields are kept in the session; the
GET request resumes the checkout after login. The route uses the
cms-cashier rate limiter, which allows 10 requests per minute per IP address
and per authenticated user.
Access state
Verified webhook events record each payment source of a user in the hidden
users.access column. A role remains active in its tenant while any of its
payment sources is permanent (one-time payment) or paid through a future date.
The number of payment sources per user is limited.
Provider-confirmed paid invoices, transactions, and orders renew the source. Status-only subscription updates never restore access. Failed renewals and scheduled cancellations retain access through the already paid period. Provider-confirmed subscription deletion, immediate cancellation, full refund, or chargeback revokes the affected source. Repeated and out-of-order webhook delivery is idempotent.
Applications may schedule end-of-period cancellation through
DELETE /cmsapi/cashier/{subscription} (route name cms.cashier.cancel). Only
subscriptions of the authenticated user can be cancelled and access is removed
when the provider's webhook confirms the cancellation.
Webhooks
Webhook handling and the corresponding users.access mutation are synchronous.
An exception prevents a successful response so the payment provider can retry
the event. Provider retries are the only recovery mechanism for failed webhook
delivery and there is no separate reconciliation job, so monitor webhook
endpoints and exhausted deliveries. If every retry for a one-time refund or
chargeback is exhausted, permanent access may require manual revocation.
Frontend authorization
Payment roles are added to the existing Pagible Access grants. They do not replace a custom Bouncer, Laratrust, Spatie, or Access::using() resolver. Page rendering, navigation, and JSON:API apply them the same way, and your own pages and APIs can check them too, e.g. to show premium features:
use Aimeos\Cms\Access; $roles = app( Access::class )->allowed( $request->user() ); if( in_array( 'premium-members', $roles, true ) ) { // ... }
allowed() returns all access values of the user in the current tenant, i.e. active payment roles and other grants of the configured access catalog, and is memoized for the request. Payment roles count only if they are part of the catalog. Don't read users.access directly, it contains revoked and expired sources too.
License
MIT