Skip to content

Developers

Testing

Build against a Wellth that runs in development: its keys are test keys, its gates are open, and its payment rails are fakes that never touch real money. Then switch to your live key.

A test Wellth

  • A Wellth running in development mode makes wsk_test_ keys and sends livemode: false. Every deployed Wellth makes live keys.
  • If you work on Wellth itself, run it locally (npm run dev, at http://localhost:3000). Otherwise write to dev@tallgrasshq.com for a test Wellth and its address.
  • In development, gates are open, sign-in codes are printed in the server's terminal instead of texted, and webhook addresses may be http:// and local, such as http://localhost:4000/wellth/webhook.

Demo organisations

On a local Wellth, one command makes four demo organisations, each with sites, payers and bills, and about ten weeks of made-up history (every row marked as demo). Running it again adds nothing.

PowerShell or any shell, with npm run dev running
npm run org -- demo
npm run org
  • Demo High School: a school, for learners and collections.
  • Demo Clinic Kisaasi: a clinic with sites kisaasi and kyanja, for payers and bills.
  • Demo Fuel: a petrol station with three sites.
  • Demo Boda Fleet: riders on remittance plans, to read remittance.

Sign in as the demo owner, open /org, pick the organisation, open Connect, save a webhook address, then Make the API key. Copy the key and the signing secret.

A first run

curl

bash
export WELLTH=http://localhost:3000
export WELLTH_KEY=wsk_test_...   # from Connect

curl $WELLTH/api/org/v1/ping -H "Authorization: Bearer $WELLTH_KEY"

curl -X PUT $WELLTH/api/org/v1/payers/clinic_pt_1 \
  -H "Authorization: Bearer $WELLTH_KEY" -H "Content-Type: application/json" \
  -d '{ "payerLabel": "J. W.", "currency": "UGX", "siteCode": "kyanja" }'

curl -X POST $WELLTH/api/org/v1/bills \
  -H "Authorization: Bearer $WELLTH_KEY" -H "Content-Type: application/json" \
  -d '{ "payerRef": "clinic_pt_1", "externalRef": "inv_test_1", "description": "Clinic services", "amountMinor": "30000", "currency": "UGX" }'

PowerShell

PowerShell
$key = "wsk_test_..."
$h = @{ Authorization = "Bearer $key" }
Invoke-RestMethod http://localhost:3000/api/org/v1/ping -Headers $h
$p = Invoke-RestMethod http://localhost:3000/api/org/v1/payers/clinic_pt_1 -Method Put -Headers $h -ContentType "application/json" -Body (@{ payerLabel = "J. W."; currency = "UGX"; siteCode = "kyanja" } | ConvertTo-Json)
$b = Invoke-RestMethod http://localhost:3000/api/org/v1/bills -Method Post -Headers $h -ContentType "application/json" -Body (@{ payerRef = "clinic_pt_1"; externalRef = "inv_test_1"; description = "Clinic services"; amountMinor = "30000"; currency = "UGX" } | ConvertTo-Json)
$p.payUrl

Making a payment happen

Open the payer's payUrl (or a collection's), sign in as any test person, and pay. The fake rails decide the outcome from what you type:

  • Mobile money: a mobile-money number ending 0000 is declined, one ending 1111 stays pending (to test a payment on its way), and any other number succeeds.
  • From abroad by bank: a fake bank page opens, where you approve or decline.
  • From a Wellth balance: the test person needs money in their balance first.

A success writes the webhook events at once. The bill's paidMinor and the payer's balanceMinor change straight away: read them with GET to see it.

Getting the webhook

On a deployed Wellth, events go out every two minutes by themselves. Locally nothing runs on a timer, so send them yourself: press Try again now beside the event on Connect, or run the delivery route with the CRON_SECRET from Wellth's .env.local:

Deliver every due event
curl http://localhost:3000/api/cron/school-webhooks -H "Authorization: Bearer $CRON_SECRET"

It answers how many were delivered, are waiting to retry, or failed. Connect shows each event's answer from your system. No Wellth at hand? Sign a test event yourself.