Storefront
Courses
Your course catalogue on your own site, and enrolling — free or paid.
TypeScript
const courses = await mercestack.courses.list({ q: "design" });
// [{ slug, title, subtitle, coverImageUrl, pricing: "free" | "paid", price, currency, lessonCount }]
const course = await mercestack.courses.get(courses[0].slug); // modules, lessons, instructor
const result = await mercestack.courses.enroll(course.slug, {
name: "Ada Lovelace",
email: "[email protected]",
});
if (result.status === "pending_payment") location.assign(result.paymentUrl);
else show("You're in — check your email for access.");- Free courses enrol at once and the student is emailed their access link.
- Paid courses answer with a
paymentUrlon the workspace's own payment page. The enrolment activates when the payment succeeds. - Enrolling twice is safe: an active student gets
{ status: "active", alreadyEnrolled: true }. - Lessons are watched in Mercestack's learning space, which the access email links to; video stays signed and streamed from there.