Loco Pesa
LocoPesaService takes payments through Loco Pesa, a Tanzanian wallet, at the register.
A business connects its Loco Pesa business account once by pasting a till key (lp_sk_…) from the Loco Pesa app. A charge is one request to pay an order: the register shows its QR code, or sends it to the customer's Loco Pesa app by phone number, and waits until it is paid. The register then records the payment like any other, with the Loco Pesa reference. See docs/adr/0037-loco-pesa.md.
GetConnection#
The business's connection, without its key. Anyone signed in may read it, so registers know whether to offer Loco Pesa.
Request body
No fields: send {}.
Response
connectionConnectioncurl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/GetConnection \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'{
"connection": {
"connected": false,
"merchantName": "Amina Mushi",
"lipaNamba": "",
"keyHint": "",
"webhooks": false,
"connectedAt": "",
"currencySupported": false
}
}Connect#
Connects (or replaces) the business's Loco Pesa account. Needs settings.manage, and a person, not an API key.
Request body
secretKeystringsecret_keyA till key from the Loco Pesa app (Business account → Connect a till).
Response
connectionConnectioncurl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/Connect \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'{
"connection": {
"connected": false,
"merchantName": "Amina Mushi",
"lipaNamba": "",
"keyHint": "",
"webhooks": false,
"connectedAt": "",
"currencySupported": false
}
}Disconnect#
Request body
No fields: send {}.
Response
No fields: send {}.
curl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/Disconnect \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'{}StartConnect#
"Connect with Loco Pesa": instead of pasting a key, the dashboard shows a code as a QR. The owner scans it in the Loco Pesa app and approves with their PIN, and the next PollConnect saves the account. Both need settings.manage, and a person, not an API key.
Request body
No fields: send {}.
Response
idstringPass id and poll_token back to PollConnect. The token stays with this screen: the code alone can't connect anything.
pollTokenstringpoll_tokencodestringWhat the owner types in the Loco Pesa app, e.g. "KXRT-4M9P".
linkstringlocopesa://connect?code=…, to show as a QR code.
qrPngbase64 stringqr_pngThe same link as a PNG QR code.
expiresAtstringexpires_atcurl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/StartConnect \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'{
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01",
"pollToken": "",
"code": "",
"link": "",
"qrPng": "",
"expiresAt": ""
}PollConnect#
Request body
idstringpollTokenstringpoll_tokenResponse
statusConnectStatusconnectionConnectioncurl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/PollConnect \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01"
}'{
"status": "CONNECT_STATUS_PENDING",
"connection": {
"connected": false,
"merchantName": "Amina Mushi",
"lipaNamba": "",
"keyHint": "",
"webhooks": false,
"connectedAt": "",
"currencySupported": false
}
}CreateCharge#
Asks the customer to pay an amount toward an order. Needs pos.sell. Asking again for the same order and amount while one is still waiting returns that one.
Request body
orderIdstringorder_idorderNumberstringorder_numberShown to the customer, e.g. "Order 1042".
locationIdstringlocation_idamountint64 stringcustomerPhonestringcustomer_phoneOptional. A Loco Pesa user's phone number: their app asks them to pay.
Response
chargeChargecurl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/CreateCharge \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"locationId": "0193a4f2-0b10-7f62-a4c9-6d1e2b3c4f70",
"amount": "150000",
"customerPhone": "+255712345678"
}'{
"charge": {
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01",
"orderId": "",
"locationId": "0193a4f2-0b10-7f62-a4c9-6d1e2b3c4f70",
"amount": "150000",
"status": "CHARGE_STATUS_PENDING",
"qrPayload": "",
"qrPng": "",
"merchantName": "Amina Mushi",
"lipaNamba": "",
"reference": "",
"customerPhone": "+255712345678",
"expiresAt": "",
"paidAt": "",
"createdAt": ""
}
}GetCharge#
A charge's latest state. While it waits, this also checks with Loco Pesa, so registers can poll it every couple of seconds.
Request body
idstringResponse
chargeChargecurl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/GetCharge \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01"
}'{
"charge": {
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01",
"orderId": "",
"locationId": "0193a4f2-0b10-7f62-a4c9-6d1e2b3c4f70",
"amount": "150000",
"status": "CHARGE_STATUS_PENDING",
"qrPayload": "",
"qrPng": "",
"merchantName": "Amina Mushi",
"lipaNamba": "",
"reference": "",
"customerPhone": "+255712345678",
"expiresAt": "",
"paidAt": "",
"createdAt": ""
}
}ListCharges#
An order's charges, newest first, so a register that restarted can find one that was paid but not yet recorded.
Request body
orderIdstringorder_idResponse
chargesCharge[]curl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/ListCharges \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{}'{
"charges": [
{
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01",
"orderId": "",
"locationId": "0193a4f2-0b10-7f62-a4c9-6d1e2b3c4f70",
"amount": "150000",
"status": "CHARGE_STATUS_PENDING",
"qrPayload": "",
"qrPng": "",
"merchantName": "Amina Mushi",
"lipaNamba": "",
"reference": "",
"customerPhone": "+255712345678",
"expiresAt": "",
"paidAt": "",
"createdAt": ""
}
]
}CancelCharge#
Stops a waiting charge; the customer can no longer pay it.
Request body
idstringResponse
chargeChargecurl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/CancelCharge \
-H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01"
}'{
"charge": {
"id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01",
"orderId": "",
"locationId": "0193a4f2-0b10-7f62-a4c9-6d1e2b3c4f70",
"amount": "150000",
"status": "CHARGE_STATUS_PENDING",
"qrPayload": "",
"qrPng": "",
"merchantName": "Amina Mushi",
"lipaNamba": "",
"reference": "",
"customerPhone": "+255712345678",
"expiresAt": "",
"paidAt": "",
"createdAt": ""
}
}Types
The messages and enums these methods use. Field names are lowerCamelCase in JSON; the snake_case names work too. Enum values are sent as their names.
GetConnectionRequest
holygrail.locopesa.v1.GetConnectionRequest
No fields.
ConnectRequest
holygrail.locopesa.v1.ConnectRequest
secretKeystringsecret_keyA till key from the Loco Pesa app (Business account → Connect a till).
DisconnectRequest
holygrail.locopesa.v1.DisconnectRequest
No fields.
DisconnectResponse
holygrail.locopesa.v1.DisconnectResponse
No fields.
StartConnectRequest
holygrail.locopesa.v1.StartConnectRequest
No fields.
StartConnectResponse
holygrail.locopesa.v1.StartConnectResponse
idstringPass id and poll_token back to PollConnect. The token stays with this screen: the code alone can't connect anything.
pollTokenstringpoll_tokencodestringWhat the owner types in the Loco Pesa app, e.g. "KXRT-4M9P".
linkstringlocopesa://connect?code=…, to show as a QR code.
qrPngbase64 stringqr_pngThe same link as a PNG QR code.
expiresAtstringexpires_atPollConnectRequest
holygrail.locopesa.v1.PollConnectRequest
idstringpollTokenstringpoll_tokenCreateChargeRequest
holygrail.locopesa.v1.CreateChargeRequest
orderIdstringorder_idorderNumberstringorder_numberShown to the customer, e.g. "Order 1042".
locationIdstringlocation_idamountint64 stringcustomerPhonestringcustomer_phoneOptional. A Loco Pesa user's phone number: their app asks them to pay.
GetChargeRequest
holygrail.locopesa.v1.GetChargeRequest
idstringListChargesRequest
holygrail.locopesa.v1.ListChargesRequest
orderIdstringorder_idCancelChargeRequest
holygrail.locopesa.v1.CancelChargeRequest
idstringConnection
holygrail.locopesa.v1.Connection
connectedbooleanmerchantNamestringmerchant_nameThe Loco Pesa business account's name and Lipa Namba.
lipaNambastringlipa_nambakeyHintstringkey_hintThe start of the key, e.g. "lp_sk_Ab3d…", to tell keys apart.
webhooksbooleanTrue when Loco Pesa tells us about payments as they happen; otherwise charges are checked when registers ask.
connectedAtstringconnected_atcurrencySupportedbooleancurrency_supportedLoco Pesa takes payments in Tanzanian shillings only.
Charge
holygrail.locopesa.v1.Charge
idstringorderIdstringorder_idlocationIdstringlocation_idamountint64 stringMinor units of the business's currency (TZS cents).
statusChargeStatusqrPayloadstringqr_payloadTANQR / EMVCo text for the customer to scan with any Loco Pesa app.
qrPngbase64 stringqr_pngThe same code as a PNG, for screens that can't draw one.
merchantNamestringmerchant_namelipaNambastringlipa_nambareferencestringLoco Pesa's transaction reference ("LP…") once paid; the register records it on the payment.
customerPhonestringcustomer_phoneexpiresAtstringexpires_atpaidAtstringpaid_atcreatedAtstringcreated_atConnectStatus enum
holygrail.locopesa.v1.ConnectStatus
CONNECT_STATUS_UNSPECIFIEDCONNECT_STATUS_PENDINGWaiting for the owner to approve in the Loco Pesa app.
CONNECT_STATUS_CONNECTEDApproved and saved: connection is set.
CONNECT_STATUS_DENIEDCONNECT_STATUS_EXPIREDRan out of time, or was already used: start again.
ChargeStatus enum
holygrail.locopesa.v1.ChargeStatus
CHARGE_STATUS_UNSPECIFIEDCHARGE_STATUS_PENDINGWaiting for the customer.
CHARGE_STATUS_PAIDCHARGE_STATUS_CANCELLEDCHARGE_STATUS_EXPIREDBase URL https://api.buziin.tech. Every method is POST with a JSON body; see Making requests.