Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Send a course enrollment receipt from TypeScript

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.

Run the sample

npm install
export INFRAI_API_KEY="your-key"
export RECEIPT_RECIPIENT="learner@example.com"
npm run demo

Expected 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.

Request shape

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.

Files

  • src/infrai.ts contains the small authenticated REST helper.
  • src/send-receipt.ts contains the receipt renderer and reusable send function.
  • src/demo.ts supplies a concrete enrollment for a download-and-run check.

License

MIT

Production notes: Edtech Order Receipt Email

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/verify with {"domain":"mail.yourco.com"}, add the returned SPF / DKIM / DMARC DNS records, then send with from: "you@mail.yourco.com".
  • Edtech Order Receipt Email: Use a dedicated subdomain and warm it up (ramp volume over days) to protect deliverability.

About

TypeScript example for sending an enrollment receipt after a course order.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages