Skip to content

feat(docusign): implement embedded signing flow with parallel signatures, geolocation tracking, and PDF certificate generation

fatima senan a demandé de fusionner feature/VSN-2685 vers develop

This MR includes the full integration of DocuSign electronic signature into the report lifecycle, replacing the delegated email flow with an embedded signing approach where both parties sign directly (company from the BO interface, driver from the mobile app), with no dependency on DocuSign email delivery.

DocuSign Service (DocuSignServiceImpl)

  • JWT-based authentication with DocuSign API
  • Envelope creation with embedded signing for both company and driver signers
  • Parallel signing: both signers are set at routingOrder=1
  • getRecipientSigningUrl: generates an embedded signing URL for a given recipient
  • ensureEmbeddedSigner: two-pass lookup to safely identify a recipient by clientUserId first, then by email (avoids wrong-signer assignment)
  • saveSignatureLocation: persists signer geolocation at time of signing

DocuSign Webhook (DocuSignWebhookServiceImpl)

  • Handles recipient-completed events: updates report status to DRIVER_SIGNED or COMPANY_SIGNED based on the signer's role
  • Handles envelope-completed event: appends the signature certificate to the signed PDF, uploads the final document to S3, then sets status to COMPLETED (race condition fix: COMPLETED is only set after the final PDF is on S3)

Report Service (ReportServiceImpl)

  • Report is saved to DB before envelope creation to ensure a valid ID is available as clientUserId (fixes UNKNOWN_ENVELOPE_RECIPIENT error)
  • Driver signing email sent immediately at envelope creation
  • getReportUrl returns the final signed S3 key when available, falling back to the original key

Report Controller (ReportController)

  • New endpoints: GET /reports/{reportId}/company-signing-url, GET /reports/{reportId}/driver-signing-url
  • New endpoint: POST /reports/{reportId}/signature-location to save signer geolocation
  • ReportResponseDto extended with signature fields: signatureStatus, driverSigned, companySigned, driverSignerEmail, driverSignerName, companySigningUrl

Rapports de requête de fusion