typicms/subscriptions

Fund package maintenance!
typicms

10.0.2 2023-01-25 10:23 UTC

This package is auto-updated.

Last update: 2024-10-17 12:47:27 UTC


README

This module is part of TypiCMS, a multilingual CMS based on the Laravel framework.

It allows you to setup a subscriptions management system based on Laravel Cashier for Mollie.

Installation

Prerequisites

  • You must have a working installation of TypiCMS
  • Make sure your APP_URL in .env is correctly set.

Install the package

composer require typicms/subscriptions

Add the service provider:

// config/app.php

/*
 * TypiCMS Modules Service Providers.
 * Here is the place for your modules,
 * they should be set before Core Service provider.
 */TypiCMS\Modules\Subscriptions\Providers\ModuleServiceProvider::class,
…

Configure your app

Add the cashier model and the mollie key in your .env environment file:

CASHIER_MODEL=TypiCMS\Modules\Core\Models\User
MOLLIE_KEY="test_12345678912345678912345678912345"

Publish the Users module and add the BillableUser trait to the User model.

php artisan typicms:publish Users

Modify the User model like this:

use TypiCMS\Modules\Subscriptions\Traits\BillableUser;
…
class User extends Model implements …
{
    …
    use BillableUser;
    …
}

More information can be found here

Mass-assignement

If needed, allow the following fields to be fillable.

protected $fillable = [
     'tax_percentage',
     'mollie_customer_id',
     'mollie_mandate_id',
     'tax_percentage',
     'trial_ends_at',
     'extra_billing_information'
 ];

Run the installation script

Install Cashier and migrate the database.

php artisan subscriptions:install

Import the scss files

Edit resources/scss/public.scss and add:

@import 'public/account';
@import 'public/plan-list';

Run npm run dev to compile the public.css file.

Configure Cashier

Configure your subscription plans in config/cashier_plans.php.

Manage any coupons in config/cashier_coupons.php. By default an example coupon is enabled, consider disabling it before deploying to production.

Setup your app

Create a page linked to the Subscriptions module and navigate to it.

Pre-build Plans Template

Quickly build an effective pricing table for your potential customers with the template created under /plans and linked to the PublicController@plans controller.

Customize Invoices

Copy the Cashier package views using the following command:

php artisan vendor:publish --provider="Laravel\Cashier\CashierServiceProvider" --tag="cashier-views"

You can customize the /resources/views/vendor/cashier/ files as you like.

Tax Management

To specify the tax percentage a user pays on a subscription, edit the tax_percentage column for the user in the database.

The displayed price on the subscription has built-in tax calculation.

Additional information

Read the cashier-mollie documentation