LMS Payment System Integration Setup (Course Sales)
LMS monetization is not just a "Buy" button. Full payment system integration includes one-time purchases, subscriptions, coupons, installments, refunds, and correct transaction accounting.
Payment System Selection
| System | Regions | Features |
|---|---|---|
| Stripe | Worldwide | Best API, built-in subscriptions, Stripe Checkout |
| PayPal | Worldwide | Wide user trust, PayPal Express |
| YooKassa | Russia/CIS | Russian cards, RNKO, QR code |
| LiqPay | Ukraine | Privat24, widely known |
| Paddle | SaaS products | Merchant of Record, handles VAT |
For international LMS — Stripe as the base + regional gateways for specific markets.
Stripe: Basic Integration
// Backend: create Checkout Session
async function createCheckoutSession(userId, courseId, priceId, couponId = null) {
const user = await db.users.findByPk(userId);
const course = await db.courses.findByPk(courseId);
const session = await stripe.checkout.sessions.create({
customer_email: user.email,
client_reference_id: `${userId}:${courseId}`, // Link in webhook
line_items: [{
price: priceId, // Stripe Price ID
quantity: 1,
}],
discounts: couponId ? [{ coupon: couponId }] : [],
mode: 'payment', // Or 'subscription' for subscriptions
success_url: `${process.env.APP_URL}/courses/${courseId}?payment=success&session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${process.env.APP_URL}/courses/${courseId}?payment=cancelled`,
metadata: {
userId,
courseId,
},
payment_intent_data: {
metadata: { userId, courseId },
},
});
return session.url;
}
Webhook Handler
Don't rely on success_url for payment confirmation — users can fake it. Always use webhooks:
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), async (req, res) => {
const sig = req.headers['stripe-signature'];
let event;
try {
event = stripe.webhooks.constructEvent(req.body, sig, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
switch (event.type) {
case 'checkout.session.completed': {
const session = event.data.object;
if (session.payment_status === 'paid') {
const { userId, courseId } = session.metadata;
await enrollStudentAfterPayment(userId, courseId, session.id);
}
break;
}
case 'charge.refunded': {
await handleRefund(event.data.object);
break;
}
case 'customer.subscription.deleted': {
await revokeSubscriptionAccess(event.data.object.customer);
break;
}
}
res.json({ received: true });
});
Monetization Models
One-time Purchase — standard Stripe Payment. Student pays once, gets access forever (or for N months).
Subscription — Stripe Subscriptions. Access to all courses while subscription is active. On cancellation — revoke access via customer.subscription.deleted webhook.
Installments — multiple payments via Stripe payment_intent with installment_plan or manually via scheduled invoices.
Corporate Licenses — purchase N seats for a team. In DB: licenses table → license_seats → user bindings.
Promo Codes
// Create promo code
const coupon = await stripe.coupons.create({
name: 'SUMMER2026',
percent_off: 30, // Or amount_off in kopecks
duration: 'once',
redeem_by: Math.floor(new Date('2026-09-01').getTime() / 1000),
max_redemptions: 500,
});
const promotionCode = await stripe.promotionCodes.create({
coupon: coupon.id,
code: 'SUMMER2026',
restrictions: {
first_time_transaction: false,
},
});
On the frontend — promo code input field with validation via Stripe API before checkout.
YooKassa for Russian Users
use YooKassa\Client;
$client = new Client();
$client->setAuth(SHOP_ID, SECRET_KEY);
$payment = $client->createPayment([
'amount' => ['value' => '3900.00', 'currency' => 'RUB'],
'capture' => true,
'confirmation' => [
'type' => 'redirect',
'return_url' => env('APP_URL') . '/payment/return',
],
'description' => "Course: {$course->title}",
'metadata' => ['user_id' => $userId, 'course_id' => $courseId],
], uniqid('', true));
return $payment->getConfirmation()->getConfirmationUrl();
Transaction Accounting
CREATE TABLE transactions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES users(id),
course_id UUID REFERENCES courses(id),
provider VARCHAR(50), -- 'stripe', 'yookassa', 'paypal'
provider_payment_id VARCHAR(200) UNIQUE,
amount NUMERIC(10,2),
currency VARCHAR(3),
status VARCHAR(50), -- 'pending', 'succeeded', 'failed', 'refunded'
coupon_code VARCHAR(100),
discount_amount NUMERIC(10,2) DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT NOW()
);
Timeframes
Stripe integration with one-time purchase, webhook, course enrollment, and promo codes — 4–5 days. Subscription model — additional 2–3 days. YooKassa — 2–3 days. Corporate licenses — 3–4 days.







