stripe-php
Stripe's official PHP library for the Stripe API
Repository Health
Technical Analysis
stripe-php is the officially maintained PHP client for the Stripe API, providing typed resource classes (Charge, Customer, Subscription, PaymentIntent, and hundreds more) that initialize dynamically from API responses. This dynamic-initialization design keeps the library forward-compatible with new Stripe API fields and versions without requiring a release for every API change.
The library covers the full breadth of Stripe’s product surface — Payments, Billing, Connect, Checkout, Climate, Apps, and more — organized into namespaced resource classes that mirror the API’s structure. It ships with configurable retry logic, webhook signature verification, and idempotency-key support, making it the standard entry point for PHP applications integrating Stripe.
What You Get
- Typed PHP classes for nearly every Stripe API resource (Charges, Customers, Subscriptions, PaymentIntents, Connect accounts, and more)
- A configurable
StripeClientwith automatic retries, timeouts, and idempotency-key support - Built-in webhook signature verification via
Webhook::constructEvent - Support for pinning a specific Stripe API version per request or client
- Auto-pagination helpers for list endpoints via the
Collectionclass - PHPStan static analysis baseline and strict typing for safer integration
Common Use Cases
- Processing one-off and recurring payments (Charges, PaymentIntents, Subscriptions) from a PHP backend
- Building marketplace or platform payouts using Stripe Connect
- Verifying and handling incoming Stripe webhook events securely
- Implementing Stripe Checkout or Billing Portal sessions from server-side PHP code
Under The Hood
Architecture - The library is organized as a large, generated set of resource classes under lib/ (460+ PHP files), each subclassing shared ApiResource/ApiOperations traits (create, retrieve, update, delete, list) that funnel every request through a central ApiRequestor. Domain areas like Billing, Connect, Checkout, Climate, and Apps are grouped into their own subdirectories, mirroring the Stripe API’s own namespacing, while cross-cutting concerns (retries, telemetry, error mapping) live in BaseStripeClient and ApiRequestor.
Tech Stack - Built for PHP 7.2+ (moving toward dropping the oldest supported versions), it depends only on standard PHP extensions (curl, json, mbstring) with no heavyweight external dependencies, keeping installs lightweight in typical Composer-based PHP stacks. Development tooling includes PHPUnit for tests, PHP-CS-Fixer for style, and PHPStan (with a maintained baseline file) for static analysis.
Code Quality - The tests/ directory mirrors lib/’s resource structure with dedicated test classes per resource, and the repo tracks OPENAPI_VERSION/CODEGEN_VERSION files, indicating the resource classes are generated from Stripe’s OpenAPI spec rather than hand-maintained — reducing drift between the API and the SDK. A phpstan-baseline.neon shows static analysis is enforced incrementally on top of a large, mostly-generated codebase.
API Design - Resources follow a consistent Stripe\ResourceName::method() pattern (e.g. Stripe\Charge::create(), Stripe\Customer::retrieve()), and the dynamic-initialization approach means new API fields surface automatically without waiting for a new SDK release. The main developer-experience trade-off is the sheer size of the surface area — with hundreds of resource classes across nested namespaces, discoverability leans heavily on Stripe’s external API reference docs rather than the code alone.
Used by 6 apps in this directory
Bagisto
Analytics · Ecommerce
Open-source Laravel eCommerce platform for building multi-vendor marketplaces, B2B stores, headless commerce, and AI-powered storefronts.
Coolify
Devops · Hosting Control Panel
Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in
Fleetbase
Logistics
Modular open-source logistics and supply chain operating system
Hi.Events
Ecommerce · Scheduling
Self-hosted event ticketing platform that keeps your attendee data, brand, and revenue completely under your control.
Invoice Ninja
Invoicing Finance · Project Management
Self-hostable invoicing, time-tracking, and multi-gateway payment platform for freelancers and small businesses, with built-in e-invoicing compliance for EU and global standards.
Leantime
Productivity · Project Management · Collaboration
Project management built for ADHD, autism, and dyslexia — simple as Trello, powerful as Jira