Skip to content

Digital products

import {
Billing,
DownloadEmails,
Downloads,
Offer,
Purchase,
} from "@byfungsi/sapa";
import { Effect } from "effect";
export const ebook = Effect.gen(function* () {
const download = yield* Downloads.download({
asset: { key: "ebook.effect.pdf", revision: 1 },
duration: "perpetual",
});
const email = yield* DownloadEmails.customer({
asset: { key: "ebook.effect.pdf", revision: 1 },
});
const purchase = yield* Purchase.parse({
key: "ebook.effect.benefits",
revision: 1,
provides: [download, email],
});
const billing = yield* Billing.oneTime({
price: { currency: "IDR", amount: 99_000n },
});
return yield* Offer.parse({
key: "ebook.effect",
revision: 1,
purchase,
billing,
});
});

Install the exact asset revision before registering the offer. Settlement makes the customer eligible; download authorization produces a short-lived URL.

import { Access, Fulfillment } from "@byfungsi/sapa";
export const course = Effect.gen(function* () {
const access = yield* Access.entitlements({
entitlements: ["course.effect.use"],
duration: "perpetual",
});
const delivery = yield* Fulfillment.external({
binding: { key: "course.effect.delivery", revision: 1 },
entitlement: "course.effect.use",
});
const purchase = yield* Purchase.parse({
key: "course.effect.enrollment",
revision: 1,
provides: [access, delivery],
});
const billing = yield* Billing.oneTime({
price: { currency: "IDR", amount: 499_000n },
});
return yield* Offer.parse({
key: "course.effect",
revision: 1,
purchase,
billing,
});
});

Settlement retains a fulfillment obligation. A worker executes the exact installed binding with a stable execution identity. Replay and history rebuild must not execute delivery again. Refund processing can retain a reversal obligation rather than deleting the original successful delivery.