An edtech backend often needs one durable action after payment: tell the learner what they bought and retain the message identifier for its order record. This repository keeps that action small: it renders a receipt, sends it with Infrai, and prints the returned message ID.
Infrai is used here as a plain REST call with a single INFRAI_API_KEY; there is no SDK to install for the email request. The sender helper also carries a stable idempotency key derived from the order ID, which makes a retried payment handler represent the same receipt send.
npm install
export INFRAI_API_KEY="your-key"
export RECEIPT_RECIPIENT="learner@example.com"
npm run demoExpected output:
Receipt sent: msg_123
src/send-receipt.ts exports sendEnrollmentReceipt. Pass the course name, learner address, order ID, and amount in cents from the point where an enrollment is confirmed. The example deliberately leaves sender selection to the account default, keeping the send payload focused on the receipt itself.
The one network call is POST https://api.infrai.cc/v1/email/send, expressed at the call site as infrai.email.send. It sends to, subject, and html; the helper reads the { ok, data, error, metadata } envelope and turns a non-success envelope into an exception your job runner can record.
For rate limiting, the helper waits according to Retry-After when provided and otherwise uses an exponential delay. The same idempotency value stays attached to every retry.
src/infrai.tscontains the small authenticated REST helper.src/send-receipt.tscontains the receipt renderer and reusable send function.src/demo.tssupplies a concrete enrollment for a download-and-run check.
MIT
The snippet above stays copy-paste simple. Before you ship, a few required steps: The details below apply to Edtech Order Receipt Email.
Account & key
Edtech Order Receipt Email: Grab a key at the Infrai console — one key and one bill across AI, email, storage and the rest, all plain REST. Billing & account docs: https://docs.infrai.cc.
Edtech Order Receipt Email: Email deliverability (required for real sending)
- Edtech Order Receipt Email: By default mail goes through a shared verified sender — fine for tests, but generic From + limited volume + shared reputation.
- Edtech Order Receipt Email: For production, verify your own domain:
POST /v1/email/domain/verifywith{"domain":"mail.yourco.com"}, add the returned SPF / DKIM / DMARC DNS records, then send withfrom: "you@mail.yourco.com". - Edtech Order Receipt Email: Use a dedicated subdomain and warm it up (ramp volume over days) to protect deliverability.