infuse/billing

Subscription membership module for Infuse Framework powered by Stripe

2.0 2017-12-03 03:15 UTC

This package is auto-updated.

Last update: 2024-11-20 16:23:09 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads

Subscription membership module for Infuse Framework powered by Stripe

Installation

  1. Install the package with composer:

     composer require infuse/billing
    
  2. Add a billing section in your app's configuration:

    'billing' => [
    	'model' => 'App\Users\Models\User',
    	'emails' => [
    		'trial_will_end' => true,
    		'trial_ended' => true,
    		'failed_payment' => true,
    		'payment_receipt' => true,
    		'subscription_canceled' => true
    	],
    	'defaultPlan' => 'default_plan',
    	'trialWillEndReminderDays' => 3
    ]
  3. Add the console command to run jobs to console.commands in your app's configuration:

    'console' => [
    	// ...
    	'commands' => [
    		// ...
    		'Infuse\Billing\Console\ExtendTrialCommand',
    		'Infuse\Billing\Console\SyncStripeSubscriptionsCommand',
    		'Infuse\Billing\Console\SyncStripeProfilesCommand'
    	]
    ]
  4. Add the migration to your app's configuration:

    'modules' => [
       'migrations' => [
          // ...
          'Billing'
       ],
       'migrationPaths' => [
          // ...
          'Billing' => 'vendor/infuse/billing/src/migrations'
       ]
    ]
  5. (optional) Add the following scheduled job to your app's configuration:

    'cron' => [
    	// ...
    	[
    	    'id' => 'billing:sendTrialReminders',
    	    'class' => 'Infuse\Billing\Jobs\SendTrialReminders',
    	    'minute' => 0,
    	    'expires' => 1800 // 30 minutes
    	]
    ]
  6. (optional) Add an endpoint to your routing table to receive Stripe webhooks:

    'routes' => [
    	// ...
    	'POST /billing/webhook' => [
    		'Infuse\Billing\Libs\StripeWebhook',
    		'webhook'
        ]
    ]