Skip to content

Build a creator payouts platform ​

This tutorial builds the payments side of Kazi Studio, an invented platform where brands pay for marketing campaigns and creators make the content. Brands pay Kazi Studio. When a brand approves a creator's work, Kazi Studio pays the creator's share into a Kazi Studio pocket in the creator's own MOOKHPay wallet, and the creator withdraws it to M-PESA whenever they like.

It is the second way to run a platform, described on Pay into your users' pockets. If each sale belongs to one seller and you only take a fee, the creator marketplace tutorial fits better.

By the end you have one Node file, server.mjs, that:

  • takes a brand's payment into Kazi Studio's own balance with a hosted checkout, and confirms it before trusting it
  • opens a MOOKHPay account for a creator, or asks one who already has MOOKHPay to link theirs
  • pays a creator's earnings into their pocket with a signed pay-in, in whole shillings, keeping cents until they add up
  • shows the creator their pocket, with what Kazi paid in and what they did themselves
  • lets the creator set a payout number with a one-time code and withdraw
  • handles signed webhooks, and runs a job every five minutes for anything a webhook missed
  • compares Kazi Studio's own balance with its books

It uses Node 18 or later and nothing outside Node's standard library. Download the whole file. Data is kept in memory so the payment code is easy to read; What to change for production lists what to replace.

Building it with an AI coding tool

Paste this page's address into the tool along with your own project, and ask it to follow the calls here in your project's language. Everything it needs is on this page and on Pay into your users' pockets. The hub's API Integrations page has a ready-made prompt for a platform like this one.

What you need ​

ThingWhere it comes from
An organisation switched on as a platform, with a pocket set upMOOKHPay staff. Agree your pocket's name and look, the text creators get when it opens, your daily pay-in cap (it starts at zero), your daily payout cap and your daily account limit. Pockets are available in Kenya
A secret key (mkp_…) with the scopes belowAn Owner, on Create A Key in the hub. Scopes can't be added to a key later
A payout signing secret (mps_…)An Owner, in the hub under API Integrations. It is shown once. It signs pay-ins, payouts and payout-number changes
A webhook endpoint and its secret (whsec_…)API Integrations, Webhooks, Add Endpoint, pointing at https://<your server>/hooks/mookhpay
ScopeUsed for
checkoutsTaking brands' payments
accounts:writeOpening creators' accounts
accounts:linkAsking creators who already use MOOKHPay to link their account
accounts:readPocket balances, movements and the fee quote
transfers:writePaying into pockets
payouts:writeWithdrawals and payout numbers
balance:readReading Kazi Studio's own balance, to reconcile

Subscribe the endpoint to payment.succeeded, payment.failed, account.linked, account.disconnected, payout.paid and payout.failed.

Set these environment variables:

sh
MOOKHPAY_API_BASE=https://payments-ke.mookhpay.co/v1/payments/merchant
MOOKHPAY_SECRET_KEY=mkp_live_…
MOOKHPAY_PAYOUT_SIGNING_SECRET=mps_…
MOOKHPAY_WEBHOOK_SECRET=whsec_…
PUBLIC_URL=https://kazi.example

There is no sandbox: staging moves real money too. Try it with small amounts.

How the money moves ​

Kazi Studio keeps its own books of what each brand paid and what each creator is owed. MOOKHPay holds the money. The brands' money stays in Kazi Studio's main balance until Kazi pays a creator; from that moment it is the creator's, in their pocket.

Call MOOKHPay ​

Every call goes through one function. It sends the secret key, and for the four calls that move money or change where it goes (pay-ins, payouts and the two payout-number calls) it signs the request with the payout signing secret.

js
class MookhPayError extends Error {
  constructor(status, body) {
    super(body?.description ?? `MOOKHPay answered ${status}`);
    this.status = status;
    this.code = body?.code;
    this.name = body?.data?.error ?? "MookhPayError";
    this.data = body?.data ?? {};
  }
}

// Every call: the secret key, JSON, and an Idempotency-Key on writes.
// signed: true adds X-Mookh-Timestamp and X-Mookh-Signature (pay-ins, payouts, payout numbers).
async function mookhpay(method, path, { body, idempotencyKey, signed = false } = {}) {
  const url = new URL(BASE + path);
  const raw = body === undefined ? "" : JSON.stringify(body);
  const headers = { Authorization: `Bearer ${KEY}` };
  if (body !== undefined) headers["Content-Type"] = "application/json";
  if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
  if (signed) {
    // Signed over the timestamp, the method, the path without its query, the
    // Idempotency-Key and the raw body. A signature is good once: this runs on every attempt.
    const timestamp = Math.floor(Date.now() / 1000).toString();
    const mac = createHmac("sha256", SIGNING_SECRET)
      .update(`${timestamp}.${method}.${url.pathname}.${idempotencyKey}.`)
      .update(raw);
    headers["X-Mookh-Timestamp"] = timestamp;
    headers["X-Mookh-Signature"] = `sha256=${mac.digest("hex")}`;
  }
  const res = await fetch(url, { method, headers, body: raw || undefined, signal: AbortSignal.timeout(20_000) });
  const answer = await res.json().catch(() => null);
  if (!res.ok || answer?.ok === false) throw new MookhPayError(res.status, answer);
  return { status: res.status, data: answer.data };
}

The signature is sha256= and the hex HMAC-SHA256, keyed on the signing secret, of the timestamp, the method, the request path without its query string (including /v1/payments/merchant), and the Idempotency-Key, each followed by a dot, then the raw body. Each signature is accepted once, so a retry is signed again with a new timestamp and the same Idempotency-Key and body. See How to sign a request.

Kazi Studio's records, in memory here:

js
// Replace these with your database. Every amount is in minor units (KES cents).
const campaigns = new Map(); // id -> { id, brand, amount, status: "unpaid"|"paid", checkoutId }
const creators = new Map(); // id -> { id, phone, firstName, lastName, accountId, linkId, wallet: null|"linking"|"connected"|"disconnected", owed }
const payIns = new Map(); // reference -> { reference, creatorId, amount, status: "processing"|"paid"|"failed", transferId }
const withdrawals = new Map(); // id -> { id, creatorId, amount, fee, status, payoutId }

1. A brand pays for a campaign ​

Open a hosted checkout without on_behalf_of, so the money lands in Kazi Studio's own balance. Send the brand to payUrl. When they come back, or when the webhook arrives, read the checkout back and mark the campaign paid only if it is completed with the right amount.

js
async function startCampaignPayment(campaign) {
  const { data } = await mookhpay("POST", "/checkouts", {
    // Same campaign and amount: same checkout. A changed amount opens a new one.
    idempotencyKey: `campaign-${campaign.id}-${campaign.amount}`,
    body: {
      amount: campaign.amount,
      reference: campaign.id,
      description: `Kazi Studio campaign for ${campaign.brand}`,
      return_url: `${PUBLIC_URL}/campaigns/${campaign.id}/paid`,
    },
  });
  campaign.checkoutId = data.id;
  return data.url;
}

// The only place a campaign is marked paid. Safe to run any number of times.
async function confirmCampaignPayment(campaign) {
  if (campaign.status === "paid" || !campaign.checkoutId) return campaign.status;
  const { data } = await mookhpay("GET", `/checkouts/${campaign.checkoutId}`);
  if (data.status === "completed" && Number(data.amount) === campaign.amount && data.currency === "KES") {
    campaign.status = "paid"; // the money is now in Kazi's main balance
  }
  return campaign.status;
}

The return address only tells you to look. Anybody can type it, so it never marks anything paid by itself.

2. Connect a creator's wallet ​

When a creator asks to be paid through MOOKHPay, show them MOOKHPay's terms and record when they accepted. Then open an account for them with POST /accounts. MOOKHPay opens the Kazi Studio pocket in their wallet moments later and texts them.

If their phone number already has MOOKHPay, that call answers 409 with code 2944 and creates nothing. Ask them to link their account instead with an account link: they approve it in MOOKHPay with their PIN, and you hear about it from the account.linked webhook. Ask for accounts:read and payouts:write.

js
async function connectWallet(creator, acceptedAt) {
  try {
    const { data } = await mookhpay("POST", "/accounts", {
      idempotencyKey: `creator-${creator.id}`,
      body: {
        phone: creator.phone,
        first_name: creator.firstName,
        last_name: creator.lastName,
        external_reference: creator.id,
        terms: { accepted_at: acceptedAt, version: TERMS_VERSION },
      },
    });
    creator.accountId = data.id;
    creator.wallet = "connected"; // the pocket may still be "opening"; pay-ins retry until it is ready
    await payInOwed(creator);
    return { connected: true };
  } catch (err) {
    if (err.code !== 2944) throw err; // PLATFORM_ACCOUNT_EXISTS: they already have MOOKHPay
  }
  // They already use MOOKHPay: ask them to link it, with their PIN, in MOOKHPay.
  const { data } = await mookhpay("POST", "/account-links", {
    idempotencyKey: `link-${creator.id}-${Date.now()}`,
    body: { phone: creator.phone, scopes: ["accounts:read", "payouts:write"] },
  });
  creator.linkId = data.id;
  creator.wallet = "linking";
  return { connected: false, approveUrl: data.url }; // show it once; never store it
}

async function linkApproved(creator, accountId) {
  creator.accountId = accountId;
  creator.wallet = "connected";
  creator.linkId = null;
  await payInOwed(creator);
}

3. Pay earnings into the pocket ​

When a brand approves a creator's work, add the creator's share to what Kazi owes them and pay it in with POST /accounts/:id/transfers. Pay-ins are in whole currency units, so the server pays whole shillings and keeps any cents owed until they add up.

js
// Called when a brand approves a creator's work: the creator is owed their share.
async function releaseEarnings(creator, amount) {
  creator.owed += amount;
  await payInOwed(creator);
}

// Pays whole shillings only (pay-ins are multiples of 100); cents stay owed until they add up.
async function payInOwed(creator) {
  if (creator.wallet !== "connected") return; // still owed, paid when they connect
  const amount = Math.floor(creator.owed / 100) * 100;
  if (amount === 0) return;
  const reference = `payin-${randomUUID()}`;
  creator.owed -= amount;
  const payIn = { reference, creatorId: creator.id, amount, status: "processing", transferId: null };
  payIns.set(reference, payIn);
  await sendPayIn(payIn);
}

// Sends (or re-sends) one pay-in. The reference is both the Idempotency-Key and
// external_reference, so a resend can never pay twice.
async function sendPayIn(payIn) {
  const creator = creators.get(payIn.creatorId);
  try {
    const { data } = await mookhpay("POST", `/accounts/${creator.accountId}/transfers`, {
      signed: true,
      idempotencyKey: payIn.reference,
      body: { amount: payIn.amount, external_reference: payIn.reference, remarks: "Kazi Studio earnings" },
    });
    payIn.transferId = data.transfer_id;
    if (data.status === "succeeded" && data.amount === payIn.amount) payIn.status = "paid";
  } catch (err) {
    // No answer, MOOKHPay busy (503), the daily cap reached (3062) or the pocket still
    // opening (3063): the key is still free. Leave it processing; the job resends it.
    const sameKeyLater = !err.status || err.status >= 500 || [3062, 3063].includes(err.code);
    if (sameKeyLater) return;
    // Refused for good, including 3060 (Kazi's balance is short), which closes this
    // pay-in and its reference. The money is owed again and goes out later under a new reference.
    payIn.status = "failed";
    creator.owed += payIn.amount;
    if (err.code === 3061) creator.wallet = "disconnected";
  }
}

Three things make this safe to run again and again:

  • The pay-in's reference is created once, stored, and used as both the Idempotency-Key and external_reference. Sending it again answers the same pay-in; it can never pay twice.
  • A pay-in that got no answer, or a refusal that leaves the key free (503 MOOKHPay busy, 3062 daily cap reached, 3063 pocket still opening), stays processing and is sent again with the same key by the job in step 6.
  • Any other refusal closes the pay-in and puts the amount back in what Kazi owes, to go out later under a new reference. That includes 3060, Kazi's main balance too low: the same key would only answer 3060 again. 3061 means the creator disconnected Kazi Studio: keep what they're owed until they connect again.

MOOKHPay tells the creator about every pay-in by SMS, email and push, naming Kazi Studio.

4. Show the creator their pocket ​

In pocket mode, GET /accounts/:id/balance and GET /accounts/:id/transactions see only the Kazi Studio pocket. Kazi lists its own pay-ins and withdrawals from its records, and adds from MOOKHPay only what the creator did themselves, so nothing shows twice. GET /fees gives the withdrawal fee, which is taken on top of the amount, so "withdraw all" is the balance minus the fee.

js
async function walletView(creator) {
  if (creator.wallet !== "connected") return { wallet: creator.wallet, owed: creator.owed };
  const [{ data: balance }, { data: moves }, { data: fees }] = await Promise.all([
    mookhpay("GET", `/accounts/${creator.accountId}/balance`),
    mookhpay("GET", `/accounts/${creator.accountId}/transactions?limit=20`),
    mookhpay("GET", "/fees"),
  ]);
  const fee = Number(fees.payout?.mpesa?.total ?? 0);
  const available = Number(balance.available);
  return {
    wallet: "connected",
    available,
    owed: creator.owed,
    canWithdraw: Math.max(0, available - fee), // the fee is taken on top, from the pocket
    // Kazi lists its own pay-ins and withdrawals; MOOKHPay's list adds what the creator did themselves.
    ownMoves: moves.movements.filter((m) => ["moved_in", "moved_out", "payment_out"].includes(m.type)),
    payIns: [...payIns.values()].filter((p) => p.creatorId === creator.id),
    withdrawals: [...withdrawals.values()].filter((w) => w.creatorId === creator.id),
  };
}

5. Withdraw ​

A withdrawal is a payout out of the pocket. It goes to the number the creator set for the pocket, else to their main payout account, else to their own phone. Setting a number is optional: MOOKHPay texts a six-digit code to it, the creator types it into Kazi Studio, and you pass it on.

js
// Optional: send withdrawals to another number. MOOKHPay texts a code to it.
async function startPayoutNumber(creator, phone) {
  const { data } = await mookhpay("POST", `/accounts/${creator.accountId}/payout-destination`, {
    signed: true,
    idempotencyKey: `dest-${creator.id}-${Date.now()}`,
    body: { rail: "mpesa", phone },
  });
  return data.verification_id;
}

async function verifyPayoutNumber(creator, verificationId, code) {
  const { data } = await mookhpay("POST", `/accounts/${creator.accountId}/payout-destination/verify`, {
    signed: true,
    idempotencyKey: `dest-${verificationId}-${code}`,
    body: { verification_id: verificationId, code },
  });
  return data.destination.phone_masked;
}

async function withdraw(creator, amount) {
  const id = `wd-${randomUUID()}`;
  const w = { id, creatorId: creator.id, amount, fee: null, status: "processing", payoutId: null };
  withdrawals.set(id, w);
  const { data } = await mookhpay("POST", `/accounts/${creator.accountId}/payouts`, {
    signed: true,
    idempotencyKey: id,
    body: { amount, remarks: "Kazi Studio withdrawal" },
  });
  w.payoutId = data.payout_id;
  w.fee = Number(data.fee); // the fee MOOKHPay charged is the one to keep
  settleWithdrawal(w, data.status);
  return w;
}

// paid and failed are final. A failed payout's money goes back to the pocket by itself.
function settleWithdrawal(w, status) {
  if (w.status !== "processing") return;
  if (status === "paid" || status === "failed") w.status = status;
}

A payout answers 202 and settles with the payout.paid or payout.failed webhook. Keep the fee it answers with: that is what was charged. A failed payout puts the money back in the pocket by itself, so Kazi records nothing more. A company account can't be paid out through a pocket (3037); its owners withdraw in MOOKHPay.

Webhooks ​

Verify every delivery before reading it: x-mookh-signature must be sha256= and the hex HMAC-SHA256, keyed on the webhook secret, of x-mookh-timestamp, a dot and the raw body. Refuse a timestamp more than five minutes old. Each event has an id (evt_…) that is the same on every retry, so remember the ones you've handled.

js
function verifyWebhook(headers, raw) {
  const timestamp = headers["x-mookh-timestamp"];
  const signature = headers["x-mookh-signature"] ?? "";
  if (!timestamp || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const expected = "sha256=" + createHmac("sha256", WEBHOOK_SECRET).update(`${timestamp}.`).update(raw).digest("hex");
  const a = Buffer.from(signature);
  const b = Buffer.from(expected);
  return a.length === b.length && timingSafeEqual(a, b);
}

const seenEvents = new Set(); // event ids already handled; in production, a table

async function handleEvent(event) {
  if (seenEvents.has(event.id)) return;
  switch (event.event) {
    case "payment.succeeded":
    case "payment.failed": {
      // A nudge, not a verdict: read the checkout back.
      const campaign = [...campaigns.values()].find((c) => c.checkoutId === event.checkout_id);
      if (campaign) await confirmCampaignPayment(campaign);
      break;
    }
    case "account.linked": {
      const creator = [...creators.values()].find((c) => c.linkId === event.data?.link_id);
      if (creator) await linkApproved(creator, event.account);
      break;
    }
    case "account.disconnected": {
      const creator = [...creators.values()].find((c) => c.accountId === event.account);
      if (creator) creator.wallet = "disconnected"; // keep what they're owed; pay when they reconnect
      break;
    }
    case "payout.paid":
    case "payout.failed": {
      const w = [...withdrawals.values()].find((x) => x.payoutId === event.payout_id);
      if (w) settleWithdrawal(w, event.event === "payout.paid" ? "paid" : "failed");
      break;
    }
  }
  seenEvents.add(event.id);
}

Answer 2xx quickly. Anything else, including a 500 because MOOKHPay couldn't be reached while you handled it, is retried. See Retries and ordering.

6. Catch what a webhook missed ​

Webhooks are at least once, in no fixed order, and sometimes late. A job every five minutes does what a missed webhook would have: resends pay-ins still processing with the same key, pays in what's owed, reads pending account links, reads withdrawals still on their way, and reads back unpaid campaigns.

js
async function everyFiveMinutes() {
  for (const p of payIns.values()) if (p.status === "processing") await sendPayIn(p).catch(() => {});
  for (const c of creators.values()) {
    if (c.wallet === "connected" && c.owed >= 100) await payInOwed(c).catch(() => {});
    if (c.wallet === "linking" && c.linkId) {
      const { data } = await mookhpay("GET", `/account-links/${c.linkId}`).catch(() => ({ data: null }));
      if (data?.status === "approved" && data.account) await linkApproved(c, data.account);
      if (data?.status === "expired") c.wallet = null; // ask them to connect again
    }
  }
  for (const w of withdrawals.values()) {
    if (w.status !== "processing" || !w.payoutId) continue;
    const creator = creators.get(w.creatorId);
    const { data } = await mookhpay("GET", `/accounts/${creator.accountId}/payouts/${w.payoutId}`).catch(() => ({ data: null }));
    if (data) settleWithdrawal(w, data.status);
  }
  for (const c of campaigns.values()) if (c.status === "unpaid") await confirmCampaignPayment(c).catch(() => {});
}

7. Reconcile ​

Kazi Studio's main balance should hold every brand payment not yet paid in, plus Kazi's own revenue. Once a night, compare it with Kazi's books using GET /balance. When they differ, list the day's movements with GET /balance/transactions and pair each with one of your records of the same direction and amount, nearest in time.

js
// What Kazi should hold: brands' money not yet paid in, plus Kazi's own revenue.
async function reconcile(expectedMinor) {
  const { data } = await mookhpay("GET", "/balance"); // needs balance:read
  const actual = Number(data.available);
  return { expected: expectedMinor, actual, difference: actual - expectedMinor, asOf: data.as_of };
}

The routes ​

The rest of server.mjs is a small HTTP server: Kazi Studio's own app calls these routes.

js
async function readBody(req) {
  const chunks = [];
  for await (const chunk of req) chunks.push(chunk);
  return Buffer.concat(chunks);
}

function send(res, status, body) {
  res.writeHead(status, { "Content-Type": "application/json" });
  res.end(JSON.stringify(body));
}

const routes = [
  ["POST", /^\/campaigns$/, async (req, res, _m, body) => {
    const campaign = { id: `cmp-${randomUUID()}`, brand: body.brand, amount: body.amount, status: "unpaid", checkoutId: null };
    campaigns.set(campaign.id, campaign);
    send(res, 201, { campaign, payUrl: await startCampaignPayment(campaign) });
  }],
  ["GET", /^\/campaigns\/([^/]+)\/paid$/, async (_req, res, m) => {
    const campaign = campaigns.get(m[1]);
    if (!campaign) return send(res, 404, { error: "no such campaign" });
    send(res, 200, { status: await confirmCampaignPayment(campaign) }); // never trust the query string
  }],
  ["POST", /^\/creators$/, async (req, res, _m, body) => {
    const creator = { id: `cr-${randomUUID()}`, phone: body.phone, firstName: body.firstName, lastName: body.lastName, accountId: null, linkId: null, wallet: null, owed: 0 };
    creators.set(creator.id, creator);
    send(res, 201, { creator });
  }],
  ["POST", /^\/creators\/([^/]+)\/wallet$/, async (_req, res, m, body) => {
    const creator = creators.get(m[1]);
    if (!body.acceptedTermsAt) return send(res, 400, { error: "accept MOOKHPay's terms first" });
    send(res, 200, await connectWallet(creator, body.acceptedTermsAt));
  }],
  ["POST", /^\/campaigns\/([^/]+)\/release$/, async (_req, res, m, body) => {
    const campaign = campaigns.get(m[1]);
    if (campaign?.status !== "paid") return send(res, 409, { error: "campaign is not paid" });
    await releaseEarnings(creators.get(body.creatorId), body.amount);
    send(res, 200, { ok: true });
  }],
  ["GET", /^\/creators\/([^/]+)\/wallet$/, async (_req, res, m) => send(res, 200, await walletView(creators.get(m[1])))],
  ["POST", /^\/creators\/([^/]+)\/payout-number$/, async (_req, res, m, body) =>
    send(res, 200, { verificationId: await startPayoutNumber(creators.get(m[1]), body.phone) })],
  ["POST", /^\/creators\/([^/]+)\/payout-number\/verify$/, async (_req, res, m, body) =>
    send(res, 200, { phone: await verifyPayoutNumber(creators.get(m[1]), body.verificationId, body.code) })],
  ["POST", /^\/creators\/([^/]+)\/withdraw$/, async (_req, res, m, body) =>
    send(res, 202, await withdraw(creators.get(m[1]), body.amount))],
];

createServer(async (req, res) => {
  try {
    const raw = await readBody(req);
    if (req.method === "POST" && req.url === "/hooks/mookhpay") {
      if (!verifyWebhook(req.headers, raw)) return send(res, 401, { error: "bad signature" });
      await handleEvent(JSON.parse(raw.toString("utf8")));
      return send(res, 200, { ok: true });
    }
    const path = new URL(req.url, "http://x").pathname;
    for (const [method, pattern, handler] of routes) {
      const m = req.method === method && path.match(pattern);
      if (m) return await handler(req, res, m, raw.length ? JSON.parse(raw.toString("utf8")) : {});
    }
    send(res, 404, { error: "not found" });
  } catch (err) {
    // A webhook that failed here answers 500, so MOOKHPay retries it.
    send(res, err instanceof MookhPayError && err.status < 500 ? 422 : 500, { error: err.name, code: err.code });
  }
}).listen(process.env.PORT ?? 3000);

setInterval(() => everyFiveMinutes().catch(console.error), 5 * 60 * 1000);
RouteDoes
POST /campaigns { brand, amount }Opens a checkout; answers payUrl
GET /campaigns/:id/paidThe checkout's return_url: confirms the payment
POST /creators { phone, firstName, lastName }A creator signs up with Kazi
POST /creators/:id/wallet { acceptedTermsAt }Connects their MOOKHPay wallet, or answers approveUrl for a link
POST /campaigns/:id/release { creatorId, amount }Work approved: pays the creator's share in
GET /creators/:id/walletThe creator's pocket, for their dashboard
POST /creators/:id/payout-number { phone } and …/verify { verificationId, code }Sets the number withdrawals go to
POST /creators/:id/withdraw { amount }A withdrawal
POST /hooks/mookhpayMOOKHPay's webhooks

Try it ​

  1. Start the server with the environment variables above, behind a public https address (a tunnel works) so webhooks reach it.
  2. POST /campaigns with a small amount, open payUrl and pay.
  3. POST /creators, then POST /creators/:id/wallet with the time the creator accepted the terms. Use a phone number that isn't on MOOKHPay yet to see an account opened, and one that is to see a link.
  4. POST /campaigns/:id/release for that creator. The creator gets a text, and the pocket shows the money in MOOKHPay.
  5. POST /creators/:id/withdraw.

What to change for production ​

  • Keep the records in a database, and take a row lock on a creator while you change what they're owed and record a pay-in, so two releases can't pay in the same money.
  • Store every pay-in before you send it, so a crash between the two is resent with the same reference by the job.
  • Show each creator MOOKHPay's terms yourself and keep your own record of their acceptance (the time and the version) alongside the one MOOKHPay keeps.
  • Ask for the creator's PIN, or your own step-up check, before connecting a wallet or withdrawing.
  • Log MOOKHPay's error names and ids, never the secret key, the signing secret, the webhook secret or an account link's url.
  • Ask MOOKHPay to limit your key to your servers' IP addresses.
  • Turn MOOKHPay's error codes into your own words for creators; see Errors.

Staging documentation. A checkout made with a secret key on staging charges a real phone. See Environments.