2026-03-19 20:37:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Tests\Service;
|
|
|
|
|
|
|
|
|
|
use App\Service\StripeService;
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
|
|
class StripeServiceTest extends TestCase
|
|
|
|
|
{
|
Refactor Stripe integration: single Connect webhook, account pages, cleanup
Stripe webhook:
- Single webhook endpoint /stripe/webhook for Connect + payment events
- v2 Connect events configured manually in Stripe Dashboard (not via API)
- account.updated syncs charges_enabled/payouts_enabled via API retrieve
- Remove StripeSyncCommand and saveWebhookSecret (secret managed via Ansible vault)
Account page (/mon-compte):
- Buyer tabs: Billets, Achats, Factures, Parametres
- Organizer tabs: Evenements/Brocantes, Sous-comptes, Virements + buyer tabs
- Stripe Connect status banner: setup required, pending verification, active, refused
- Stripe Connect onboarding: create account, complete verification (GET links)
- Dashboard Stripe: opens in new tab via createLoginLink (Express dashboard)
- Cancel/close Stripe account: deletes via API + resets local fields
- Stripe required message on events/subaccounts/payouts tabs when not active
- Settings: organizer fields locked (name, address), email/phone editable
- Return/refresh routes for Stripe Connect onboarding flow
- Error handling with flash messages on all Stripe operations
- Auto-sync Stripe status on /mon-compte visit
StripeService cleanup:
- Remove syncWebhook, saveWebhookSecret, getWebhookUrl, projectDir
- Add deleteAccount method
- Keep: verifyWebhookSignature, createAccountConnect, createAccountLink, createLoginLink
Security:
- Add connect.stripe.com and dashboard.stripe.com to nelmio whitelist
- Add STRIPE_SK, STRIPE_WEBHOOK_SECRET, OUTSIDE_URL to .env.test
Tests: 19 AccountControllerTest, 4 StripeWebhookControllerTest, 1 StripeServiceTest
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 22:41:31 +01:00
|
|
|
private function createService(): StripeService
|
2026-03-19 20:37:16 +01:00
|
|
|
{
|
2026-04-01 14:07:49 +02:00
|
|
|
return new StripeService('sk_test', 'whsec_test_insta', 'whsec_test_leger', 'https://example.com');
|
2026-03-19 20:37:16 +01:00
|
|
|
}
|
|
|
|
|
|
2026-04-01 14:07:49 +02:00
|
|
|
public function testVerifyWebhookSignatureInstaReturnsNullOnInvalid(): void
|
2026-03-19 20:37:16 +01:00
|
|
|
{
|
2026-04-01 14:07:49 +02:00
|
|
|
self::assertNull($this->createService()->verifyWebhookSignatureInsta('{}', 'invalid'));
|
2026-03-19 20:37:16 +01:00
|
|
|
}
|
2026-03-20 23:35:42 +01:00
|
|
|
|
2026-04-01 14:07:49 +02:00
|
|
|
public function testVerifyWebhookSignatureLegerReturnsNullOnInvalid(): void
|
2026-03-20 23:35:42 +01:00
|
|
|
{
|
2026-04-01 14:07:49 +02:00
|
|
|
self::assertNull($this->createService()->verifyWebhookSignatureLeger('{}', 'invalid'));
|
2026-03-20 23:35:42 +01:00
|
|
|
}
|
2026-03-19 20:37:16 +01:00
|
|
|
}
|