PHP code example of isapp / laravel-cashier-support
1. Go to this page and download the library: Download isapp/laravel-cashier-support 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/ */
isapp / laravel-cashier-support example snippets
use Isapp\CashierSupport\Facades\Cashier;
Cashier::extend('revolut', fn ($app) => $app->make(RevolutGateway::class));
'default' => env('CASHIER_DRIVER', 'revolut'),
use Illuminate\Database\Eloquent\Model;
use Isapp\CashierSupport\Billable;
class User extends Model
{
use Billable;
}
class Vendor extends Model
{
use Billable;
public function cashierDriver(): ?string
{
return 'adyen';
}
}
use Isapp\CashierSupport\Enums\Capability;
use Isapp\CashierSupport\Facades\Cashier;
if (Cashier::supports(Capability::SubscriptionPause)) {
$user->pauseSubscription('default');
}
use Isapp\CashierSupport\Enums\Currency;
use Isapp\CashierSupport\Invoice\InvoiceBuilder;
use Isapp\CashierSupport\Invoice\InvoiceRenderer;
$invoice = InvoiceBuilder::make()
->id('in_1')->currency(Currency::EUR)
->addLine('Pro plan', 1000)
->build();
return app(InvoiceRenderer::class)->render($invoice)->download('invoice.pdf');
// AppServiceProvider::boot()
Cashier::extend('revolut', fn ($app) => $app->make(MyRevolutGateway::class));
// or side-by-side under its own name, selected per model via cashierDriver()
Cashier::extend('revolut-b2b', fn ($app) => $app->make(B2bRevolutGateway::class));
Cashier::macro('chargeInCents', function (Model $billable, int $amount): Payment {
return $this->provider()->charge($billable, $amount, 'pm_default');
});