Cas d’usage
Workflow de remboursement (avoir total / partiel + envoi)
Émettre, signer fiscalement, envoyer un avoir au client
Le workflow de remboursement Scell.io respecte la séquence légale française : (1) `POST /api/v1/invoices/{id}/credit-notes` pour émettre l'avoir (total ou partiel sur lignes), (2) immédiatement scellé fiscalement (immuable, conformité ISCA), (3) `POST /api/v1/invoices/{credit_note_id}/send` pour notifier le client par email avec PDF Factur-X attaché, (4) optionnellement, déclencher le remboursement bancaire via votre PSP (Stripe, Mangopay) avec le lien PDF de l'avoir comme justificatif. L'avoir n'efface JAMAIS la facture parent dans le registre fiscal — les deux coexistent. Webhook `credit_note.issued` notifie votre backend en temps réel.
À retenir
- Émission avoir → scellement fiscal immédiat
- Endpoint d'envoi email PDF Factur-X attaché
- Webhook `credit_note.issued`
- Avoir et facture coexistent (jamais d'écrasement)
- PSP refund (Stripe, Mangopay) découplé
- INTERDIT de delete avoir / facture (autocertification ISCA)
Exemple de code
import { ScellClient } from '@scell/sdk';
import Stripe from 'stripe';
const scell = new ScellClient({ apiKey: process.env.SCELL_SECRET_KEY! });
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
// 1. Émettre l'avoir total
const creditNote = await scell.invoices.createCreditNote('inv_42', {
reason: 'Annulation commande client',
});
// 2. Envoyer l'avoir au client
await scell.invoices.send(creditNote.id, {
to: 'client@example.com',
subject: `Avoir ${creditNote.number}`,
});
// 3. Rembourser via Stripe
await stripe.refunds.create({
payment_intent: 'pi_xxx',
amount: Math.round(creditNote.total_ttc * 100),
metadata: { scell_credit_note_id: creditNote.id, scell_pdf_url: creditNote.pdf_url },
});