AML Credit Ledger & Calmony Pay Integration
AML Credit Ledger & Calmony Pay Integration
The AML Credits system lets your organisation purchase and consume credits for AML/KYC identity checks powered by the Blinc-UK provider. Credits are bought via Calmony Pay and tracked in a full audit ledger per organisation.
Getting Started
1. Configure Environment Variables
Before AML checks can be run, set the following environment variables:
# Blinc-UK provider
BLINC_UK_API_KEY=your_blinc_api_key
BLINC_UK_API_URL=https://api.blinc-uk.com
BLINC_UK_WEBHOOK_SECRET=your_webhook_secret
# Calmony Pay (credit purchasing)
CALMONY_PAY_SECRET_KEY=your_calmony_secret_key
Credits can be purchased in advance even if the Blinc-UK integration is not yet configured. The dashboard will display a warning if
BLINC_UK_API_KEYis missing.
Dashboard
Navigate to Dashboard → AML Credits (/dashboard/aml).
Balance Card
Shows the current credit balance for your organisation in real time.
Integration Status
Displays a green/red indicator based on whether the Blinc-UK API key is configured.
Low-Balance Warning
A warning is shown automatically when your balance drops below 5 credits.
Purchasing Credits
- Click Purchase Credits on the AML Credits dashboard.
- Select a credit pack from the modal.
- You will be redirected to a hosted Calmony Pay checkout.
- On successful payment you are returned to the dashboard; credits are automatically added to your balance.
- If you cancel the checkout, no credits are charged or added.
Available Credit Packs
| Pack | Credits | Price | Per Credit |
|---|---|---|---|
| Starter | 10 | £50.00 | £5.00 |
| Standard | 25 | £112.50 | £4.50 |
| Professional | 50 | £200.00 | £4.00 |
| Enterprise | 100 | £350.00 | £3.50 |
Volume discounts apply automatically — larger packs have a lower cost per credit.
Transaction History
All credit movements are recorded and viewable in the Transaction History table on the AML Credits page.
Transaction Types
| Type | Description |
|---|---|
purchase | Credits added via a Calmony Pay checkout |
consumption | 1 credit consumed per AML check initiated |
refund | Credit returned when a check is cancelled |
adjustment | Manual admin top-up or correction |
The table shows:
- Transaction type (colour-coded badge)
- Credit amount (positive = credit added, negative = credit consumed)
- Running balance after each transaction
- Description
- Timestamp (relative)
Use the type filter dropdown to narrow the view to a specific transaction type. History is paginated in pages of 20.
tRPC API Reference
All procedures are under the
amlrouter (trpc.aml.*).
getBalance
Returns the current credit balance for the authenticated organisation.
const { data } = trpc.aml.getBalance.useQuery();
// data.balance: number
getCreditPacks
Returns the list of available credit packs with pricing.
const { data } = trpc.aml.getCreditPacks.useQuery();
// data: Array<{ id, name, credits, priceGBP, perCreditGBP }>
purchaseCredits
Creates a Calmony Pay checkout session. The client should redirect to the returned URL.
const mutation = trpc.aml.purchaseCredits.useMutation();
mutation.mutate({ packId: '25-credits' });
// returns: { checkoutUrl: string }
fulfilPurchase
Called automatically on successful payment return. Adds credits and records the purchase in the audit ledger.
const mutation = trpc.aml.fulfilPurchase.useMutation();
mutation.mutate({ packId: '25-credits' });
creditHistory
Paginated transaction ledger, optionally filtered by type.
const { data } = trpc.aml.creditHistory.useQuery({
type: 'purchase', // optional: 'purchase' | 'consumption' | 'refund' | 'adjustment'
cursor: '...', // optional: pagination cursor
limit: 20,
});
// data: { items: Transaction[], nextCursor?: string }
initiateCheck
Consumes 1 credit and dispatches an AML check via Blinc-UK.
cancelCheck
Cancels an in-progress check and refunds 1 credit.
integrationStatus
Returns whether the Blinc-UK provider is configured.
const { data } = trpc.aml.integrationStatus.useQuery();
// data: { configured: boolean, provider: string }
Notes
- All credit operations are scoped per organisation — balances are not shared between orgs.
- Credits do not expire.
- The audit ledger (
creditHistory) is append-only; no transactions are deleted.