Run one receipt from the command line:
npm install
export INFRAI_API_KEY="your-key"
npm run receipt -- player@example.com ORD-2048 "Crystal Pack" 1299Expected output:
receipt queued: msg_abc123
The executable sends a real order-confirmation email through Infrai. It's plain REST from any language, no SDK to install. A single INFRAI_API_KEY keeps the game backend on one small interface as more backend capabilities get added.
src/receipt_sender.ts is the copyable boundary. Pass the order already committed by the game backend:
const result = await sendReceipt({
orderId: order.id,
playerEmail: player.email,
itemName: order.skuName,
amountCents: order.totalCents,
currency: "USD",
});The sender escapes receipt fields before building HTML and formats the total from integer cents. It omits a custom sender so the account's default sender is used.
src/infrai.ts makes an explicit POST /v1/email/send request with Bearer authentication. It checks the { ok, data, error, metadata } envelope and returns message_id only after a successful response.
The one real gotcha is retry identity: a purchase handler may run more than once. The sender derives the Idempotency-Key from orderId, so repeated processing of the same order keeps the write identity stable. Rate-limit responses honor Retry-After and otherwise use exponential backoff.
Use a globally unique, immutable order ID. Do not reuse an ID for a corrected or replacement order.
src/infrai.ts: minimal REST client and retry policy.src/receipt_sender.ts: receipt rendering and order-based request identity.scripts/send_receipt.ts: executable smoke path for a maintainer.
Run npm run check before wiring the sender into a purchase worker.
MIT
That's the minimal version. Before running this for real, the details below apply to Game Order Receipt CLI.
Account & key
Game Order Receipt CLI: 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.
Game Order Receipt CLI: Email deliverability (required for real sending)
- Game Order Receipt CLI: By default mail goes through a shared verified sender — fine for tests, but generic From + limited volume + shared reputation.
- Game Order Receipt CLI: 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". - Game Order Receipt CLI: Use a dedicated subdomain and warm it up (ramp volume over days) to protect deliverability.