aamroni / stripe
Stripe API Payment in Laravel
1.0.0
2024-04-01 18:21 UTC
Requires
- php: >=8.2
Requires (Dev)
- laravel/pint: ^1.15
- pestphp/pest: ^2.34
This package is auto-updated.
Last update: 2025-03-01 00:33:17 UTC
README
Install
composer require aamroni/stripe
Config Example
Collect your public and secret keys, and configure as necessary in config/payment.php
'stripe' => [ 'public' => env('STRIPE_PUBLIC_KEY'), 'secret' => env('STRIPE_SECRET_KEY'), 'redirect' => [ 'success' => 'http://localhost:8000/stripe/success', 'cancel' => 'http://localhost:8000/stripe/cancel' ], 'currency' => 'USD' ]
Checkout Example
<?php use Aamroni\Stripe\Entities\CustomerEntity; use Aamroni\Stripe\Entities\PurchaseEntity; use Aamroni\Stripe\Facades\Stripe; use Aamroni\Stripe\StripePaymentManager; // @step01: Create a customer information $customer = CustomerEntity::instance( name: 'James Wilson', email: 'james.wilson@example.com', mobile: '+1 562-506-8893', street: '2812 Locust Court', city: 'Irvine', postal: '92614', state: 'California', country: 'US' ); // @step02: Create a purchase information $purchase = PurchaseEntity::instance( title: 'FoldSack No. 1 Backpack, Fits 15 Laptops', quantity: 1, regular: 109.95, offered: 99, currency: 'USD' ); // @step03: Process the Stripe checkout $stripe = Stripe::checkout($customer, $purchase); // or $stripe = StripePaymentManager::instance()->checkout($customer, $purchase); dd($stripe);
Customer Example
<?php use Aamroni\Stripe\Contracts\CustomerContract; $instance = CustomerContract::instance(); $response = $instance->create(CustomerEntity: $customer); // Create a customer information $response = $instance->delete(); // Delete a customer information $response = $instance->record(); // Fetch all customer information $response = $instance->record(id: $id); // Fetch a specific customer information dd($response);
Purchase Example
<?php use Aamroni\Stripe\Contracts\PurchaseContract; $instance = PurchaseContract::instance(); $response = $instance->create(PurchaseEntity: $purchase); // Create a purchase information $response = $instance->record(); // Fetch all purchase information $response = $instance->record(id: $id); // Fetch a specific purchase information dd($response);