Spec: PayPal, Cash App, Zelle, Polar, affiliates, and a creator program #1
Labels
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: RezinaLMS/RezinaLMS-CustomerEnd#1
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
For Yared
Add the ways a student outside Ethiopia can pay, and add two growth programs: affiliates (someone recommends a course and earns a cut) and a creator program (someone makes a course and earns a share). Do not invent a second way to unlock a course. Every provider must end in the order state machine already in SPEC §8.3.
The checkout screen already lists PayPal and Zelle as simulated methods (
packages/features/src/student.tsx). Cash App is new. Telebirr, CBE Birr, Visa and Mastercard stay on ArifPay. This work does not replace ArifPay.Rules that already exist — do not break them
From SPEC §8:
PaymentAdapterper provider (id,methods,createCheckout,verifyWebhook,queryStatus). Order and enrollment code must not know which provider ran.PENDING → PAIDand the enrollment insert happen in one transaction and are idempotent.queryStatus.flaggedReason, does not unlock, and alerts an admin.PAID: in-app notification, SMS, and an emailed receipt.REFUNDEDand must also reverse any affiliate commission and creator share for that order.The demo (
apps/demo) stays simulated. Real adapters belong inapps/api/src/payments/when that app exists. Until then, new methods on the demo checkout use the same Pay / Fail simulation as Telebirr, so the client can click through them.What each rail actually is
PayPal
PAYPAL. Method id staysPAYPAL./orders/{id}.PAYMENT.CAPTURE.COMPLETED), not on the return URL.providerRefas the PayPal order id.isTestcourse, then a refund, and never shows in student stats (SPEC §8.4).Cash App
CASHAPP. Method id:CASH_APP.Zelle
Zelle does not offer a checkout API we can call. Do not pretend a return URL or a screenshot is a verified webhook.
Manual flow:
PENDINGorder and shows a short reference, the amount, and the academy’s Zelle name (email or US phone). The reference is the only thing the student must put in the Zelle note.PAIDtransition as a webhook. Record who confirmed it and when.ZELLEand for Cash App when it is on the manual flow.Show copy that says a person confirms Zelle, so the student does not expect the course to open the second they hit send.
Polar
Polar does not require the academy to hold a payments or money-transmitter license. Polar is the legal seller (merchant of record): it charges the card, handles sales tax on that sale, and pays the academy out. What the academy still has to do, before the first payout:
Polar’s own rules, which this design must follow:
Provider id:
POLAR. One Polar product per course (or one product with the course id in metadata). Checkout session URL comes back fromcreateCheckout. Webhookorder.paid(confirm the event name against current Polar docs) is verified with the webhook secret, then runs the samePAIDtransition. Amount and currency must match. Refunds from Polar must move our order toREFUNDEDand reverse affiliate and creator balances for that order.Polar fees and the 7-day settlement delay (organizations created on or after 12 May 2026) are Polar’s, not something we reimplement. Do not unlock early and do not delay the unlock until the payout; the student gets the course when Polar says the order is paid.
Affiliates
A person recommends a course. If a new student buys through their link, they earn a percentage of that order.
SELAM) and a link/{locale}/course/{slug}?ref=SELAM.PAID, and only if the buyer is not the affiliate. No commission onisTestcourses.REFUNDEDreverses that commission. If it was already paid out, the affiliate balance may go negative and the next payout absorbs it.Creator program
A creator makes a course for the academy and earns a share of sales. The academy remains the seller.
APPLIED → APPROVEDorREJECTED.PAID, write a creator earning for that order:amount paid × share. OnREFUNDED, reverse it. No earning onisTestcourses. No earning when the buyer is the creator.Data to add
Keep names close to the existing order. Suggested records:
Affiliate— id, user id, code (unique), percent, status (ACTIVE | PAUSED), createdAt.ReferralClick— optional; only if we need to debug. The cookie plus the code on the order is enough for v1.Order.affiliateIdandOrder.creatorShareMinor/Order.affiliateCommissionMinorsnapshotted atPAID.Creator— id, user id, status (APPLIED | APPROVED | REJECTED), share percent, appliedAt.Course.creatorIdnullable. Empty means the academy owns it and nobody takes a share.Earning— id, payee (affiliate or creator), order id, minor amount, currency, status (PENDING | PAID | REVERSED), payout id.Payout— id, payee, amount, method, external reference, paidAt, staff user id.Order.methodalready a string. AddCASH_APP.providerbecomesARIFPAY | PAYPAL | CASHAPP | ZELLE | POLAR.Order.paymentReference,Order.confirmedBy,Order.confirmedAt.Admin
confirmedByinstead ofproviderRef).Acceptance checks
FAILEDorCANCELLED, course stays locked.PENDINGafter the student leaves checkout. Unlock happens only after staff confirm a matching reference and amount. A wrong amount does not unlock.REFUNDED.PAID. Buy as yourself with your own code → no commission. Refund → commission reversed.isTestpurchases create no affiliate or creator earnings and stay out of their dashboards.Open decisions (do not guess)
PENDING(suggestion: 48 hours).Out of scope