1. Go to this page and download the library: Download aimeos/pagible-cashier library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Laravel\Cashier\Events\WebhookHandled;
Event::listen(WebhookHandled::class, function ($event) {
$payload = $event->payload;
// One-time payment completed
if (($payload['type'] ?? '') === 'checkout.session.completed') {
$session = $payload['data']['object'] ?? [];
$userId = $session['customer'] ?? null;
$items = \Laravel\Cashier\Cashier::stripe()->checkout->sessions->allLineItems($session['id'] ?? '');
$priceId = $items->data[0]->price->id ?? null;
$product = config('cms.cashier.products')[$priceId] ?? [];
if ($userId && $user = User::where('stripe_id', $userId)->first()) {
// grant access based on $product config
}
}
// Recurring payment succeeded
if (($payload['type'] ?? '') === 'invoice.payment_succeeded') {
$userId = $payload['data']['object']['customer'] ?? null;
$priceId = $payload['data']['object']['lines']['data'][0]['price']['id'] ?? null;
$product = config('cms.cashier.products')[$priceId] ?? [];
if ($userId && $user = User::where('stripe_id', $userId)->first()) {
// grant access based on $product config
}
}
});
use Laravel\Paddle\Events\WebhookHandled;
Event::listen(WebhookHandled::class, function ($event) {
$payload = $event->payload;
// One-time payment completed
if (($payload['event_type'] ?? '') === 'transaction.completed') {
$data = $payload['data'] ?? [];
$userId = $data['customer_id'] ?? null;
$priceId = $data['items'][0]['price']['id'] ?? null;
$product = config('cms.cashier.products')[$priceId] ?? [];
if ($userId && $user = User::where('paddle_id', $userId)->first()) {
// grant access based on $product config
}
}
// Recurring subscription activated
if (($payload['event_type'] ?? '') === 'subscription.activated') {
$data = $payload['data'] ?? [];
$userId = $data['customer_id'] ?? null;
$priceId = $data['items'][0]['price']['id'] ?? null;
$product = config('cms.cashier.products')[$priceId] ?? [];
if ($userId && $user = User::where('paddle_id', $userId)->first()) {
// grant access based on $product config
}
}
});
use Laravel\CashierMollie\Events\OrderPaymentPaid;
use Laravel\CashierMollie\Events\FirstPaymentPaid;
// One-time payment completed
Event::listen(OrderPaymentPaid::class, function ($event) {
if ($user = $event->order?->owner) {
$priceId = $event->order->orderItems->first()?->orderable_id;
$product = config('cms.cashier.products')[$priceId] ?? [];
// grant access based on $product config
}
});
// First recurring payment completed
Event::listen(FirstPaymentPaid::class, function ($event) {
if ($user = $event->payment?->owner) {
$priceId = $event->payment->orderItems->first()?->orderable_id;
$product = config('cms.cashier.products')[$priceId] ?? [];
// grant access based on $product config
}
});
bash
php artisan cms:install:cashier
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.