PHP code example of iamalamin / easy-stripe

1. Go to this page and download the library: Download iamalamin/easy-stripe 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/ */

    

iamalamin / easy-stripe example snippets


return [
    'stripe' => [
        'publishable_key' => env('STRIPE_PUBLISHABLE_KEY'),
        'secret_key' => env('STRIPE_SECRET_KEY'),
        'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
    ],
    'currency' => env('STRIPE_CURRENCY', 'usd'),
    'routes' => [
        'prefix' => 'stripe',
        'middleware' => ['web'],
    ],
];

// app/Http/Controllers/StripePaymentController.php
class StripePaymentController extends Controller
{
    public function index()
    {
        return view('easy-stripe.stripe-payment.index');
    }
    
    public function processPayment(Request $request)
    {
        // Payment processing logic
    }
    
    // ... other methods
}

// app/Models/StripePayment.php
class StripePayment extends Model
{
    protected $fillable = [
        'stripe_payment_intent_id',
        'amount',
        'currency',
        'status',
        'customer_email',
        'customer_name',
        'metadata',
    ];
}

Schema::create('stripe_payments', function (Blueprint $table) {
    $table->id();
    $table->string('stripe_payment_intent_id')->unique();
    $table->integer('amount'); // Amount in cents
    $table->string('currency', 3)->default('usd');
    $table->string('status');
    $table->string('customer_email')->nullable();
    $table->string('customer_name')->nullable();
    $table->json('metadata')->nullable();
    $table->timestamps();
});
bash
php artisan easy-stripe:install
bash
php artisan migrate

resources/views/stripe-integration/
├── layouts/
│   └── app.blade.php           # Main layout
├── stripe-payment/
│   ├── index.blade.php         # Payment form
│   ├── success.blade.php       # Success page
│   ├── cancel.blade.php        # Cancel page
│   └── list.blade.php          # Payments list

/stripe?amount=2000&currency=usd&description=Custom Product
blade
{{-- resources/views/easy-stripe/layouts/app.blade.php --}}
<style>
    .payment-card {
        background: white;
        border-radius: 15px;
        /* Your custom styles */
    }
</style>