Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Stripe Php Laravel Package

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+.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Expanded Stripe Resource Support: New resources (V2.Core.FeeBatch, V2.MoneyManagement.DebitDispute, etc.) align with Laravel’s Eloquent patterns for domain-specific modeling (e.g., FeeBatch, DebitDispute models).
    • Delegated Checkout Enhancements: Support for discounts, amount_sale, and amount_discount on DelegatedCheckout.RequestedSession enables richer Laravel-based checkout flows (e.g., dynamic pricing via Eloquent observers).
    • Testing Improvements: New test helpers (simulate_network_lifecycle_pre_arbitration_response) integrate with Laravel’s testing tools (e.g., Pest/PHPUnit mocks for dispute simulations).
    • Event-Driven Extensions: New event notifications (V2MoneyManagementFinancialAccountStatementCreatedEvent) can trigger Laravel events (e.g., financial_account_statement_created) for reactive workflows.
    • Optional Fields: Changes like making address.country optional reduce Laravel model validation boilerplate (e.g., nullable() in migrations).
  • Cons:

    • Breaking Changes:
      • Removal of check_deposit_address from multiple resources (e.g., Invoice, Subscription) may require Laravel model updates and migration of existing data.
      • Mitigation: Use Laravel’s schema migrations to add nullable columns or deprecated fields (e.g., check_deposit_address_deprecated).
    • Complexity Risk:
      • New resources (e.g., FeeBatch, FinancialAccountStatement) introduce deeper Stripe API coupling. Laravel apps may need additional services/contracts to abstract these.
      • Mitigation: Implement adapters (e.g., FeeBatchAdapter) to decouple Laravel models from Stripe SDK changes.
    • Async Limitations Persist:
      • No native async support in Stripe’s PHP SDK; Laravel queues remain the primary solution for background processing (e.g., webhooks, batch operations).

Integration Feasibility

  • Laravel Ecosystem Synergy:

    • New Resources as Eloquent Models:
      • Extend Laravel’s Model class for new Stripe resources (e.g., app/Models/V2/FeeBatch.php).
      • Use Stripe\Stripe::resource() to hydrate models from API responses.
    • Delegated Checkout:
      • Sync DelegatedCheckout.RequestedSession with Laravel’s Order or CheckoutSession models, leveraging new fields (discounts, amount_sale) for dynamic pricing.
    • Events:
      • Register new Stripe events as Laravel listeners (e.g., Events\HandlesV2MoneyManagementFinancialAccountStatementCreated).
      • Use Laravel’s dispatch() to trigger domain events (e.g., FinancialAccountStatementCreated).
    • Testing:
      • Integrate new test helpers with Laravel’s tests/Feature/StripeTest.php (e.g., simulate disputes for DebitDispute models).
  • Database Synergy:

    • Migrations for New Fields:
      • Add columns for new fields (e.g., dispute_details, payment_attempt_record) to existing Laravel models (e.g., payment_attempt_records table).
      • Use Laravel’s Schema::table() for backward-compatible updates.
    • Deprecated Fields:
      • Add check_deposit_address_deprecated column to invoices/subscriptions tables and populate via a migration.

Technical Risk

  • Breaking Changes:

    • check_deposit_address Removal:
      • Risk: Existing Laravel apps using this field will fail. Stripe’s API no longer accepts it, but some legacy data may still reference it.
      • Mitigation:
        • Add a Laravel migration to archive deprecated values.
        • Use a trait (e.g., DeprecatedCheckDepositAddress) to handle legacy cases.
    • New Resource Complexity:
      • Risk: FeeBatch, FinancialAccountStatement, and DebitDispute introduce new business logic layers. Laravel apps may need additional services to manage these.
      • Mitigation:
        • Start with read-only integration (e.g., FinancialAccountStatement::all()).
        • Gradually add write operations with Laravel transactions.
    • Enum Changes:
      • New values (e.g., debit_dispute in Transaction.category) may require Laravel model casts or database enum updates.
      • Mitigation: Use Laravel’s CastsAttributes to handle enum serialization.
  • Error Handling:

    • New resources/events may introduce unhandled exceptions (e.g., Stripe\Exception\InvalidRequestException for invalid payment_behavior).
    • Mitigation: Extend Laravel’s App\Exceptions\Handler to centralize Stripe error responses.
  • Performance:

    • Batch operations (e.g., FeeBatch) may require Laravel’s chunking or queues to avoid timeouts.
    • Mitigation: Use Laravel’s collect()->chunk(100) or queue jobs for large batches.

Key Questions

  1. Deprecated Fields:
    • How will Laravel apps handle the removal of check_deposit_address? (Archive, ignore, or migrate to a new field?)
  2. New Resource Adoption:
    • Which Laravel models will map to new Stripe resources (e.g., FeeBatch, DebitDispute)? Should these be core or optional?
  3. Delegated Checkout:
    • How will Laravel sync DelegatedCheckout.RequestedSession discounts with existing pricing logic (e.g., Coupon models)?
  4. Event-Driven Workflows:
    • Which Laravel events will trigger for new Stripe events (e.g., FinancialAccountStatementCreated)? Will these use queues?
  5. Testing Strategy:
    • How will Laravel test new Stripe features (e.g., dispute simulations)? Will Stripe\TestHelper be integrated into CI?
  6. Monitoring:
    • How will Laravel track usage of new resources (e.g., FeeBatch API calls)? Will custom metrics be added to Stripe logs?
  7. Backward Compatibility:
    • How will Laravel handle apps still using deprecated check_deposit_address during migration?

Integration Approach

Stack Fit

  • Laravel Core:

    • Service Container:
      • Bind new Stripe resources to Laravel’s container (e.g., app/Providers/StripeServiceProvider.php):
        $this->app->bind(
            \App\Services\V2\FeeBatchService::class,
            fn($app) => new \App\Services\V2\FeeBatchService(
                $app->make(\Stripe\StripeClient::class)
            )
        );
        
    • Facades (Optional):
      • Extend existing Stripe facade or create sub-facades (e.g., Stripe::feeBatch()).
    • Contracts:
      • Define interfaces (e.g., FeeBatchRepository) to decouple Laravel models from Stripe SDK.
  • Database:

    • Migrations:
      • Add tables/columns for new resources:
        Schema::create('fee_batches', function (Blueprint $table) {
            $table->string('stripe_id')->unique();
            $table->json('metadata');
            $table->timestamps();
        });
        
      • Add nullable columns for deprecated fields (e.g., check_deposit_address_deprecated).
    • Eloquent Models:
      • Extend StripeResourceModel (custom trait) for new resources:
        class FeeBatch extends Model
        {
            use StripeResourceModel;
        
            protected $stripeClass = \Stripe\V2\Core\FeeBatch::class;
        }
        
  • HTTP:

    • Webhooks:
      • Register new event handlers in routes/web.php:
        Route::post('/stripe/webhook/v2-money-management/financial-account-statement-created',
            [WebhookController::class, 'handleFinancialAccountStatementCreated']
        );
        
      • Use Laravel middleware to validate signatures and dispatch events.
    • API Routes:
      • Add routes for new resources (e.g., GET /api/fee-batches).
  • Queues:

    • Background Jobs:
      • Process new resources asynchronously (e.g., ProcessFeeBatchJob):
        class ProcessFeeBatchJob implements ShouldQueue
        {
            use Dispatchable, InteractsWithQueue, Queueable;
        
            public function handle() {
                $feeBatch = FeeBatch::createFromStripe();
                // Sync with Laravel models
            }
        }
        

Migration Path

  1. Phase 1: Assessment & Planning
    • Audit existing Laravel models for check_deposit_address usage.
    • Identify new Stripe resources to integrate (prioritize based on business needs).
  2. Phase 2: Backward Compatibility
    • Add migrations for deprecated fields (e.g., check_deposit_address_deprecated).
    • Update Laravel models to handle optional fields (e.g., address.country).
  3. Phase 3: New Resource Integration
    • Create Eloquent models for new resources (FeeBatch, DebitDispute).
    • Implement basic CRUD operations with Stripe SDK.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope