Two payment paths#
Platform payment gateways and the wallet are not live yet. Each app picks one path in the developer console (Monetization):
| Platform path | External path | |
|---|---|---|
| Who collects | The platform (Billing Hub) | You, with your own gateway, wallet or bank account |
| Available | Now with manual payments the platform approves; gateways later | Now |
| Purchase UI | The host's plan sheet, end to end | The host's plan sheet, then a disclosure, then your checkout page |
| Plans and coupons | Defined in the console, applied by the platform | Defined in the console for display and entitlements, applied by you (optionally priced with quote) |
| Entitlements | Computed by the platform | Computed from your reports, or kept by you if you do not report |
| «My subscriptions» in the app | Full: renew, cancel, change, receipts | Reported subscriptions show «Managed by the developer» and open your manageUrl |
| Refunds and disputes | Through the platform | Entirely yours, under your published policy |
| Earnings window | Audited (ledger) with payouts | «Reported» figures, no payouts (the money is already yours) |
| Platform fee | Per seller (currently 0) | None today |
Monetization settings (developer console):
{
"pricing": { "model": "free" | "paid" | "freemium" | "trial", "trialDays": 14, "requiredEntitlement": "access" },
"payments": { "mode": "platform" | "external", "externalDomains": ["pay.example.iq"],
"checkoutPath": "/checkout", "manageUrl": "/account/subscription", "reportsToPlatform": true }
}
Rules for the external path: declare your pricing model (the app page then shows «Paid» or «In-app purchases»), list every payment domain (the host never opens a payment page elsewhere), start payments with purchase() or openExternalPayment() so the host shows its disclosure, publish a refund policy and a support channel, and never collect card data inside your own pages.
Plans, prices, entitlements, coupons#
- A plan has localized name, description and feature bullets, an audience (
userorbusiness), machine entitlements ({"products.max": 500, "export.pdf": true, "support": "priority"}) and one or more prices (month,quarter,year, customdays, oronce) with optional trial days. - Coupons: percent, fixed amount, extra trial days or free months; once, N cycles or forever; plan scope, total and per-subscriber limits, dates, new subscribers only.
- One trial per subscriber per app (checked by user, business and phone).
Selling from your page#
import { SalophaMiniApp } from "@salopha/mini-app-sdk"; // 1.4.0
const app = new SalophaMiniApp();
const ent = await app.getEntitlements(); // { plan, status, entitlements, validUntil }
if (!ent.entitlements["export.pdf"]) {
const r = await app.purchase({ planId: "pro" }); // host plan sheet
// r.status: "purchased" | "trialing" | "pending" | "cancelled"
}
app.on("entitlementsChanged", () => location.reload());
await app.manageSubscription(); // the host's «my subscriptions» for your app
In the external path purchase() shows your plans and the disclosure, then opens checkoutPath?planId=&priceId=&coupon= inside your app and resolves pending. To open a payment page directly use openExternalPayment({ url }) (https, host listed in externalDomains, otherwise forbidden).
The page never receives tokens. Always confirm on your server.
On your server#
import { PlatformClient } from "@salopha/mini-app-server-sdk"; // 1.4.0
const ent = await platform.entitlements({ sub }); // or { businessId }
await platform.reportExternalPurchase({ // external path, after your gateway confirms
externalReference: payment.id, event: "purchased", planId: "pro", subscriber: { sub },
periodStart: "2026-11-06T00:00:00Z", periodEnd: "2026-12-06T00:00:00Z",
amountMinor: 10000, currency: "IQD", paymentMethodLabel: "ZainCash",
});
const q = await platform.quote({ priceId: "price_pro_month", couponCode: "RAMADAN30", subscriber: { sub } });
Report every change: purchased, renewed, plan_changed, canceled, refunded, expired. Reports are idempotent (duplicate on a resend). An external subscription stays active until the reported periodEnd plus a 24-hour grace for late renewals.
| Partner route | Purpose |
|---|---|
GET /v1/partner/billing/entitlements?sub= or ?businessId= | entitlements (+ a short-lived signed token) |
POST /v1/partner/billing/external-purchases | report an external purchase/change |
POST /v1/partner/billing/quote | price after a coupon |
GET /v1/partner/billing/subscriptions | your subscriptions |
Webhooks (signed like every platform → partner call): platform.subscription.created|trial_started|renewed|past_due|canceled|expired|plan_changed.v1, platform.entitlements.changed.v1.
Earnings window#
The developer console shows two separate sections: Through the platform (from the ledger, reconciled, pending vs available balance, payouts and monthly statements) and Reported external payments (from your reports, clearly labelled). KPIs: MRR, active and trialing subscriptions, new and canceled, trial conversion, revenue by plan, CSV export.