stripe/stripe-php
Official Stripe PHP SDK for accessing the Stripe API. Provides resource classes that map to API objects, auto-initialize from responses, and support many API versions. Install via Composer and use with PHP 7.2+.
Pros:
V2.Core.FeeBatch, V2.MoneyManagement.DebitDispute, etc.) align with Laravel’s Eloquent patterns for domain-specific modeling (e.g., FeeBatch, DebitDispute models).discounts, amount_sale, and amount_discount on DelegatedCheckout.RequestedSession enables richer Laravel-based checkout flows (e.g., dynamic pricing via Eloquent observers).simulate_network_lifecycle_pre_arbitration_response) integrate with Laravel’s testing tools (e.g., Pest/PHPUnit mocks for dispute simulations).V2MoneyManagementFinancialAccountStatementCreatedEvent) can trigger Laravel events (e.g., financial_account_statement_created) for reactive workflows.address.country optional reduce Laravel model validation boilerplate (e.g., nullable() in migrations).Cons:
check_deposit_address from multiple resources (e.g., Invoice, Subscription) may require Laravel model updates and migration of existing data.check_deposit_address_deprecated).FeeBatch, FinancialAccountStatement) introduce deeper Stripe API coupling. Laravel apps may need additional services/contracts to abstract these.FeeBatchAdapter) to decouple Laravel models from Stripe SDK changes.Laravel Ecosystem Synergy:
Model class for new Stripe resources (e.g., app/Models/V2/FeeBatch.php).Stripe\Stripe::resource() to hydrate models from API responses.DelegatedCheckout.RequestedSession with Laravel’s Order or CheckoutSession models, leveraging new fields (discounts, amount_sale) for dynamic pricing.Events\HandlesV2MoneyManagementFinancialAccountStatementCreated).dispatch() to trigger domain events (e.g., FinancialAccountStatementCreated).tests/Feature/StripeTest.php (e.g., simulate disputes for DebitDispute models).Database Synergy:
dispute_details, payment_attempt_record) to existing Laravel models (e.g., payment_attempt_records table).Schema::table() for backward-compatible updates.check_deposit_address_deprecated column to invoices/subscriptions tables and populate via a migration.Breaking Changes:
check_deposit_address Removal:
DeprecatedCheckDepositAddress) to handle legacy cases.FeeBatch, FinancialAccountStatement, and DebitDispute introduce new business logic layers. Laravel apps may need additional services to manage these.FinancialAccountStatement::all()).debit_dispute in Transaction.category) may require Laravel model casts or database enum updates.CastsAttributes to handle enum serialization.Error Handling:
Stripe\Exception\InvalidRequestException for invalid payment_behavior).App\Exceptions\Handler to centralize Stripe error responses.Performance:
FeeBatch) may require Laravel’s chunking or queues to avoid timeouts.collect()->chunk(100) or queue jobs for large batches.check_deposit_address? (Archive, ignore, or migrate to a new field?)FeeBatch, DebitDispute)? Should these be core or optional?DelegatedCheckout.RequestedSession discounts with existing pricing logic (e.g., Coupon models)?FinancialAccountStatementCreated)? Will these use queues?Stripe\TestHelper be integrated into CI?FeeBatch API calls)? Will custom metrics be added to Stripe logs?check_deposit_address during migration?Laravel Core:
app/Providers/StripeServiceProvider.php):
$this->app->bind(
\App\Services\V2\FeeBatchService::class,
fn($app) => new \App\Services\V2\FeeBatchService(
$app->make(\Stripe\StripeClient::class)
)
);
Stripe facade or create sub-facades (e.g., Stripe::feeBatch()).FeeBatchRepository) to decouple Laravel models from Stripe SDK.Database:
Schema::create('fee_batches', function (Blueprint $table) {
$table->string('stripe_id')->unique();
$table->json('metadata');
$table->timestamps();
});
check_deposit_address_deprecated).StripeResourceModel (custom trait) for new resources:
class FeeBatch extends Model
{
use StripeResourceModel;
protected $stripeClass = \Stripe\V2\Core\FeeBatch::class;
}
HTTP:
routes/web.php:
Route::post('/stripe/webhook/v2-money-management/financial-account-statement-created',
[WebhookController::class, 'handleFinancialAccountStatementCreated']
);
GET /api/fee-batches).Queues:
ProcessFeeBatchJob):
class ProcessFeeBatchJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable;
public function handle() {
$feeBatch = FeeBatch::createFromStripe();
// Sync with Laravel models
}
}
check_deposit_address usage.check_deposit_address_deprecated).address.country).FeeBatch, DebitDispute).How can I help you explore Laravel packages today?