Docs

How to charge credits from a site or app.

Quickstart

  1. Sign in and register your company and site. The site can take payments immediately. Copy the API key (mbk_…) shown after registering; it is shown once. Keep it on your server.
  2. Add the client script to your page and call init with your hostname.
  3. Add data-mb-charge to any element that should start a charge.
  4. When the customer returns, verify the receipt code from your server.

Pay button

A click redirects to the pay sheet on micro.broker. The customer signs in if needed, confirms the charge (or is charged automatically if they allowed it for your site), and returns with a receipt code. The return URL must be on your registered hostname or a subdomain of it, over https.

<script src="https://micro.broker/client.js"></script>
<script>microBroker.init({ site: 'example.com' })</script>

<!-- 0.14 credits -->
<button data-mb-charge="0.14" data-mb-label="Keep reading">Continue</button>

<!-- or from code -->
<script>microBroker.pay({ amount: 0.14, label: 'Keep reading' })</script>

Attributes: data-mb-charge (credits), data-mb-label (shown on the pay sheet), data-mb-return (return URL; defaults to the current page).

Open the demo pay sheet →

Verifying a payment

The customer returns with ?mb_receipt=… in the URL. The customer can edit that URL, so do not unlock anything based on it alone. Exchange the code from your server with your API key and use the amount in the response.

curl -X POST https://micro.broker/api/pay/receipt \
  -H "X-Microbroker-Key: mbk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"code":"mbrc_…"}'

{
  "ok": true,
  "receipt": {
    "transactionId": "…",
    "host": "example.com",
    "amountUnits": 1400,
    "amountCredits": 0.14,
    "amountEur": 0.14,
    "amountLabel": "0.14 credits",
    "paidAt": "2026-08-26T10:04:11.000Z",
    "firstRedeemedAt": "2026-08-26T10:04:12.000Z"
  },
  "customerRef": "mbc_…"
}

A code only resolves with the API key of the site that earned it, and expires one hour after the charge. A code can be exchanged more than once so you can retry a failed request; firstRedeemedAt shows the first exchange. Store transactionId and unlock once per transaction.

Returning customers

Each receipt includes a customerRef. Save it with your own user record. It identifies the customer at your site only: other sites get a different ref for the same person, and it works only with your API key. With it you can show the customer what they have available with you, and charge them from your server without sending them to the pay sheet.

What you can see

curl https://micro.broker/api/customers/mbc_… \
  -H "X-Microbroker-Key: mbk_your_api_key"

{
  "customerRef": "mbc_…",
  "mode": "daily",
  "available":      { "units": 15000, "credits": 1.5, "eur": 1.5, "label": "1.5 credits" },
  "balance":        { "units": 30000, "credits": 3,   "eur": 3,   "label": "3 credits" },
  "dailyLimit":     { "units": 20000, "credits": 2,   "eur": 2,   "label": "2 credits" },
  "remainingToday": { "units": 15000, "credits": 1.5, "eur": 1.5, "label": "1.5 credits" }
}

You only see what the customer trusted you with:

  • ask: the customer approves every charge. balance, dailyLimit and remainingToday are null and available is 0.
  • daily: the customer set a daily limit. balance is their credits balance.

available is the largest single charge you can make right now without asking: the lower of balance and remainingToday. Show it on your page, for example "1.50 credits available".

Charging from your server

curl -X POST https://micro.broker/api/customers/mbc_…/charge \
  -H "X-Microbroker-Key: mbk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"amountCredits":0.14,"idempotencyKey":"order-1234","label":"Keep reading","returnUrl":"https://example.com/article"}'

{
  "ok": true,
  "replayed": false,
  "transaction": { "transactionId": "…", "amountUnits": 1400, "amountCredits": 0.14, "amountEur": 0.14, "amountLabel": "0.14 credits", "paidAt": "…" },
  "customer": { "customerRef": "mbc_…", "mode": "daily", "available": { … }, … }
}

The charge only goes through within what the customer allowed you. Otherwise you get an error with a payUrl. Send the customer there to approve the charge or buy credits; they come back to returnUrl with a receipt code as usual.

  • 403 with needsApproval: the customer approves every charge, or this one is over their daily limit.
  • 402 with needsCredits: not enough credits.
  • 404: unknown customerRef, or one that belongs to another site.

idempotencyKey is required. Sending the same key again returns the first charge with replayed: true instead of charging twice. The customer can change or withdraw what they allowed you at any time under Stores. amountEur remains accepted as a deprecated alias for amountCredits.

Amounts and fees

  • Amounts are in credits, up to four decimals. 1 credit = €1. Min 0.001, max 50.
  • Fee: 0.8% per charge.
  • Customers buy 5 to 1,000 credits at a time with PayPal. Their payment provider’s fee applies.
  • On their first charge at your site, each customer chooses: approve every charge, or a daily limit. Charges within the limit go through without a prompt; above it, the customer approves on the pay sheet.

Security

Hosted on Microsoft Azure. Sign-in is handled by login.broker. Sites receive a receipt code and a per-site customer reference, never the customer's email address. API keys and session tokens are stored as SHA-256 hashes.

Questions: nb@gyxi.com