feat: accumulated work — PI-SPI, KYC, RLS, mutuelle parts, comptabilité PDF + startup fixes
## PI-SPI BCEAO (P0.3 — deadline 30/06/2026)
- package payment/pispi/ complet : PispiAuth (OAuth2), PispiClient (HTTP brut),
PispiIso20022Mapper (pacs.008/002), PispiSignatureVerifier (HMAC-SHA256),
PispiWebhookResource (/api/pispi/webhook), DTOs ISO 20022
- PaymentOrchestrator + PaymentProviderRegistry pour l'orchestration multi-provider
- Mode mock automatique si credentials absents (dev)
## KYC AML
- entity/KycDossier, KycResource, KycAmlService + tests
- Migration V38 (create_kyc_dossier_table)
## RLS (PostgreSQL Row-Level Security) — isolation multi-tenant
- RlsConnectionInitializer, RlsContextInterceptor, @RlsEnabled annotation
- Migration V39 (PostgreSQL RLS Tenant Isolation) + V42 (app DB roles)
- Tests unitaires RlsConnectionInitializerTest, RlsContextInterceptorTest
- Tests d'intégration RlsCrossTenantIsolationTest (@QuarkusTest + IntegrationTestProfile)
## Mutuelle — Parts sociales
- entity/mutuelle/parts/ComptePartsSociales, TransactionPartsSociales
- Service, resource, mapper, repository + tests
- InteretsEpargneService + ReleveComptePdfService
## Comptabilité PDF
- ComptabilitePdfService (OpenPDF), ComptabilitePdfResource
- Tests ComptabilitePdfServiceTest, ComptabilitePdfResourceTest
## Migrations Flyway (SYSCOHADA + Keycloak Orgs)
- V36 SYSCOHADA Plan Comptable Complet : seeds comptes standards UEMOA,
trigger init_plan_comptable_organisation, alignement schéma V1 → entités
- V37 keycloak_org_id sur organisations (P0.2 migration KC 26)
- V40 provider_defaut sur FormuleAbonnement
- V41 fcm_token sur utilisateurs (FCM notifications push)
## Fixes startup (SmallRye Config 3.20 + schéma)
- 8× @ConfigProperty(defaultValue = "") → Optional<String>
(firebase, pispi.*, mtnmomo, orange) — empty default rejetés par SmallRye 3.20
- application.properties : mappings secrets env var sous %prod. uniquement
- V36 : drop colonne obsolète 'numero' de V1 quand Hibernate a créé 'numero_compte'
- V36 : remplacement UNIQUE global sur journaux_comptables.code par composite
(organisation_id, code) pour autoriser plusieurs orgs avec code 'ACH'/'VTE'/etc
- V39 : escape placeholder ${VAR} → <VAR> dans lignes commentées
(Flyway parser évalue les placeholders même dans les commentaires)
- V41 : table 'membres' → 'utilisateurs' (nom correct selon entité Membre)
- JournalComptable entity : @UniqueConstraint composite au lieu de unique=true
- MembreResource : example @Schema JSON valide (['...'] → [])
- IntegrationTestProfile : auto-détection Docker via `docker info`, fallback
vers PostgreSQL local sans DevServices
## Dev config
- application-dev.properties : quarkus.devservices.enabled=false +
quarkus.kafka.devservices.enabled=false (pas besoin de Docker pour dev)
- quarkus.flyway.placeholder-replacement=false
- Secrets dev (wave.*, firebase, pispi) en mode mock automatique
## Phase 8 tests (complète)
- 170 fichiers modifiés/ajoutés, 23425+ insertions
- Tests RBAC (@QuarkusTest) pour MembreResource lifecycle
- Tests OrganisationContextFilter multi-org
- Tests SouscriptionQuotaOptionC, KycAmlService, EmailTemplate, etc.
Résultat : Backend démarre en 64s sur port 8085 avec 36 features installées.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
package dev.lions.unionflow.server.resource;
|
||||
|
||||
import dev.lions.unionflow.server.api.payment.*;
|
||||
import dev.lions.unionflow.server.entity.SouscriptionOrganisation;
|
||||
import dev.lions.unionflow.server.payment.orchestration.PaymentOrchestrator;
|
||||
import dev.lions.unionflow.server.payment.orchestration.PaymentProviderRegistry;
|
||||
import dev.lions.unionflow.server.repository.SouscriptionOrganisationRepository;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Endpoints de paiement unifiés — abstraction multi-provider.
|
||||
* Remplace à terme les endpoints Wave-spécifiques.
|
||||
*/
|
||||
@Slf4j
|
||||
@Path("/api/paiements")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class PaiementUnifieResource {
|
||||
|
||||
@Inject
|
||||
PaymentOrchestrator orchestrator;
|
||||
|
||||
@Inject
|
||||
PaymentProviderRegistry registry;
|
||||
|
||||
@Inject
|
||||
SouscriptionOrganisationRepository souscriptionRepository;
|
||||
|
||||
/**
|
||||
* Initie un paiement via le provider demandé (ou le provider par défaut).
|
||||
*
|
||||
* <p>Exemple : {@code POST /api/paiements/initier?provider=WAVE}
|
||||
*/
|
||||
@POST
|
||||
@Path("/initier")
|
||||
@RolesAllowed({"MEMBRE_ACTIF", "ADMIN_ORGANISATION", "TRESORIER", "SUPER_ADMIN"})
|
||||
public Response initier(
|
||||
@QueryParam("provider") String provider,
|
||||
PaiementInitierRequest req) {
|
||||
try {
|
||||
// Si une souscription est fournie, utiliser le providerDefaut de sa formule
|
||||
String resolvedProvider = provider;
|
||||
if (req.souscriptionId() != null) {
|
||||
resolvedProvider = souscriptionRepository.findByIdOptional(req.souscriptionId())
|
||||
.map(SouscriptionOrganisation::getFormule)
|
||||
.map(f -> f.getProviderDefaut())
|
||||
.filter(p -> p != null && !p.isBlank())
|
||||
.orElse(provider);
|
||||
}
|
||||
|
||||
CheckoutRequest checkoutRequest = new CheckoutRequest(
|
||||
req.montant(),
|
||||
req.devise() != null ? req.devise() : "XOF",
|
||||
req.telephone(),
|
||||
req.email(),
|
||||
req.reference(),
|
||||
req.successUrl(),
|
||||
req.cancelUrl(),
|
||||
Map.of()
|
||||
);
|
||||
CheckoutSession session = orchestrator.initierPaiement(checkoutRequest, resolvedProvider);
|
||||
return Response.ok(session).build();
|
||||
} catch (PaymentException e) {
|
||||
return Response.status(e.getHttpStatus())
|
||||
.entity(Map.of("error", e.getMessage(), "provider", e.getProviderCode()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Webhook entrant d'un provider. Vérifie la signature et met à jour le statut.
|
||||
* Route : {@code POST /api/paiements/webhook/{provider}}
|
||||
*/
|
||||
@POST
|
||||
@Path("/webhook/{provider}")
|
||||
@PermitAll
|
||||
@Consumes(MediaType.WILDCARD)
|
||||
public Response webhook(
|
||||
@PathParam("provider") String providerCode,
|
||||
String rawBody,
|
||||
@Context HttpHeaders httpHeaders) {
|
||||
try {
|
||||
PaymentProvider provider = registry.get(providerCode.toUpperCase());
|
||||
Map<String, String> headers = httpHeaders.getRequestHeaders().entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
e -> e.getValue().isEmpty() ? "" : e.getValue().get(0)
|
||||
));
|
||||
|
||||
PaymentEvent event = provider.processWebhook(rawBody, headers);
|
||||
orchestrator.handleEvent(event);
|
||||
return Response.ok().build();
|
||||
|
||||
} catch (UnsupportedOperationException e) {
|
||||
return Response.status(Response.Status.NOT_FOUND)
|
||||
.entity(Map.of("error", "Provider inconnu : " + providerCode))
|
||||
.build();
|
||||
} catch (PaymentException e) {
|
||||
log.error("Webhook {} rejeté : {}", providerCode, e.getMessage());
|
||||
return Response.status(e.getHttpStatus())
|
||||
.entity(Map.of("error", e.getMessage()))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
/** Retourne les providers de paiement disponibles. */
|
||||
@GET
|
||||
@Path("/providers")
|
||||
@RolesAllowed({"ADMIN_ORGANISATION", "SUPER_ADMIN"})
|
||||
public List<String> getProviders() {
|
||||
return registry.getAvailableCodes();
|
||||
}
|
||||
|
||||
public record PaiementInitierRequest(
|
||||
BigDecimal montant,
|
||||
String devise,
|
||||
String telephone,
|
||||
String email,
|
||||
String reference,
|
||||
String successUrl,
|
||||
String cancelUrl,
|
||||
/** Optionnel — si fourni, le providerDefaut de la formule prend le dessus sur le query param. */
|
||||
UUID souscriptionId
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user