Commerce

Plans, subscriptions and payments

Define plans, trials and coupons in the developer console, sell them from your app with one call, check entitlements on your server and follow your earnings. You choose how money is collected — the platform's payment path or your own payment methods.

Last updated: November 7, 2026 · Browser SDK 1.6.0 · Bridge protocol 1.2

Two payment paths#

Platform payment gateways and the wallet are not live yet. Each app picks one path in the developer console (Monetization):

Platform pathExternal path
Who collectsThe platform (Billing Hub)You, with your own gateway, wallet or bank account
AvailableNow with manual payments the platform approves; gateways laterNow
Purchase UIThe host's plan sheet, end to endThe host's plan sheet, then a disclosure, then your checkout page
Plans and couponsDefined in the console, applied by the platformDefined in the console for display and entitlements, applied by you (optionally priced with quote)
EntitlementsComputed by the platformComputed from your reports, or kept by you if you do not report
«My subscriptions» in the appFull: renew, cancel, change, receiptsReported subscriptions show «Managed by the developer» and open your manageUrl
Refunds and disputesThrough the platformEntirely yours, under your published policy
Earnings windowAudited (ledger) with payouts«Reported» figures, no payouts (the money is already yours)
Platform feePer 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 (user or business), machine entitlements ({"products.max": 500, "export.pdf": true, "support": "priority"}) and one or more prices (month, quarter, year, custom days, or once) 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 routePurpose
GET /v1/partner/billing/entitlements?sub= or ?businessId=entitlements (+ a short-lived signed token)
POST /v1/partner/billing/external-purchasesreport an external purchase/change
POST /v1/partner/billing/quoteprice after a coupon
GET /v1/partner/billing/subscriptionsyour 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.