Skip to content

Posten.no E-Signature Integration #303

@Starefossen

Description

@Starefossen

Summary

Integrate with Posten Signering for legally binding digital signatures via BankID.

Reference: https://signering.posten.no/priser

Implementation

src/lib/posten-signering/client.ts

  • OAuth2 enterprise authentication
  • createSigningTask(pdf, signerEmail, signerName) - upload PDF, create signing task
  • getTaskStatus(taskId) - poll for status
  • downloadSignedDocument(taskId) - retrieve signed PDF

tRPC Endpoints

  • crm.contract.sendToSigning - generate PDF, create Posten task, update status
  • crm.contract.checkStatus - manual status check

Webhook Handler

  • src/app/api/webhooks/posten-signering/route.ts
  • Receive signing events (completed, declined, expired)
  • Update signature_status and contract_status
  • Store signed PDF in Sanity
  • Trigger welcome email on completion

Environment Variables

  • POSTEN_SIGNERING_CLIENT_ID
  • POSTEN_SIGNERING_CLIENT_SECRET
  • POSTEN_SIGNERING_WEBHOOK_SECRET

Acceptance Criteria

  • PDF successfully uploaded to Posten.no
  • Sponsor receives BankID signing request
  • Webhook updates CRM status on signature
  • Signed PDF stored in Sanity

Dependencies

Part of

Epic: CRM Phase 2 - Sponsor Contract Signing & Automation

Related: #199

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions