encoredigitalgroup / stripe
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/encoredigitalgroup/stripe
Requires
- php: ^8.3
- encoredigitalgroup/stdlib: ^2.0
- filament/support: ^3.2
- illuminate/support: ^11|^12
- phpgenesis/logger: ^1
- stripe/stripe-php: ^16.5 || ^17.0 || ^18.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- larastan/larastan: ^3.0
- neronmoon/scriptsdev: ^0.1.9
- orchestra/testbench: ^9.1 || ^10.0
- pestphp/pest: ^4
- pestphp/pest-plugin-laravel: ^4
- phpgenesis/devutilities: ^1
- phpstan/extension-installer: ^1.3
- rector/rector: ^2.0
- tightenco/duster: ^3.0
- tomasvotruba/cognitive-complexity: ^1.0
This package is auto-updated.
Last update: 2025-10-19 02:44:41 UTC
README
A clean, type-safe PHP interface for the Stripe API designed specifically for Laravel applications. This library wraps the Stripe PHP SDK with strongly-typed objects, service classes, and enums while maintaining full compatibility with Laravel 11-12.
Why This Library?
The official Stripe PHP SDK, while powerful, returns dynamic objects and arrays that lack type safety and IDE support. This library bridges that gap by providing:
- Type Safety: All Stripe objects are represented as strongly-typed PHP classes with full PHPStan Level 8 compliance
- Laravel Integration: Seamless integration with Laravel's service container and testing infrastructure
- Developer Experience: Rich IDE autocompletion, type hints, and inline documentation
- Consistent API: Clean, predictable methods that follow Laravel conventions
- Comprehensive Testing: Built-in testing utilities that fake Stripe API calls without network requests
Quick Start
Install via Composer:
composer require encoredigitalgroup/stripe
Configure your Stripe secret key in .env
:
STRIPE_SECRET_KEY=sk_test_...
Start using the library:
use EncoreDigitalGroup\Stripe\Stripe; // Create a customer $customer = Stripe::customers()->create(Stripe::customer( email: 'customer@example.com', name: 'John Doe' )); echo $customer->id; // cus_...
Core Features
Services
Clean service methods accessible via the Stripe facade:
Stripe::customers()
- Create, update, retrieve, delete, list, and search customersStripe::products()
- Manage products with archive/reactivate functionalityStripe::prices()
- Handle pricing with support for recurring billing, tiers, and complex configurationsStripe::subscriptions()
- Full subscription lifecycle management
Type-Safe Objects
Immutable objects created via factory methods:
Stripe::customer()
- Customer objects with address and shipping supportStripe::product()
- Product objects with metadata, images, and package dimensionsStripe::price()
- Price objects with complex recurring billing, tiers, and custom unit amountsStripe::address()
- Address objects for billing and shipping
Enums
String-backed enums for Stripe constants:
RecurringInterval
(Month, Year, Day, Week)PriceType
(OneTime, Recurring)SubscriptionStatus
(Active, Canceled, Incomplete, etc.)- And many more for type-safe API interactions
Testing Infrastructure
Comprehensive testing utilities:
Stripe::fake()
for mocking API callsStripeFixtures
for realistic test data- Custom PHPUnit expectations for asserting API calls
- No network requests in tests
Requirements
- PHP 8.3+
- Laravel 11 or 12
- Stripe PHP SDK ^18.0
Documentation
=� Read the Full Documentation �
The documentation is organized as a coherent story that will take you from basic concepts to advanced usage:
- Getting Started - Installation, configuration, and basic concepts
- Customers - Everything about customer management
- Products - Product creation, management, and lifecycle
- Prices - Complex pricing, recurring billing, and tiers
- Testing - Comprehensive testing strategies and utilities
- Architecture - Deep dive into library design and patterns
Example: Complete E-commerce Flow
use EncoreDigitalGroup\Stripe\Stripe; use EncoreDigitalGroup\Stripe\Enums\{PriceType, RecurringInterval}; // 1. Create a customer $customer = Stripe::customers()->create(Stripe::customer( email: 'customer@example.com', name: 'John Doe' )); // 2. Create a product $product = Stripe::products()->create(Stripe::product( name: 'Premium Subscription', description: 'Monthly premium features' )); // 3. Create a recurring price $price = Stripe::prices()->create(Stripe::price( product: $product->id, currency: 'usd', unitAmount: 2999, // $29.99 type: PriceType::Recurring, recurring: [ 'interval' => RecurringInterval::Month, 'interval_count' => 1 ] )); echo "Created customer {$customer->id} with product {$product->id} priced at {$price->id}";
Contributing
Contributions to this repository are governed by the Encore Digital Group Contribution Terms. Additional details on how to contribute are available here.
License
This repository is licensed using a modified version of the BSD 3-Clause License. The license is available for review here.