brazilianfriendsofsymfony/pagamento-bundle
Bundle Symfony para agregar funcionalidades comuns a meios de pagamento no Brasil, inspirado no JMSPaymentCoreBundle. Inclui utilitários e Twig helper para opções de parcelamento (juros, limites, templates) e suporte a formulários de escolha de pagamento.
Pros:
ParcelamentoUtils) suggests extensibility for new payment gateways.Cons:
FormBuilderInterface, AbstractType), requiring significant abstraction for Laravel.e37secret), implying manual config management.Core Features:
Pagamento::createPayment()).@installmentOptions($config, $value)).Blockers:
JMSPaymentCoreBundle patterns; Laravel would need custom adapters (e.g., for PagSeguro’s Laravel SDK).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony-Laravel Gap | High | Abstract core logic into Laravel Services; use Symfony Bridge for Forms. |
| Frontend Dependencies | Medium | Replace jQuery with Alpine.js for dynamic UI; lazy-load RequireJS. |
| Gateway Support | Medium | Build a plugin system for new gateways (e.g., MercadoPago, Stripe). |
| State Management | Low | Use Laravel’s Session or Cache for payment state. |
| Testing | High | Write Pest/PHPUnit tests for core utils; mock gateways. |
Laravel Compatibility:
Container to Laravel’s Service Container via a custom compiler pass.Recommended Tech Stack:
| Layer | Laravel Equivalent | Adaptation Notes |
|---|---|---|
| Forms | Form Requests / Livewire | Replace FormBuilderInterface with Request. |
| Templating | Blade + Alpine.js | Rewrite Twig functions as Blade directives. |
| Asset Pipeline | Vite/Mix | Replace RequireJS with ES Modules. |
| DI | Service Container | Use bind() in AppServiceProvider. |
| Payments | Spatie’s Gateways + Cashier | Extend for parceling logic. |
Phase 1: Core Logic Extraction (2–3 weeks)
ParcelamentoUtils) into a Laravel package.FormType with Laravel Form Requests or Livewire.// Before (Symfony)
$builder->add('formaPagamento', 'bfos_pagamento_forma_pagamento_checkout_choice');
// After (Laravel/Livewire)
public function mount(PaymentConfig $config, $value) {
$this->installmentOptions = InstallmentCalculator::calculate($config, $value);
}
Phase 2: Frontend Adaptation (1–2 weeks)
<!-- Before (jQuery/RequireJS) -->
<script src="assets/bfos-pagamento.js"></script>
<!-- After (Alpine.js) -->
<div x-data="{ open: false }">
<button @click="open = true">Ver parcelas</button>
<template x-if="open">
@include('payments.installments', ['options' => $installmentOptions])
</template>
</div>
Phase 3: Gateway Integration (2–4 weeks)
PagSeguroGateway, MercadoPagoGateway).class PagamentoServiceProvider extends ServiceProvider {
public function register() {
$this->app->bind(PaymentGateway::class, function () {
return new PagSeguroGateway(config('pagamento.pagseguro'));
});
}
}
Phase 4: Testing & Optimization (1–2 weeks)
InstallmentCalculator.Http client.Pros:
Cons:
Mitigation:
CHANGELOG.md.How can I help you explore Laravel packages today?