<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
digikraaft / laravel-paystack-subscription example snippets
return [
/*
|--------------------------------------------------------------------------
| Paystack Keys
|--------------------------------------------------------------------------
|
| The Paystack publishable key and secret key. You can get these from your Paystack dashboard.
|
*/
'public_key' => env('PAYSTACK_PUBLIC_KEY'),
'secret' => env('PAYSTACK_SECRET'),
/*
|--------------------------------------------------------------------------
| Subscription Model
|--------------------------------------------------------------------------
|
| This is the model in your application that implements the Billable trait
| provided by PaystackSubscription. It will serve as the primary model you use while
| interacting with PaystackSubscription related methods, subscriptions, etc.
|
*/
'model' => env('SUBSCRIPTION_MODEL', App\User::class),
/*
|--------------------------------------------------------------------------
| User Table
|--------------------------------------------------------------------------
|
| This is the table in your application where your users' information is stored.
|
*/
'user_table' => 'users',
/*
|--------------------------------------------------------------------------
| Webhooks Path
|--------------------------------------------------------------------------
|
| This is the base URI path where webhooks will be handled from.
|
| This should correspond to the webhooks URL set in your Paystack dashboard:
| https://dashboard.paystack.com/#/settings/developer.
|
| If your webhook URL is https://domain.com/paystack/webhook/ then you should simply enter paystack here.
|
| Remember to also add this as an exception in your VerifyCsrfToken middleware.
|
| See the demo application linked on github to help you get started.
|
*/
'webhook_path' => env('PAYSTACK_WEBHOOK_PATH', 'paystack'),
];
use Digikraaft\PaystackSubscription\Billable;
class User extends Authenticatable
{
use Billable;
}
namespace App\Http\Controllers;
use Digikraaft\PaystackSubscription\Http\Controllers\WebhookController as PaystackWebhookController;
class WebhookController extends PaystackWebhookController
{
/**
* Handle invoice create.
*
* @param array $payload
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handleInvoiceCreate($payload)
{
// Handle The Event
}
}
public function handle($request, Closure $next)
{
if ($request->user() && ! $request->user()->subscribed('default')) {
// This user is not a paying customer...
return redirect('billing');
}
return $next($request);
}
if ($user->subscribedToPlan('PLN_paystackplan_code', 'default')) {
//
}
if ($user->subscribedToPlan(['PLN_paystackplan_code', 'PLN_paystackplan_code2'], 'default')) {
//
}
protected $except = [
'paystack/*',
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.