Skip to content

feat: PDF receipts, Stellar fee estimation, and i18n notifications#1036

Merged
Haroldwonder merged 2 commits into
Haroldwonder:mainfrom
Idaonoli:feature/issues-948-949-950
Jun 30, 2026
Merged

feat: PDF receipts, Stellar fee estimation, and i18n notifications#1036
Haroldwonder merged 2 commits into
Haroldwonder:mainfrom
Idaonoli:feature/issues-948-949-950

Conversation

@Idaonoli

@Idaonoli Idaonoli commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements three related enhancements from the Stellar Wave milestone:

  • Add transaction receipt PDF generation API endpoint #948GET /api/remittances/:id/receipt returns a branded PDF receipt for any remittance. Authentication is required via X-API-Key (admin) or X-Sender-Address (must match the remittance owner).
  • Add Stellar network fee (XLM) estimation and top-up guidance #949GET /api/accounts/:address/stellar-fees returns the current Horizon base fee, the account's native XLM balance, and the estimated XLM cost for N operations. Includes a low_balance flag and top_up_link when balance is below 2 XLM. An estimateStellarFee(operationCount) helper is added to the SDK. The frontend gains a checkXlmBalance() utility that calls the endpoint and renders a red warning banner when XLM is low.
  • Add multi-language support for email and SMS notifications #950 — Notification templates are extracted into per-locale files (en, es, fr, pt) covering all five event types: remittance_created, remittance_completed, remittance_failed, kyc_approved, kyc_expired. A preferred_language column is added to notification_preferences (with migration). The notification service loads the correct locale template and falls back to English when a translation is missing. A CI-friendly script (check-notification-templates.ts) exits 1 if any locale is missing any key.

Changes

Area File(s) Change
API api/src/routes/remittances.ts Added GET /:id/receipt endpoint
API api/src/services/receiptGenerator.ts New — PDFKit-based receipt generator
API api/src/routes/accounts.ts New — Stellar fee + XLM balance endpoint
API api/src/app.ts Registered /api/accounts router
API api/package.json Added pdfkit + @types/pdfkit dependencies
Backend backend/src/notification-service.ts i18n template lookup, preferred_language in preferences, notifyKycEvent()
Backend backend/src/notification-templates/ New — types.ts, index.ts, en.ts, es.ts, fr.ts, pt.ts
Backend backend/migrations/ Migration to add preferred_language column
Backend backend/scripts/check-notification-templates.ts New — CI completeness check
SDK sdk/src/index.ts Added estimateStellarFee() helper
Frontend frontend/src/main.ts Added checkXlmBalance() and low-XLM banner

Notes

  • Run npm install in api/ after merging to pick up pdfkit.
  • Run npm run migrate in backend/ to apply the preferred_language column migration.
  • Add tsx backend/scripts/check-notification-templates.ts to CI to enforce template completeness.
  • The PDF receipt endpoint requires ADMIN_API_KEY to be set in the environment for admin access. Sender-based auth uses the X-Sender-Address header matched against remittance.sender_id.
  • STELLAR_EXPLORER_URL can be set to override the default on-chain explorer base URL in receipts.

Test plan

  • GET /api/remittances/:id/receipt with a valid X-API-Key returns a PDF (Content-Type: application/pdf)
  • Same endpoint with a mismatched X-Sender-Address returns 403
  • Same endpoint with no auth headers returns 401
  • GET /api/accounts/G.../stellar-fees returns base_fee_stroops, xlm_balance, estimated_fee_xlm
  • Response includes low_balance: true and top_up_link when XLM balance < 2
  • estimateStellarFee(2) returns 0.00002 (2 × 100 stroops / 10 000 000)
  • Sending a notification to a user with preferred_language = 'pt' delivers Portuguese text
  • Missing translation falls back to English without throwing
  • check-notification-templates.ts exits 0 with all templates present; exits 1 if a key is removed

closes #948
closes #949
closes #950

…aroldwonder#948, Haroldwonder#949, Haroldwonder#950)

Closes Haroldwonder#948 — Add transaction receipt PDF generation API endpoint
Closes Haroldwonder#949 — Add Stellar network fee (XLM) estimation and top-up guidance
Closes Haroldwonder#950 — Add multi-language support for email and SMS notifications
@vercel

vercel Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Idaonoli is attempting to deploy a commit to the Harold's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@Idaonoli Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Haroldwonder Haroldwonder merged commit 5eadc55 into Haroldwonder:main Jun 30, 2026
5 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants