Docs
How to charge credits from a site or app.
Quickstart
- 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. - Add the client script to your page and call
initwith your hostname. - Add
data-mb-chargeto any element that should start a charge. - When the customer returns, verify the receipt code from your server.
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,dailyLimitandremainingTodayarenullandavailableis 0.daily: the customer set a daily limit.balanceis 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.
403withneedsApproval: the customer approves every charge, or this one is over their daily limit.402withneedsCredits: not enough credits.404: unknowncustomerRef, 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