Files
crm_ecosplay/migrations/Version20260402205935.php

33 lines
1.0 KiB
PHP
Raw Permalink Normal View History

refactor: stocker les secrets webhook Stripe en BDD au lieu de .env.local src/Entity/StripeWebhookSecret.php (nouveau): - Constantes TYPE_MAIN_LIGHT, TYPE_MAIN_INSTANT, TYPE_CONNECT_LIGHT, TYPE_CONNECT_INSTANT pour les 4 types de webhook - type: string(30) unique, identifie le webhook (main_light, etc.) - secret: string(255), le signing secret retourne par Stripe (whsec_xxx) - endpointId: string nullable, l'ID de l'endpoint Stripe (we_xxx) - createdAt: DateTimeImmutable src/Repository/StripeWebhookSecretRepository.php (nouveau): - findByType(): trouve un secret par type - getSecret(): retourne directement la valeur du secret ou null src/Controller/WebhookStripeController.php (reecrit): - Les 4 routes lisent le secret depuis la BDD via StripeWebhookSecretRepository::getSecret() au lieu de variables d'env - Retourne HTTP 503 si le secret n'est pas encore configure - Plus besoin des variables STRIPE_WH_*_SECRET dans .env src/Controller/Admin/SyncController.php: - syncStripeWebhooks(): sauvegarde les secrets en BDD (cree ou met a jour StripeWebhookSecret par type) - Suppression de saveSecretsToEnvLocal() (plus de modification .env.local) - URL de base lue depuis WEBHOOK_BASE_URL (env) .env: - Suppression des 4 variables STRIPE_WH_*_SECRET (stockees en BDD) - Ajout WEBHOOK_BASE_URL (vide par defaut) docker/ngrok/sync.sh: - Ecrit aussi WEBHOOK_BASE_URL en plus de OUTSIDE_URL ansible/env.local.j2: - WEBHOOK_BASE_URL=https://stripe.siteconseil.fr pour la prod migrations/Version20260402205935.php: - Table stripe_webhook_secret avec type unique, secret, endpoint_id Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 22:59:51 +02:00
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260402205935 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE stripe_webhook_secret (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, type VARCHAR(30) NOT NULL, secret VARCHAR(255) NOT NULL, endpoint_id VARCHAR(255) DEFAULT NULL, created_at TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY (id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_D9BDCBA48CDE5729 ON stripe_webhook_secret (type)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE stripe_webhook_secret');
}
}