- Can I use BFOSPagamentoBundle directly in Laravel without Symfony?
- No, the bundle is Symfony-specific and requires abstraction for Laravel. You’ll need to extract core logic (e.g., `ParcelamentoUtils`) into a Laravel package, replace Symfony Forms with Form Requests or Livewire, and adapt Twig functions to Blade directives. The Symfony Bridge or Lumen may help bridge gaps.
- How do I handle payment gateway integration (e.g., PagSeguro, MercadoPago) in Laravel?
- The bundle assumes Symfony’s `JMSPaymentCoreBundle` patterns, so you’ll need to build a Laravel-compatible wrapper. For PagSeguro, use the official Laravel SDK; for MercadoPago, leverage Spatie’s Payment Gateways or create a custom Service Provider. The bundle’s `ParcelamentoUtils` can still handle parceling logic.
- What’s the best way to migrate jQuery/RequireJS dependencies to Laravel’s modern stack?
- Replace jQuery with Alpine.js for lightweight interactivity or use Inertia.js for full-stack reactivity. RequireJS can be dropped in favor of Laravel Mix/Vite’s ES Modules. If dynamic UI is critical, rewrite the parceling logic using Alpine.js components or Vue/React hooks.
- Does this bundle support Laravel’s Blade templating instead of Twig?
- Yes, but you’ll need to rewrite the Twig functions (e.g., `bfos_pagamento_opcoes_parcelamento()`) as Blade directives or use the TwigBridge package to integrate Twig into Laravel. Example: Convert Twig logic to a Blade component or helper like `@installmentOptions($config, $value)`.
- How do I configure parceling rules (e.g., max installments, interest rates) in Laravel?
- The bundle’s `ParcelamentoConfiguracao` class defines rules like `setQuantidadeMaximaParcelas(12)` or `setJurosParcelamento(1.99)`. In Laravel, instantiate this class in a Service Provider or Form Request, then pass it to your parceling logic. Example: `$config = new ParcelamentoConfiguracao(); $config->setParcelamentoHabilitado(true);`
- Are there Laravel alternatives for payment parceling with better support?
- Yes. For global payments, use Laravel Cashier (Stripe) or Spatie’s Payment Gateways. For Brazilian-specific needs, consider forking this bundle or evaluating MercadoPago’s Laravel SDK. If parceling is a core feature, a custom package built on Spatie’s Gateways may be more maintainable.
- How do I handle payment secrets (e.g., API keys) securely in production?
- Avoid hardcoding secrets like `e37secret`. Use Laravel’s `.env` file for sensitive data (e.g., `PAGSEGURO_SECRET=your_key`). Inject these into your Service Providers or Form Requests via `config()` or `env()`. Never commit `.env` to version control.
- Can I test the parceling logic without connecting to real payment gateways?
- Yes. Mock the gateway dependencies in PHPUnit/Pest tests. For example, use Laravel’s `Mockery` to fake the `ParcelamentoUtils` or gateway responses. Test edge cases like `ValorMinimoParcela` or `QuantidadeMaximaParcelas` with assertions on the returned array of installment options.
- What Laravel versions does this bundle support, and are there breaking changes?
- The bundle is Symfony-focused, so Laravel compatibility depends on your abstraction layer. Target Laravel 9+ for modern features like Symfony Bridge or Livewire. Breaking changes may arise from Symfony’s DI updates; monitor the bundle’s GitHub for Symfony version bumps.
- How do I extend this bundle to support additional payment methods (e.g., PicPay, Itau Shopline)?
- Create a plugin system in Laravel. Build a base `PaymentGateway` interface, then implement adapters for each provider (e.g., `PicPayGateway`). Use Laravel’s Service Container to bind these classes. The bundle’s `ParcelamentoUtils` can remain agnostic to the gateway, focusing only on installment logic.