Facturation Stripe : abonnement, suspension pour impayé, factures PDF
- Lien Checkout d'abonnement 10 €/mois (carte ou SEPA) créé depuis l'admin et envoyé au contact du magasin - Webhook Stripe signé : suivi de l'abonnement, suspension automatique des magasins actifs en cas d'impayé, réactivation au paiement (uniquement si la suspension venait de la facturation) - Factures MEP-AAAA-NNNNNN à numérotation continue, PDF avec mentions légales (art. 293 B, pénalités, indemnité 40 €), envoyées par e-mail - Onglet Facturation dans l'admin, page /abonnement/merci/ sur le site - Migration SQL manuelle prisma/manual-migrations/2026-10-06-facturation.sql Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5b4a3018b7
commit
f6bd030b35
18 changed files with 1580 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -24,3 +24,6 @@ carte-test.pkpass
|
|||
*.rar
|
||||
*.7z
|
||||
*.tar.gz
|
||||
|
||||
# Factures PDF générées (archive légale, sauvegardée côté serveur)
|
||||
backend/storage/
|
||||
|
|
|
|||
|
|
@ -107,6 +107,20 @@ async function request<T>(method: string, path: string, body?: unknown, auth = t
|
|||
return (text ? JSON.parse(text) : null) as T;
|
||||
}
|
||||
|
||||
/** Téléchargement d'un fichier protégé (le jeton ne peut pas passer par un simple lien). */
|
||||
export async function downloadFile(path: string, filename: string) {
|
||||
if (!accessToken) await refresh();
|
||||
let res = await fetch(`${BASE}${path}`, { headers: { Authorization: `Bearer ${accessToken}` } });
|
||||
if (res.status === 401 && (await refresh())) {
|
||||
res = await fetch(`${BASE}${path}`, { headers: { Authorization: `Bearer ${accessToken}` } });
|
||||
}
|
||||
if (!res.ok) throw new ApiError(res.status, 'Téléchargement impossible');
|
||||
const url = URL.createObjectURL(await res.blob());
|
||||
const a = Object.assign(document.createElement('a'), { href: url, download: filename });
|
||||
a.click();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 10_000);
|
||||
}
|
||||
|
||||
export const api = {
|
||||
get: <T>(path: string) => request<T>('GET', path),
|
||||
post: <T>(path: string, body?: unknown) => request<T>('POST', path, body ?? {}),
|
||||
|
|
@ -130,6 +144,7 @@ export interface Store {
|
|||
contactEmail: string;
|
||||
contactPhone: string;
|
||||
status: StoreStatus;
|
||||
billingSuspended: boolean;
|
||||
maxAmountEuros: number;
|
||||
minScanIntervalMin: number;
|
||||
createdAt: string;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { FormEvent, useState } from 'react';
|
||||
import { Store } from '../api';
|
||||
|
||||
export type StoreInput = Omit<Store, 'id' | 'slug' | 'status' | 'createdAt'>;
|
||||
export type StoreInput = Omit<Store, 'id' | 'slug' | 'status' | 'billingSuspended' | 'createdAt'>;
|
||||
|
||||
export const EMPTY_STORE: StoreInput = {
|
||||
name: '',
|
||||
|
|
|
|||
115
admin/src/pages/BillingTab.tsx
Normal file
115
admin/src/pages/BillingTab.tsx
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { api, downloadFile, SubscriptionStatus } from '../api';
|
||||
|
||||
interface Billing {
|
||||
testMode: boolean;
|
||||
subscription: { status: SubscriptionStatus; currentPeriodEnd: string | null; hasCustomer: boolean } | null;
|
||||
billingSuspended: boolean;
|
||||
invoices: { id: string; number: string; amountCents: number; periodStart: string; periodEnd: string; issuedAt: string; paidAt: string | null }[];
|
||||
}
|
||||
|
||||
const STATUS: Record<SubscriptionStatus, [string, string]> = {
|
||||
ACTIVE: ['Actif', 'ACTIVE'],
|
||||
INCOMPLETE: ['En attente de paiement', 'DRAFT'],
|
||||
PAST_DUE: ['Impayé', 'SUSPENDED'],
|
||||
CANCELED: ['Résilié', 'CLOSED'],
|
||||
};
|
||||
|
||||
const euros = (c: number) => (c / 100).toLocaleString('fr-FR', { style: 'currency', currency: 'EUR' });
|
||||
const day = (d: string) => new Date(d).toLocaleDateString('fr-FR', { day: 'numeric', month: 'short', year: 'numeric' });
|
||||
|
||||
export function BillingTab({ storeId, contactEmail, onChange }: { storeId: string; contactEmail: string; onChange: () => void }) {
|
||||
const [data, setData] = useState<Billing | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [link, setLink] = useState<{ url: string; emailedTo: string | null } | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const reload = useCallback(() => {
|
||||
api.get<Billing>(`/api/admin/stores/${storeId}/billing`).then(setData).catch((e) => setError(e.message));
|
||||
}, [storeId]);
|
||||
useEffect(reload, [reload]);
|
||||
|
||||
async function createLink(sendEmail: boolean) {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
setLink(await api.post(`/api/admin/stores/${storeId}/billing/checkout-link`, { sendEmail }));
|
||||
reload();
|
||||
onChange();
|
||||
} catch (e) {
|
||||
setError((e as Error).message);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!data) return error ? <div className="alert error">{error}</div> : <p className="muted">Chargement…</p>;
|
||||
const sub = data.subscription;
|
||||
const active = sub?.status === 'ACTIVE';
|
||||
|
||||
return (
|
||||
<>
|
||||
{data.testMode && <div className="alert warn">Stripe est en mode test : aucun paiement réel n'est encaissé (carte de test 4242 4242 4242 4242).</div>}
|
||||
{error && <div className="alert error" role="alert">{error}</div>}
|
||||
|
||||
<section className="card" style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
||||
<div className="row between">
|
||||
<div>
|
||||
<h2>Abonnement</h2>
|
||||
<p className="muted" style={{ margin: 0 }}>10 € par mois, sans engagement — carte bancaire ou prélèvement SEPA.</p>
|
||||
</div>
|
||||
<span className={`badge ${sub ? STATUS[sub.status][1] : 'DRAFT'}`}>{sub ? STATUS[sub.status][0] : 'Aucun abonnement'}</span>
|
||||
</div>
|
||||
{sub?.currentPeriodEnd && active && <p style={{ margin: 0 }}>Prochain prélèvement le <strong>{day(sub.currentPeriodEnd)}</strong>.</p>}
|
||||
{data.billingSuspended && (
|
||||
<div className="alert warn">Magasin suspendu automatiquement pour impayé. Il sera réactivé dès que le paiement passera.</div>
|
||||
)}
|
||||
{!active && (
|
||||
<div className="row" style={{ gap: 8 }}>
|
||||
<button className="btn" disabled={busy} onClick={() => createLink(true)}>Envoyer le lien d'abonnement à {contactEmail}</button>
|
||||
<button className="btn secondary" disabled={busy} onClick={() => createLink(false)}>Créer le lien sans l'envoyer</button>
|
||||
</div>
|
||||
)}
|
||||
{link && (
|
||||
<div className="alert ok">
|
||||
{link.emailedTo ? <>Lien envoyé à <strong>{link.emailedTo}</strong>. </> : null}
|
||||
Valable 24 h :{' '}
|
||||
<a href={link.url} target="_blank" rel="noreferrer" style={{ wordBreak: 'break-all' }}>{link.url}</a>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<div className="table-wrap">
|
||||
<div className="table-scroll">
|
||||
<table style={{ minWidth: 640 }}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" style={{ paddingLeft: 24 }}>Facture</th>
|
||||
<th scope="col">Période</th>
|
||||
<th scope="col" className="num">Montant</th>
|
||||
<th scope="col">Statut</th>
|
||||
<th scope="col"><span className="sr-only">PDF</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.invoices.map((i) => (
|
||||
<tr key={i.id}>
|
||||
<td style={{ paddingLeft: 24, fontWeight: 600 }}>{i.number}</td>
|
||||
<td>{day(i.periodStart)} → {day(i.periodEnd)}</td>
|
||||
<td className="num">{euros(i.amountCents)}</td>
|
||||
<td>{i.paidAt ? <span className="badge ACTIVE">Payée le {day(i.paidAt)}</span> : <span className="badge SUSPENDED">Impayée</span>}</td>
|
||||
<td style={{ textAlign: 'right', paddingRight: 24 }}>
|
||||
<button className="btn secondary small" onClick={() => downloadFile(`/api/admin/invoices/${i.id}/pdf`, `${i.number}.pdf`).catch((e) => setError(e.message))}>
|
||||
PDF
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{data.invoices.length === 0 && <p className="muted" style={{ padding: 24, margin: 0, textAlign: 'center' }}>Aucune facture pour l'instant. Elles sont créées automatiquement à chaque paiement.</p>}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -5,11 +5,13 @@ import { StatusBadge } from '../components/Layout';
|
|||
import { StoreForm } from '../components/StoreForm';
|
||||
import { CardWizard } from './CardWizard';
|
||||
import { StaffTab } from './StaffTab';
|
||||
import { BillingTab } from './BillingTab';
|
||||
|
||||
const TABS = [
|
||||
['infos', 'Infos'],
|
||||
['carte', 'Carte de fidélité'],
|
||||
['employes', 'Employés'],
|
||||
['facturation', 'Facturation'],
|
||||
] as const;
|
||||
|
||||
export function StorePage() {
|
||||
|
|
@ -69,7 +71,8 @@ export function StorePage() {
|
|||
|
||||
{store.status === 'SUSPENDED' && (
|
||||
<div className="alert warn" role="status">
|
||||
Magasin suspendu : les scans et les nouvelles inscriptions sont refusés.
|
||||
Magasin suspendu{store.billingSuspended ? ' pour impayé' : ''} : les scans et les nouvelles inscriptions sont refusés.
|
||||
{store.billingSuspended && <> Voir l'onglet <NavLink to="facturation">Facturation</NavLink>.</>}
|
||||
</div>
|
||||
)}
|
||||
{error && <div className="alert error" role="alert">{error}</div>}
|
||||
|
|
@ -101,6 +104,7 @@ export function StorePage() {
|
|||
/>
|
||||
<Route path="carte" element={<CardWizard store={store} onSaved={reload} />} />
|
||||
<Route path="employes" element={<StaffTab storeId={store.id} />} />
|
||||
<Route path="facturation" element={<BillingTab storeId={store.id} contactEmail={store.contactEmail} onChange={reload} />} />
|
||||
</Routes>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
758
backend/package-lock.json
generated
758
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -36,9 +36,11 @@
|
|||
"passkit-generator": "^3.6.1",
|
||||
"passport": "^0.7.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"pdfkit": "^0.15.2",
|
||||
"qrcode": "^1.5.4",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1"
|
||||
"rxjs": "^7.8.1",
|
||||
"stripe": "^17.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.4.5",
|
||||
|
|
@ -48,6 +50,7 @@
|
|||
"@types/node": "^22.7.4",
|
||||
"@types/nodemailer": "^8.0.2",
|
||||
"@types/passport-jwt": "^4.0.1",
|
||||
"@types/pdfkit": "^0.17.6",
|
||||
"@types/qrcode": "^1.5.6",
|
||||
"prisma": "^5.20.0",
|
||||
"ts-node": "^10.9.2",
|
||||
|
|
|
|||
12
backend/prisma/manual-migrations/2026-10-06-facturation.sql
Normal file
12
backend/prisma/manual-migrations/2026-10-06-facturation.sql
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- Facturation Stripe (étape 6) — à exécuter UNE fois dans phpMyAdmin sur la base monespacepro,
|
||||
-- AVANT de déployer le nouveau code. Table Invoice vide à ce stade : colonnes NOT NULL sans risque.
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `Store` ADD COLUMN `billingSuspended` BOOLEAN NOT NULL DEFAULT false;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE `Invoice` ADD COLUMN `clientAddress` TEXT NOT NULL,
|
||||
ADD COLUMN `clientEmail` VARCHAR(191) NOT NULL,
|
||||
ADD COLUMN `clientName` VARCHAR(191) NOT NULL,
|
||||
ADD COLUMN `clientSiret` VARCHAR(191) NOT NULL;
|
||||
|
||||
|
|
@ -41,6 +41,8 @@ model Store {
|
|||
contactEmail String
|
||||
contactPhone String
|
||||
status StoreStatus @default(DRAFT)
|
||||
/// Suspendu automatiquement pour impayé (réactivé automatiquement au paiement).
|
||||
billingSuspended Boolean @default(false)
|
||||
|
||||
// Anti-triche : réglages par magasin
|
||||
maxAmountCents Int @default(50000) /// plafond d'un montant saisi
|
||||
|
|
@ -224,6 +226,11 @@ model Invoice {
|
|||
store Store @relation(fields: [storeId], references: [id])
|
||||
stripeInvoiceId String? @unique
|
||||
amountCents Int
|
||||
/// Identité du client figée à l'émission (une facture ne change plus).
|
||||
clientName String
|
||||
clientAddress String @db.Text
|
||||
clientSiret String
|
||||
clientEmail String
|
||||
periodStart DateTime
|
||||
periodEnd DateTime
|
||||
issuedAt DateTime @default(now())
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import { MailModule } from './mail/mail.service';
|
|||
import { EnrollmentModule } from './enrollment/enrollment.module';
|
||||
import { CounterModule } from './counter/counter.module';
|
||||
import { ContactModule } from './contact/contact.controller';
|
||||
import { BillingModule } from './billing/billing.controller';
|
||||
import { HealthController } from './health.controller';
|
||||
|
||||
@Module({
|
||||
|
|
@ -23,6 +24,7 @@ import { HealthController } from './health.controller';
|
|||
EnrollmentModule,
|
||||
CounterModule,
|
||||
ContactModule,
|
||||
BillingModule,
|
||||
],
|
||||
controllers: [HealthController],
|
||||
providers: [{ provide: APP_GUARD, useClass: ThrottlerGuard }],
|
||||
|
|
|
|||
69
backend/src/billing/billing.controller.ts
Normal file
69
backend/src/billing/billing.controller.ts
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
import { Body, Controller, Get, Headers, HttpCode, Logger, Module, Param, Post, Req, Res, UseGuards } from '@nestjs/common';
|
||||
import type { RawBodyRequest } from '@nestjs/common';
|
||||
import { SkipThrottle } from '@nestjs/throttler';
|
||||
import { IsBoolean, IsOptional } from 'class-validator';
|
||||
import type { Request, Response } from 'express';
|
||||
import { AdminGuard, JwtAuthGuard } from '../common/guards';
|
||||
import { BillingService } from './billing.service';
|
||||
|
||||
class CheckoutLinkDto {
|
||||
/** Envoyer le lien par e-mail au contact du magasin. */
|
||||
@IsOptional() @IsBoolean()
|
||||
sendEmail?: boolean;
|
||||
}
|
||||
|
||||
@Controller('admin')
|
||||
@UseGuards(JwtAuthGuard, AdminGuard)
|
||||
export class BillingAdminController {
|
||||
constructor(private billing: BillingService) {}
|
||||
|
||||
@Get('stores/:storeId/billing')
|
||||
overview(@Param('storeId') storeId: string) {
|
||||
return this.billing.overview(storeId);
|
||||
}
|
||||
|
||||
@Post('stores/:storeId/billing/checkout-link')
|
||||
@HttpCode(200)
|
||||
checkoutLink(@Param('storeId') storeId: string, @Body() dto: CheckoutLinkDto) {
|
||||
return this.billing.checkoutLink(storeId, dto.sendEmail ?? true);
|
||||
}
|
||||
|
||||
@Get('invoices/:id/pdf')
|
||||
async pdf(@Param('id') id: string, @Res() res: Response) {
|
||||
const [pdf, number] = await Promise.all([this.billing.renderPdf(id), this.billing.invoiceNumber(id)]);
|
||||
res
|
||||
.type('application/pdf')
|
||||
.setHeader('Content-Disposition', `attachment; filename="${number}.pdf"`)
|
||||
.setHeader('Cache-Control', 'private, no-store')
|
||||
.send(pdf);
|
||||
}
|
||||
}
|
||||
|
||||
/** Notifications Stripe : signature vérifiée sur le corps brut. */
|
||||
@Controller('stripe')
|
||||
@SkipThrottle()
|
||||
export class StripeWebhookController {
|
||||
private readonly logger = new Logger(StripeWebhookController.name);
|
||||
|
||||
constructor(private billing: BillingService) {}
|
||||
|
||||
@Post('webhook')
|
||||
@HttpCode(200)
|
||||
async webhook(@Req() req: RawBodyRequest<Request>, @Headers('stripe-signature') signature: string | undefined) {
|
||||
const event = this.billing.verify(req.rawBody, signature);
|
||||
try {
|
||||
await this.billing.handle(event);
|
||||
} catch (e) {
|
||||
// Erreur → 500 : Stripe renverra l'événement plus tard.
|
||||
this.logger.error(`Webhook ${event.type} (${event.id}) : ${(e as Error).message}`);
|
||||
throw e;
|
||||
}
|
||||
return { received: true };
|
||||
}
|
||||
}
|
||||
|
||||
@Module({
|
||||
controllers: [BillingAdminController, StripeWebhookController],
|
||||
providers: [BillingService],
|
||||
})
|
||||
export class BillingModule {}
|
||||
302
backend/src/billing/billing.service.ts
Normal file
302
backend/src/billing/billing.service.ts
Normal file
|
|
@ -0,0 +1,302 @@
|
|||
import { BadRequestException, Injectable, Logger, NotFoundException, ServiceUnavailableException } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Prisma, SubscriptionStatus } from '@prisma/client';
|
||||
import { mkdir, readFile, writeFile } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
import Stripe from 'stripe';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { MailService } from '../mail/mail.service';
|
||||
import { escapeHtml } from '../enrollment/pages';
|
||||
import { renderInvoicePdf } from './invoice-pdf';
|
||||
|
||||
/** Factures PDF : hors des dossiers servis publiquement. */
|
||||
export const INVOICES_DIR = join(process.cwd(), 'storage', 'invoices');
|
||||
|
||||
const STATUS: Record<string, SubscriptionStatus> = {
|
||||
active: 'ACTIVE',
|
||||
trialing: 'ACTIVE',
|
||||
past_due: 'PAST_DUE',
|
||||
unpaid: 'PAST_DUE',
|
||||
canceled: 'CANCELED',
|
||||
incomplete_expired: 'CANCELED',
|
||||
incomplete: 'INCOMPLETE',
|
||||
paused: 'PAST_DUE',
|
||||
};
|
||||
|
||||
const euros = (cents: number) => (cents / 100).toLocaleString('fr-FR', { style: 'currency', currency: 'EUR' });
|
||||
|
||||
/**
|
||||
* Abonnement Stripe (10 €/mois/magasin), suspension automatique en cas
|
||||
* d'impayé, factures numérotées sans trou émises au nom de l'auto-entreprise.
|
||||
*/
|
||||
@Injectable()
|
||||
export class BillingService {
|
||||
private readonly logger = new Logger(BillingService.name);
|
||||
private client: Stripe | null = null;
|
||||
|
||||
constructor(
|
||||
private prisma: PrismaService,
|
||||
private config: ConfigService,
|
||||
private mail: MailService,
|
||||
) {}
|
||||
|
||||
get stripe(): Stripe {
|
||||
const key: string = this.config.get('stripe.secretKey')!;
|
||||
if (!key) throw new ServiceUnavailableException('Stripe n’est pas configuré');
|
||||
this.client ??= new Stripe(key);
|
||||
return this.client;
|
||||
}
|
||||
|
||||
/** Résumé pour l'onglet Facturation de l'admin. */
|
||||
async overview(storeId: string) {
|
||||
const store = await this.prisma.store.findUnique({
|
||||
where: { id: storeId },
|
||||
include: { subscription: true, invoices: { orderBy: { sequence: 'desc' } } },
|
||||
});
|
||||
if (!store) throw new NotFoundException('Magasin introuvable');
|
||||
return {
|
||||
testMode: (this.config.get<string>('stripe.secretKey') ?? '').startsWith('sk_test_'),
|
||||
subscription: store.subscription && {
|
||||
status: store.subscription.status,
|
||||
currentPeriodEnd: store.subscription.currentPeriodEnd,
|
||||
hasCustomer: !!store.subscription.stripeCustomerId,
|
||||
},
|
||||
billingSuspended: store.billingSuspended,
|
||||
invoices: store.invoices.map((i) => ({
|
||||
id: i.id,
|
||||
number: i.number,
|
||||
amountCents: i.amountCents,
|
||||
periodStart: i.periodStart,
|
||||
periodEnd: i.periodEnd,
|
||||
issuedAt: i.issuedAt,
|
||||
paidAt: i.paidAt,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Crée (ou réutilise) le client Stripe du magasin et un lien Checkout
|
||||
* d'abonnement ; l'envoie par e-mail au contact du magasin si demandé.
|
||||
*/
|
||||
async checkoutLink(storeId: string, sendEmail: boolean) {
|
||||
const store = await this.prisma.store.findUnique({ where: { id: storeId }, include: { subscription: true } });
|
||||
if (!store) throw new NotFoundException('Magasin introuvable');
|
||||
if (store.subscription?.status === 'ACTIVE') throw new BadRequestException('Ce magasin a déjà un abonnement actif');
|
||||
|
||||
let customerId = store.subscription?.stripeCustomerId;
|
||||
if (!customerId) {
|
||||
const customer = await this.stripe.customers.create({
|
||||
name: store.name,
|
||||
email: store.contactEmail,
|
||||
phone: store.contactPhone,
|
||||
address: { line1: store.addressLine, postal_code: store.postalCode, city: store.city, country: 'FR' },
|
||||
metadata: { storeId: store.id, siret: store.siret },
|
||||
preferred_locales: ['fr'],
|
||||
});
|
||||
customerId = customer.id;
|
||||
await this.prisma.subscription.upsert({
|
||||
where: { storeId },
|
||||
create: { storeId, stripeCustomerId: customerId },
|
||||
update: { stripeCustomerId: customerId },
|
||||
});
|
||||
}
|
||||
|
||||
const price = (await this.stripe.prices.list({ lookup_keys: [this.config.get('stripe.priceLookupKey')!], limit: 1 })).data[0];
|
||||
if (!price) throw new ServiceUnavailableException('Prix Stripe introuvable');
|
||||
|
||||
const webUrl: string = this.config.get('webUrl')!;
|
||||
const session = await this.stripe.checkout.sessions.create({
|
||||
mode: 'subscription',
|
||||
customer: customerId,
|
||||
line_items: [{ price: price.id, quantity: 1 }],
|
||||
payment_method_types: ['card', 'sepa_debit'],
|
||||
locale: 'fr',
|
||||
client_reference_id: store.id,
|
||||
subscription_data: { metadata: { storeId: store.id } },
|
||||
metadata: { storeId: store.id },
|
||||
success_url: `${webUrl}/abonnement/merci/`,
|
||||
cancel_url: `${webUrl}/tarif/`,
|
||||
expires_at: Math.floor(Date.now() / 1000) + 24 * 3600, // 24 h, maximum autorisé par Stripe
|
||||
});
|
||||
|
||||
if (sendEmail) {
|
||||
const text = `Bonjour ${store.contactName},\n\nVoici le lien pour activer l'abonnement MonEspacePro de ${store.name} (10 € par mois, sans engagement, carte bancaire ou prélèvement SEPA) :\n${session.url}\n\nCe lien est valable 24 heures.\n\nMonEspacePro`;
|
||||
const html = `<p>Bonjour ${escapeHtml(store.contactName)},</p><p>Voici le lien pour activer l'abonnement MonEspacePro de <strong>${escapeHtml(store.name)}</strong> : 10 € par mois, sans engagement, par carte bancaire ou prélèvement SEPA.</p><p><a href="${escapeHtml(session.url!)}">Activer mon abonnement</a></p><p>Ce lien est valable 24 heures.</p><p>MonEspacePro</p>`;
|
||||
await this.mail.send(store.contactEmail, `Activez l'abonnement MonEspacePro de ${store.name}`, text, html);
|
||||
}
|
||||
return { url: session.url, expiresAt: new Date(session.expires_at * 1000), emailedTo: sendEmail ? store.contactEmail : null };
|
||||
}
|
||||
|
||||
// ── Webhook ────────────────────────────────────────────────
|
||||
|
||||
verify(rawBody: Buffer | undefined, signature: string | undefined): Stripe.Event {
|
||||
const secret: string = this.config.get('stripe.webhookSecret')!;
|
||||
if (!rawBody || !signature || !secret) throw new BadRequestException('Signature Stripe manquante');
|
||||
try {
|
||||
return this.stripe.webhooks.constructEvent(rawBody, signature, secret);
|
||||
} catch {
|
||||
throw new BadRequestException('Signature Stripe invalide');
|
||||
}
|
||||
}
|
||||
|
||||
async handle(event: Stripe.Event) {
|
||||
switch (event.type) {
|
||||
case 'checkout.session.completed': {
|
||||
const s = event.data.object;
|
||||
if (s.mode === 'subscription' && s.subscription) await this.syncSubscription(String(s.subscription));
|
||||
break;
|
||||
}
|
||||
case 'customer.subscription.created':
|
||||
case 'customer.subscription.updated':
|
||||
case 'customer.subscription.deleted':
|
||||
await this.syncSubscription(event.data.object.id);
|
||||
break;
|
||||
case 'invoice.paid':
|
||||
await this.onInvoicePaid(event.data.object);
|
||||
break;
|
||||
case 'invoice.payment_failed':
|
||||
await this.onPaymentFailed(event.data.object);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Recopie l'état de l'abonnement Stripe et applique suspension / réactivation. */
|
||||
private async syncSubscription(subscriptionId: string) {
|
||||
const sub = await this.stripe.subscriptions.retrieve(subscriptionId);
|
||||
const storeId = sub.metadata.storeId;
|
||||
if (!storeId) return;
|
||||
const status = STATUS[sub.status] ?? 'INCOMPLETE';
|
||||
const periodEnd = sub.current_period_end;
|
||||
await this.prisma.subscription.upsert({
|
||||
where: { storeId },
|
||||
create: { storeId, stripeCustomerId: String(sub.customer), stripeSubscriptionId: sub.id, status, currentPeriodEnd: periodEnd ? new Date(periodEnd * 1000) : null },
|
||||
update: { stripeCustomerId: String(sub.customer), stripeSubscriptionId: sub.id, status, currentPeriodEnd: periodEnd ? new Date(periodEnd * 1000) : null },
|
||||
});
|
||||
if (status === 'ACTIVE') await this.reactivate(storeId);
|
||||
if (status === 'PAST_DUE' || status === 'CANCELED') await this.suspend(storeId, `abonnement ${sub.status}`);
|
||||
}
|
||||
|
||||
private async onPaymentFailed(invoice: Stripe.Invoice) {
|
||||
const storeId = await this.storeIdForCustomer(String(invoice.customer));
|
||||
if (storeId) await this.suspend(storeId, `paiement de ${euros(invoice.amount_due)} refusé`);
|
||||
}
|
||||
|
||||
/** Seuls les magasins actifs sont suspendus ; un brouillon ou un magasin fermé reste tel quel. */
|
||||
private async suspend(storeId: string, reason: string) {
|
||||
const { count } = await this.prisma.store.updateMany({
|
||||
where: { id: storeId, status: 'ACTIVE' },
|
||||
data: { status: 'SUSPENDED', billingSuspended: true },
|
||||
});
|
||||
if (count) this.logger.warn(`Magasin ${storeId} suspendu : ${reason}`);
|
||||
}
|
||||
|
||||
/** Ne réactive que ce que la facturation a suspendu (pas une suspension manuelle). */
|
||||
private async reactivate(storeId: string) {
|
||||
const { count } = await this.prisma.store.updateMany({
|
||||
where: { id: storeId, status: 'SUSPENDED', billingSuspended: true },
|
||||
data: { status: 'ACTIVE', billingSuspended: false },
|
||||
});
|
||||
if (count) this.logger.log(`Magasin ${storeId} réactivé après paiement`);
|
||||
}
|
||||
|
||||
private async storeIdForCustomer(customerId: string) {
|
||||
const sub = await this.prisma.subscription.findUnique({ where: { stripeCustomerId: customerId }, select: { storeId: true } });
|
||||
return sub?.storeId ?? null;
|
||||
}
|
||||
|
||||
/** Émet la facture MonEspacePro (numéro suivant, PDF, e-mail). Idempotent. */
|
||||
private async onInvoicePaid(si: Stripe.Invoice) {
|
||||
if (!si.id || si.amount_paid <= 0) return;
|
||||
const storeId = await this.storeIdForCustomer(String(si.customer));
|
||||
if (!storeId) {
|
||||
this.logger.warn(`Facture Stripe ${si.id} : client ${si.customer} inconnu`);
|
||||
return;
|
||||
}
|
||||
await this.reactivate(storeId);
|
||||
if (await this.prisma.invoice.findUnique({ where: { stripeInvoiceId: si.id } })) return;
|
||||
|
||||
const store = await this.prisma.store.findUniqueOrThrow({ where: { id: storeId } });
|
||||
const period = si.lines.data[0]?.period;
|
||||
const paidAt = si.status_transitions?.paid_at ? new Date(si.status_transitions.paid_at * 1000) : new Date();
|
||||
|
||||
// Numérotation continue : séquence globale, l'unicité en base empêche tout doublon.
|
||||
let invoice: Prisma.InvoiceGetPayload<object> | null = null;
|
||||
for (let attempt = 0; attempt < 5 && !invoice; attempt++) {
|
||||
try {
|
||||
invoice = await this.prisma.$transaction(async (tx) => {
|
||||
const last = await tx.invoice.aggregate({ _max: { sequence: true } });
|
||||
const sequence = (last._max.sequence ?? 0) + 1;
|
||||
return tx.invoice.create({
|
||||
data: {
|
||||
number: `MEP-${paidAt.getFullYear()}-${String(sequence).padStart(6, '0')}`,
|
||||
sequence,
|
||||
storeId,
|
||||
stripeInvoiceId: si.id,
|
||||
amountCents: si.amount_paid,
|
||||
clientName: store.name,
|
||||
clientAddress: `${store.addressLine}\n${store.postalCode} ${store.city}`,
|
||||
clientSiret: store.siret.replace(/(\d{3})(\d{3})(\d{3})(\d{5})/, '$1 $2 $3 $4'),
|
||||
clientEmail: store.contactEmail,
|
||||
periodStart: period ? new Date(period.start * 1000) : paidAt,
|
||||
periodEnd: period ? new Date(period.end * 1000) : paidAt,
|
||||
paidAt,
|
||||
},
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
if (e instanceof Prisma.PrismaClientKnownRequestError && e.code === 'P2002') {
|
||||
// Même facture traitée en parallèle (webhook rejoué) : on s'arrête là.
|
||||
if (await this.prisma.invoice.findUnique({ where: { stripeInvoiceId: si.id } })) return;
|
||||
continue; // collision de numéro : on retente avec le suivant
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
if (!invoice) throw new Error(`Numérotation impossible pour ${si.id}`);
|
||||
|
||||
const pdf = await this.renderPdf(invoice.id);
|
||||
const text = `Bonjour ${store.contactName},\n\nVeuillez trouver ci-joint la facture ${invoice.number} de ${euros(invoice.amountCents)} pour l'abonnement MonEspacePro de ${store.name}. Elle a été réglée le ${paidAt.toLocaleDateString('fr-FR')}.\n\nMerci de votre confiance,\nMonEspacePro`;
|
||||
await this.mail
|
||||
.sendWithAttachment(store.contactEmail, `Votre facture MonEspacePro ${invoice.number}`, text, `<p>${escapeHtml(text).replace(/\n/g, '<br>')}</p>`, {
|
||||
filename: `${invoice.number}.pdf`,
|
||||
content: pdf,
|
||||
})
|
||||
.catch((e) => this.logger.error(`Facture ${invoice!.number} non envoyée : ${e.message}`));
|
||||
}
|
||||
|
||||
/** PDF généré une fois puis conservé tel quel (archive légale de 10 ans). */
|
||||
async renderPdf(invoiceId: string): Promise<Buffer> {
|
||||
const inv = await this.prisma.invoice.findUnique({ where: { id: invoiceId } });
|
||||
if (!inv) throw new NotFoundException('Facture introuvable');
|
||||
if (inv.pdfPath) {
|
||||
try {
|
||||
return await readFile(join(INVOICES_DIR, inv.pdfPath));
|
||||
} catch {
|
||||
/* fichier absent : on le régénère depuis les données figées */
|
||||
}
|
||||
}
|
||||
const pdf = await renderInvoicePdf({
|
||||
number: inv.number,
|
||||
issuedAt: inv.issuedAt,
|
||||
paidAt: inv.paidAt,
|
||||
periodStart: inv.periodStart,
|
||||
periodEnd: inv.periodEnd,
|
||||
amountCents: inv.amountCents,
|
||||
issuer: this.config.get('issuer')!,
|
||||
client: { name: inv.clientName, address: inv.clientAddress, siret: inv.clientSiret, email: inv.clientEmail },
|
||||
});
|
||||
await mkdir(INVOICES_DIR, { recursive: true });
|
||||
const file = `${inv.number}.pdf`;
|
||||
await writeFile(join(INVOICES_DIR, file), pdf);
|
||||
if (!inv.pdfPath) await this.prisma.invoice.update({ where: { id: inv.id }, data: { pdfPath: file } });
|
||||
return pdf;
|
||||
}
|
||||
|
||||
async invoiceNumber(invoiceId: string) {
|
||||
const inv = await this.prisma.invoice.findUnique({ where: { id: invoiceId }, select: { number: true } });
|
||||
if (!inv) throw new NotFoundException('Facture introuvable');
|
||||
return inv.number;
|
||||
}
|
||||
}
|
||||
123
backend/src/billing/invoice-pdf.ts
Normal file
123
backend/src/billing/invoice-pdf.ts
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
import PDFDocument from 'pdfkit';
|
||||
|
||||
export interface InvoicePdfData {
|
||||
number: string;
|
||||
issuedAt: Date;
|
||||
paidAt: Date | null;
|
||||
periodStart: Date;
|
||||
periodEnd: Date;
|
||||
amountCents: number;
|
||||
issuer: { name: string; tradeName: string; siret: string; address: string; email: string };
|
||||
client: { name: string; address: string; siret: string; email: string };
|
||||
}
|
||||
|
||||
const GREEN = '#0E7A66';
|
||||
const INK = '#1C1C19';
|
||||
const MUTED = '#5F5E56';
|
||||
|
||||
const date = (d: Date) => d.toLocaleDateString('fr-FR', { day: '2-digit', month: '2-digit', year: 'numeric', timeZone: 'Europe/Paris' });
|
||||
const euros = (cents: number) =>
|
||||
(cents / 100).toLocaleString('fr-FR', { minimumFractionDigits: 2, maximumFractionDigits: 2 }).replace(/ | /g, ' ') + ' €';
|
||||
const month = (d: Date) => d.toLocaleDateString('fr-FR', { month: 'long', year: 'numeric', timeZone: 'Europe/Paris' });
|
||||
|
||||
/**
|
||||
* Facture A4 conforme aux mentions obligatoires (art. L441-9 du Code de
|
||||
* commerce, art. 242 nonies A annexe II du CGI) pour une entreprise en
|
||||
* franchise en base de TVA.
|
||||
*/
|
||||
export function renderInvoicePdf(d: InvoicePdfData): Promise<Buffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const doc = new PDFDocument({ size: 'A4', margin: 56, info: { Title: `Facture ${d.number}`, Author: d.issuer.name } });
|
||||
const chunks: Buffer[] = [];
|
||||
doc.on('data', (c: Buffer) => chunks.push(c));
|
||||
doc.on('end', () => resolve(Buffer.concat(chunks)));
|
||||
doc.on('error', reject);
|
||||
|
||||
const left = 56;
|
||||
const right = doc.page.width - 56;
|
||||
const width = right - left;
|
||||
|
||||
// En-tête : symbole + émetteur
|
||||
doc.save().translate(left, 50).scale(0.5);
|
||||
doc.path('M12 54V32a9 9 0 0 1 18 0v22M30 32a9 9 0 0 1 18 0v22').lineWidth(8).strokeColor(GREEN).stroke();
|
||||
doc.circle(51, 12, 6).fillColor('#F2B544').fill();
|
||||
doc.restore();
|
||||
doc.fillColor(INK).font('Helvetica-Bold').fontSize(16).text(d.issuer.tradeName, left + 40, 58);
|
||||
doc.font('Helvetica').fontSize(9).fillColor(MUTED)
|
||||
.text(d.issuer.name, left, 96)
|
||||
.text(d.issuer.address)
|
||||
.text(`SIRET ${d.issuer.siret}`)
|
||||
.text(d.issuer.email);
|
||||
|
||||
// Titre facture
|
||||
doc.font('Helvetica-Bold').fontSize(22).fillColor(INK).text('FACTURE', left, 58, { width, align: 'right' });
|
||||
doc.font('Helvetica').fontSize(10).fillColor(MUTED)
|
||||
.text(`N° ${d.number}`, left, 88, { width, align: 'right' })
|
||||
.text(`Date d'émission : ${date(d.issuedAt)}`, { width, align: 'right' })
|
||||
.text(`Date de la prestation : ${date(d.periodStart)} au ${date(d.periodEnd)}`, { width, align: 'right' });
|
||||
|
||||
// Client
|
||||
const clientY = 180;
|
||||
doc.roundedRect(left + width / 2, clientY, width / 2, 92, 8).fillColor('#F6F6F3').fill();
|
||||
doc.fillColor(MUTED).font('Helvetica-Bold').fontSize(8).text('FACTURÉ À', left + width / 2 + 14, clientY + 12);
|
||||
doc.fillColor(INK).font('Helvetica-Bold').fontSize(11).text(d.client.name, left + width / 2 + 14, clientY + 26, { width: width / 2 - 28 });
|
||||
doc.font('Helvetica').fontSize(9).fillColor(INK)
|
||||
.text(d.client.address, { width: width / 2 - 28 })
|
||||
.text(`SIRET ${d.client.siret}`)
|
||||
.text(d.client.email);
|
||||
|
||||
// Tableau
|
||||
let y = 310;
|
||||
doc.rect(left, y, width, 24).fillColor(GREEN).fill();
|
||||
doc.fillColor('#FFFFFF').font('Helvetica-Bold').fontSize(9)
|
||||
.text('Désignation', left + 10, y + 8)
|
||||
.text('Qté', left + width - 230, y + 8, { width: 40, align: 'right' })
|
||||
.text('Prix unitaire HT', left + width - 180, y + 8, { width: 90, align: 'right' })
|
||||
.text('Total HT', left + width - 90, y + 8, { width: 80, align: 'right' });
|
||||
y += 34;
|
||||
doc.fillColor(INK).font('Helvetica').fontSize(10)
|
||||
.text(`Abonnement MonEspacePro — carte de fidélité dématérialisée, 1 magasin\nPériode : ${month(d.periodStart)} (du ${date(d.periodStart)} au ${date(d.periodEnd)})`, left + 10, y, { width: width - 250 })
|
||||
.text('1', left + width - 230, y, { width: 40, align: 'right' })
|
||||
.text(euros(d.amountCents), left + width - 180, y, { width: 90, align: 'right' })
|
||||
.text(euros(d.amountCents), left + width - 90, y, { width: 80, align: 'right' });
|
||||
y += 44;
|
||||
doc.moveTo(left, y).lineTo(right, y).lineWidth(0.5).strokeColor('#DEDDD6').stroke();
|
||||
|
||||
// Totaux
|
||||
y += 14;
|
||||
const line = (label: string, value: string, bold = false) => {
|
||||
doc.font(bold ? 'Helvetica-Bold' : 'Helvetica').fontSize(bold ? 12 : 10).fillColor(INK)
|
||||
.text(label, left + width - 260, y, { width: 160, align: 'right' })
|
||||
.text(value, left + width - 90, y, { width: 80, align: 'right' });
|
||||
y += bold ? 22 : 18;
|
||||
};
|
||||
line('Total HT', euros(d.amountCents));
|
||||
line('TVA', '0,00 €');
|
||||
line('Total TTC', euros(d.amountCents), true);
|
||||
doc.font('Helvetica-Oblique').fontSize(9).fillColor(MUTED).text('TVA non applicable, art. 293 B du CGI', left, y + 4, { width, align: 'right' });
|
||||
|
||||
// Règlement
|
||||
y += 40;
|
||||
doc.font('Helvetica-Bold').fontSize(10).fillColor(INK).text('Règlement', left, y);
|
||||
doc.font('Helvetica').fontSize(9).fillColor(INK).text(
|
||||
d.paidAt
|
||||
? `Payée le ${date(d.paidAt)} par prélèvement automatique (Stripe).`
|
||||
: 'Paiement par prélèvement automatique à réception de la facture.',
|
||||
left, y + 16, { width },
|
||||
);
|
||||
|
||||
// Mentions légales
|
||||
const legalY = doc.page.height - 56 - 92;
|
||||
doc.moveTo(left, legalY - 12).lineTo(right, legalY - 12).lineWidth(0.5).strokeColor('#DEDDD6').stroke();
|
||||
doc.font('Helvetica').fontSize(7.5).fillColor(MUTED).text(
|
||||
[
|
||||
"Conditions de paiement : paiement à réception, par prélèvement automatique mensuel. Pas d'escompte en cas de paiement anticipé.",
|
||||
"En cas de retard de paiement, des pénalités sont exigibles au taux d'intérêt appliqué par la Banque centrale européenne à son opération de refinancement la plus récente majoré de 10 points (art. L441-10 du Code de commerce), ainsi qu'une indemnité forfaitaire pour frais de recouvrement de 40 € (art. D441-5 du Code de commerce).",
|
||||
`${d.issuer.name} — Entrepreneur individuel — SIRET ${d.issuer.siret} — TVA non applicable, art. 293 B du CGI.`,
|
||||
].join('\n'),
|
||||
left, legalY, { width, lineGap: 2 },
|
||||
);
|
||||
|
||||
doc.end();
|
||||
});
|
||||
}
|
||||
|
|
@ -26,6 +26,19 @@ export default () => ({
|
|||
/** Chemin vers la clé JSON du compte de service. */
|
||||
serviceAccountFile: process.env.GOOGLE_WALLET_SA_FILE ?? '',
|
||||
},
|
||||
stripe: {
|
||||
secretKey: process.env.STRIPE_SECRET_KEY ?? '',
|
||||
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET ?? '',
|
||||
priceLookupKey: process.env.STRIPE_PRICE_LOOKUP_KEY || 'mep_magasin_mensuel',
|
||||
},
|
||||
/** Émetteur des factures (mentions obligatoires). */
|
||||
issuer: {
|
||||
name: process.env.ISSUER_NAME || 'EI Tony Averty',
|
||||
tradeName: 'MonEspacePro',
|
||||
siret: process.env.ISSUER_SIRET || '100 142 819 00018',
|
||||
address: process.env.ISSUER_ADDRESS || '[ADRESSE DE L’ENTREPRISE]',
|
||||
email: process.env.ISSUER_EMAIL || 'contact@monespacepro.eu',
|
||||
},
|
||||
mail: {
|
||||
host: process.env.SMTP_HOST ?? '',
|
||||
port: parseInt(process.env.SMTP_PORT ?? '587', 10),
|
||||
|
|
|
|||
|
|
@ -32,6 +32,20 @@ export class MailService {
|
|||
}
|
||||
await this.transport.sendMail({ from: this.from, to, subject, text, html, ...(replyTo && { replyTo }) });
|
||||
}
|
||||
|
||||
async sendWithAttachment(
|
||||
to: string,
|
||||
subject: string,
|
||||
text: string,
|
||||
html: string,
|
||||
attachment: { filename: string; content: Buffer },
|
||||
) {
|
||||
if (!this.transport) {
|
||||
this.logger.warn(`SMTP non configuré — e-mail à ${to} : « ${subject} » + pièce jointe ${attachment.filename}`);
|
||||
return;
|
||||
}
|
||||
await this.transport.sendMail({ from: this.from, to, subject, text, html, attachments: [attachment] });
|
||||
}
|
||||
}
|
||||
|
||||
@Global()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ function verifierSecrets(config: ConfigService) {
|
|||
}
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||
// rawBody : la signature des webhooks Stripe porte sur les octets exacts du corps.
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule, { rawBody: true });
|
||||
const config = app.get(ConfigService);
|
||||
verifierSecrets(config);
|
||||
|
||||
|
|
|
|||
|
|
@ -211,4 +211,27 @@ for (const file of Object.keys(PAGES)) {
|
|||
fs.writeFileSync(out, page(file, title, transform(file, extractBody(html)), cookie));
|
||||
console.log('✓', PAGES[file].url);
|
||||
}
|
||||
// Page de retour après paiement Stripe : gabarit de la 404, contenu propre.
|
||||
{
|
||||
const html = read('Erreur404.dc.html');
|
||||
let body = transform('Erreur404.dc.html', extractBody(html));
|
||||
body = body.replace(
|
||||
/<section class="sec"[\s\S]*?<\/section>/,
|
||||
`<section class="sec" style="padding:96px 0 200px;text-align:center">
|
||||
<div class="w" style="display:flex;flex-direction:column;align-items:center;gap:20px">
|
||||
<div class="ic" style="width:96px;height:96px;border-radius:50%;margin:0"><svg class="ico l t" style="width:48px;height:48px"><use href="#i-check"/></svg></div>
|
||||
<p class="eb" style="margin:0">Abonnement</p>
|
||||
<h1 style="max-width:18ch">Merci, votre abonnement est activé.</h1>
|
||||
<p class="lead">Vous allez recevoir la confirmation et votre première facture par e-mail. Votre carte de fidélité est prête à accueillir vos clients.</p>
|
||||
<div class="btnrow" style="justify-content:center;margin-top:12px"><a href="/" class="btn">Retour à l’accueil</a><a href="/contact/" class="btn2">Une question ?</a></div>
|
||||
</div>
|
||||
</section>`,
|
||||
);
|
||||
PAGES['Merci'] = { out: 'abonnement/merci/index.html', url: '/abonnement/merci/' };
|
||||
DESCRIPTIONS['Merci'] = 'Votre abonnement MonEspacePro est activé.';
|
||||
const out = path.join(OUT, PAGES['Merci'].out);
|
||||
fs.mkdirSync(path.dirname(out), { recursive: true });
|
||||
fs.writeFileSync(out, page('Merci', 'Abonnement activé — MonEspacePro', body, cookie).replace('<meta name="description"', '<meta name="robots" content="noindex">\n<meta name="description"'));
|
||||
console.log('✓', PAGES['Merci'].url);
|
||||
}
|
||||
void main;
|
||||
|
|
|
|||
118
site/abonnement/merci/index.html
Normal file
118
site/abonnement/merci/index.html
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Abonnement activé — MonEspacePro</title>
|
||||
<meta name="robots" content="noindex">
|
||||
<meta name="description" content="Votre abonnement MonEspacePro est activé.">
|
||||
<link rel="canonical" href="https://monespacepro.eu/abonnement/merci/">
|
||||
<meta name="theme-color" content="#0E7A66">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:title" content="Abonnement activé — MonEspacePro">
|
||||
<meta property="og:description" content="Votre abonnement MonEspacePro est activé.">
|
||||
<meta property="og:url" content="https://monespacepro.eu/abonnement/merci/">
|
||||
<meta property="og:image" content="https://monespacepro.eu/assets/og.png">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<link rel="apple-touch-icon" href="/assets/apple-touch-icon.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/assets/site.css">
|
||||
<script src="/assets/site.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="mep">
|
||||
<a class="skip" href="#contenu">Aller au contenu</a>
|
||||
|
||||
|
||||
<svg width="0" height="0" style="position:absolute" aria-hidden="true">
|
||||
<defs>
|
||||
<symbol id="logo" viewBox="0 0 40 40"><path d="M5 33V21a7.5 7.5 0 0 1 15 0v12M20 33V21a7.5 7.5 0 0 1 15 0v12" fill="none" stroke="currentColor" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/><circle cx="33" cy="8" r="4" fill="#F2B544"/></symbol>
|
||||
<symbol id="qr" viewBox="0 0 25 25"><path fill="currentColor" fill-rule="evenodd" d="M0 0h7v7H0zM1 1v5h5V1zM2 2h3v3H2zM18 0h7v7h-7zM19 1v5h5V1zM20 2h3v3h-3zM0 18h7v7H0zM1 19v5h5v-5zM2 20h3v3H2zM9 0h2v2H9zM13 0h3v1h-3zM9 3h1v2H9zM11 4h3v2h-3zM15 3h2v2h-2zM8 8h2v2H8zM12 8h3v2h-3zM17 8h2v3h-2zM21 9h2v2h-2zM9 11h2v2H9zM13 11h2v2h-2zM0 9h2v2H0zM3 9h3v1H3zM1 12h2v2H1zM5 12h2v3H5zM9 14h3v2H9zM14 14h2v2h-2zM18 13h3v2h-3zM22 14h3v2h-3zM9 18h2v3H9zM12 19h3v2h-3zM16 18h2v2h-2zM19 17h2v3h-2zM22 18h3v2h-3zM13 22h2v3h-2zM17 22h3v2h-3zM21 22h4v3h-4zM9 23h3v2H9z"/></symbol>
|
||||
<symbol id="i-check" viewBox="0 0 24 24"><path d="M5 12.5l4.5 4.5L19 7.5"/></symbol>
|
||||
<symbol id="i-x" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6L6 18"/></symbol>
|
||||
<symbol id="i-scan" viewBox="0 0 24 24"><path d="M4 8V5a1 1 0 0 1 1-1h3M16 4h3a1 1 0 0 1 1 1v3M20 16v3a1 1 0 0 1-1 1h-3M8 20H5a1 1 0 0 1-1-1v-3M4 12h16"/></symbol>
|
||||
<symbol id="i-phone" viewBox="0 0 24 24"><rect x="7" y="2.5" width="10" height="19" rx="2.5"/><path d="M11 18.5h2"/></symbol>
|
||||
<symbol id="i-gift" viewBox="0 0 24 24"><rect x="3" y="9" width="18" height="5" rx="1"/><path d="M5 14v6h14v-6M12 9v11M12 9c-2 0-4-1-4-3s3-2 4 3zM12 9c2 0 4-1 4-3s-3-2-4 3z"/></symbol>
|
||||
<symbol id="i-sync" viewBox="0 0 24 24"><path d="M4 12a8 8 0 0 1 14-5.3L20 9M20 4v5h-5M20 12a8 8 0 0 1-14 5.3L4 15M4 20v-5h5"/></symbol>
|
||||
<symbol id="i-users" viewBox="0 0 24 24"><circle cx="9" cy="8" r="3.5"/><path d="M2.5 20a6.5 6.5 0 0 1 13 0M16 4.5a3.5 3.5 0 0 1 0 7M18 14a6 6 0 0 1 3.5 6"/></symbol>
|
||||
<symbol id="i-shield" viewBox="0 0 24 24"><path d="M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"/></symbol>
|
||||
<symbol id="i-printer" viewBox="0 0 24 24"><path d="M7 9V4h10v5M7 17H5a1 1 0 0 1-1-1v-5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v5a1 1 0 0 1-1 1h-2"/><rect x="7" y="14" width="10" height="6"/></symbol>
|
||||
<symbol id="i-clock" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></symbol>
|
||||
<symbol id="i-list" viewBox="0 0 24 24"><path d="M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01"/></symbol>
|
||||
<symbol id="i-mail" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/></symbol>
|
||||
<symbol id="i-globe" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3.5 3 14.5 0 18M12 3c-3 3.5-3 14.5 0 18"/></symbol>
|
||||
<symbol id="i-trash" viewBox="0 0 24 24"><path d="M5 7h14M10 7V4h4v3M7 7l1 13h8l1-13"/></symbol>
|
||||
<symbol id="i-menu" viewBox="0 0 24 24"><path d="M4 7h16M4 12h16M4 17h16"/></symbol>
|
||||
<symbol id="i-download" viewBox="0 0 24 24"><path d="M12 4v11M7.5 11l4.5 4.5 4.5-4.5M5 20h14"/></symbol>
|
||||
<symbol id="i-search" viewBox="0 0 24 24"><circle cx="11" cy="11" r="6.5"/><path d="M16 16l4.5 4.5"/></symbol>
|
||||
<symbol id="i-plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol>
|
||||
<symbol id="i-minus" viewBox="0 0 24 24"><path d="M5 12h14"/></symbol>
|
||||
<symbol id="i-alert" viewBox="0 0 24 24"><path d="M12 3.5l9.5 16.5h-19z"/><path d="M12 10v4.5M12 17.5h.01"/></symbol>
|
||||
<symbol id="i-lock" viewBox="0 0 24 24"><rect x="5" y="11" width="14" height="9" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/></symbol>
|
||||
<symbol id="i-bell" viewBox="0 0 24 24"><path d="M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15zM10 20.5h4"/></symbol>
|
||||
<symbol id="i-back" viewBox="0 0 24 24"><path d="M19 12H5M11 6l-6 6 6 6"/></symbol>
|
||||
<symbol id="i-chev" viewBox="0 0 24 24"><path d="M6 9l6 6 6-6"/></symbol>
|
||||
<symbol id="i-coin" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 6.5v11M9.5 9.5h4a1.8 1.8 0 0 1 0 3.6h-3a1.8 1.8 0 0 0 0 3.6h4.5"/></symbol>
|
||||
<symbol id="i-stamp" viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M8.5 12.5l2.5 2.5 4.5-5"/></symbol>
|
||||
<symbol id="i-drop" viewBox="0 0 24 24"><path d="M12 3c5 5 7 8 7 11a7 7 0 0 1-14 0c0-3 2-6 7-11z"/></symbol>
|
||||
<symbol id="i-card" viewBox="0 0 24 24"><rect x="3" y="6" width="18" height="12" rx="2.5"/><path d="M3 10.5h18"/></symbol>
|
||||
<symbol id="i-pin" viewBox="0 0 24 24"><path d="M12 21s7-5.5 7-11a7 7 0 0 0-14 0c0 5.5 7 11 7 11z"/><circle cx="12" cy="10" r="2.5"/></symbol>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
<header class="w">
|
||||
<div class="hd">
|
||||
<a href="/" class="logo" aria-label="MonEspacePro, accueil">
|
||||
<svg class="lg" width="38" height="38" aria-hidden="true"><use href="#logo"/></svg>
|
||||
<span>MonEspacePro</span>
|
||||
</a>
|
||||
<nav class="nav" aria-label="Navigation principale">
|
||||
<a href="/comment-ca-marche/" class="nl">Fonctionnement</a>
|
||||
<a href="/fonctionnalites/" class="nl">Fonctionnalités</a>
|
||||
<a href="/tarif/" class="nl">Tarif</a>
|
||||
<a href="/faq/" class="nl">FAQ</a>
|
||||
<a href="/contact/" class="btn sm">Demander une démo</a>
|
||||
</nav>
|
||||
<button class="menu" type="button" aria-label="Ouvrir le menu" aria-expanded="false" data-menu><svg class="ico"><use href="#i-menu"/></svg></button>
|
||||
</div>
|
||||
</header>
|
||||
<main id="contenu">
|
||||
|
||||
<section class="sec" style="padding:96px 0 200px;text-align:center">
|
||||
<div class="w" style="display:flex;flex-direction:column;align-items:center;gap:20px">
|
||||
<div class="ic" style="width:96px;height:96px;border-radius:50%;margin:0"><svg class="ico l t" style="width:48px;height:48px"><use href="#i-check"/></svg></div>
|
||||
<p class="eb" style="margin:0">Abonnement</p>
|
||||
<h1 style="max-width:18ch">Merci, votre abonnement est activé.</h1>
|
||||
<p class="lead">Vous allez recevoir la confirmation et votre première facture par e-mail. Votre carte de fidélité est prête à accueillir vos clients.</p>
|
||||
<div class="btnrow" style="justify-content:center;margin-top:12px"><a href="/" class="btn">Retour à l’accueil</a><a href="/contact/" class="btn2">Une question ?</a></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</main>
|
||||
<footer class="ft">
|
||||
<div class="w">
|
||||
<div class="fg">
|
||||
<div>
|
||||
<div class="logo" style="color:#F3F3EC"><svg width="38" height="38" style="color:#2FB596" aria-hidden="true"><use href="#logo"/></svg><span>MonEspacePro</span></div>
|
||||
<p style="margin-top:16px;color:#B3B3A8;max-width:34ch;font-size:16px">La carte de fidélité dématérialisée pour les commerces indépendants.</p>
|
||||
</div>
|
||||
<div class="fc"><b>Le service</b><a href="/comment-ca-marche/">Fonctionnement</a><a href="/fonctionnalites/">Fonctionnalités</a><a href="/tarif/">Tarif</a><a href="/faq/">FAQ</a></div>
|
||||
<div class="fc"><b>Contact et légal</b><a href="mailto:contact@monespacepro.eu">contact@monespacepro.eu</a><a href="/mentions-legales/">Mentions légales</a><a href="/confidentialite/">Confidentialité</a><a href="/cgv/">CGV</a></div>
|
||||
</div>
|
||||
<div class="fb"><span>© MonEspacePro — EI Tony Averty</span><span>TVA non applicable, art. 293 B du CGI</span></div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="cookie" hidden data-cookie role="region" aria-label="Information sur les cookies">
|
||||
<svg class="ico" style="color:var(--grt)"><use href="#i-shield"/></svg>
|
||||
<p style="flex:1">Ce site n’utilise que des cookies techniques, nécessaires à son fonctionnement. Rien à accepter. <a href="/confidentialite/">En savoir plus</a></p>
|
||||
<button type="button" data-cookie-close aria-label="Fermer l’information"><svg class="ico"><use href="#i-x"/></svg></button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue