Filament: One-Time Payment Form with Stripe

While creating a project in Filament, you might think adding Payments is difficult as it's not the designed use case. But in reality, this is easy!

FilamentExamples ThumbBase (25)

Get the Source Code:

How it works

In our example, you will find a Product table with name and price columns. These will be the things we are selling. So we will skip the setup, as it does not matter as long as you have an ID and price.

Once we have the product list, we can create a checkout page:

php artisan make:filament-page BuyProduct

Note: When asked where to place it - enter ProductResource or any other custom resource you have.

Once this file is created, we can paste this content there:

Note: We added critical comments inside the code for clarity.

app/Filament/Resources/ProductResource/Pages/BuyProduct.php

 
namespace App\Filament\Resources\ProductResource\Pages;
 
use App\Filament\Resources\ProductResource;
use App\Models\User;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
use Filament\Resources\Pages\Page;
use Filament\Support\Assets\Js;
use Filament\Support\Facades\FilamentAsset;
use NumberFormatter;
use Stripe\Customer;
use Stripe\PaymentIntent;
use Stripe\StripeClient;
 
class BuyProduct extends Page
{
// This trait informs the Filament page that we will interact with a record
use InteractsWithRecord;
 
protected static string $resource = ProductResource::class;
 
protected static string $view = 'filament.resources.product-resource.pages.buy-product';
// ....
The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 50 Premium Examples for $99 Only Project Examples for $59