Developers
Sign inGet API keys
API reference/Payments

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.

holygrail.locopesa.v1.LocoPesaService9 methodspayments.read · payments.write

GetConnection#

payments.readRead
POST/holygrail.locopesa.v1.LocoPesaService/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

connectionConnection
Request
curl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/GetConnection \
  -H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
Response example
{
  "connection": {
    "connected": false,
    "merchantName": "Amina Mushi",
    "lipaNamba": "",
    "keyHint": "",
    "webhooks": false,
    "connectedAt": "",
    "currencySupported": false
  }
}

Connect#

payments.writeWrite
POST/holygrail.locopesa.v1.LocoPesaService/Connect

Connects (or replaces) the business's Loco Pesa account. Needs settings.manage, and a person, not an API key.

Request body

secretKeystringsecret_key

A till key from the Loco Pesa app (Business account → Connect a till).

Response

connectionConnection
Request
curl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/Connect \
  -H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
Response example
{
  "connection": {
    "connected": false,
    "merchantName": "Amina Mushi",
    "lipaNamba": "",
    "keyHint": "",
    "webhooks": false,
    "connectedAt": "",
    "currencySupported": false
  }
}

Disconnect#

payments.writeWrite
POST/holygrail.locopesa.v1.LocoPesaService/Disconnect

Request body

No fields: send {}.

Response

No fields: send {}.

Request
curl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/Disconnect \
  -H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
Response example
{}

StartConnect#

payments.writeWrite
POST/holygrail.locopesa.v1.LocoPesaService/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

idstring

Pass id and poll_token back to PollConnect. The token stays with this screen: the code alone can't connect anything.

pollTokenstringpoll_token
codestring

What the owner types in the Loco Pesa app, e.g. "KXRT-4M9P".

linkstring

locopesa://connect?code=…, to show as a QR code.

qrPngbase64 stringqr_png

The same link as a PNG QR code.

expiresAtstringexpires_at
Request
curl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/StartConnect \
  -H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
Response example
{
  "id": "4f1c2e9a-8b3d-4e57-9a10-2c6f7d8e9b01",
  "pollToken": "",
  "code": "",
  "link": "",
  "qrPng": "",
  "expiresAt": ""
}

PollConnect#

payments.writeWrite
POST/holygrail.locopesa.v1.LocoPesaService/PollConnect

Request body

idstring
pollTokenstringpoll_token

Response

connectionConnection
Request
curl 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"
}'
Response example
{
  "status": "CONNECT_STATUS_PENDING",
  "connection": {
    "connected": false,
    "merchantName": "Amina Mushi",
    "lipaNamba": "",
    "keyHint": "",
    "webhooks": false,
    "connectedAt": "",
    "currencySupported": false
  }
}

CreateCharge#

payments.writeWrite
POST/holygrail.locopesa.v1.LocoPesaService/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_id
orderNumberstringorder_number

Shown to the customer, e.g. "Order 1042".

locationIdstringlocation_id
amountint64 string
customerPhonestringcustomer_phone

Optional. A Loco Pesa user's phone number: their app asks them to pay.

Response

chargeCharge
Request
curl 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"
}'
Response example
{
  "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#

payments.readRead
POST/holygrail.locopesa.v1.LocoPesaService/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

idstring

Response

chargeCharge
Request
curl 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"
}'
Response example
{
  "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#

payments.readRead
POST/holygrail.locopesa.v1.LocoPesaService/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_id

Response

chargesCharge[]
Request
curl https://api.buziin.tech/holygrail.locopesa.v1.LocoPesaService/ListCharges \
  -H "Authorization: Bearer $LUMORA_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
Response example
{
  "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#

payments.writeWrite
POST/holygrail.locopesa.v1.LocoPesaService/CancelCharge

Stops a waiting charge; the customer can no longer pay it.

Request body

idstring

Response

chargeCharge
Request
curl 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"
}'
Response example
{
  "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.

GetConnectionResponse

holygrail.locopesa.v1.GetConnectionResponse

connectionConnection

ConnectRequest

holygrail.locopesa.v1.ConnectRequest

secretKeystringsecret_key

A till key from the Loco Pesa app (Business account → Connect a till).

ConnectResponse

holygrail.locopesa.v1.ConnectResponse

connectionConnection

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

idstring

Pass id and poll_token back to PollConnect. The token stays with this screen: the code alone can't connect anything.

pollTokenstringpoll_token
codestring

What the owner types in the Loco Pesa app, e.g. "KXRT-4M9P".

linkstring

locopesa://connect?code=…, to show as a QR code.

qrPngbase64 stringqr_png

The same link as a PNG QR code.

expiresAtstringexpires_at

PollConnectRequest

holygrail.locopesa.v1.PollConnectRequest

idstring
pollTokenstringpoll_token

PollConnectResponse

holygrail.locopesa.v1.PollConnectResponse

connectionConnection

CreateChargeRequest

holygrail.locopesa.v1.CreateChargeRequest

orderIdstringorder_id
orderNumberstringorder_number

Shown to the customer, e.g. "Order 1042".

locationIdstringlocation_id
amountint64 string
customerPhonestringcustomer_phone

Optional. A Loco Pesa user's phone number: their app asks them to pay.

CreateChargeResponse

holygrail.locopesa.v1.CreateChargeResponse

chargeCharge

GetChargeRequest

holygrail.locopesa.v1.GetChargeRequest

idstring

GetChargeResponse

holygrail.locopesa.v1.GetChargeResponse

chargeCharge

ListChargesRequest

holygrail.locopesa.v1.ListChargesRequest

orderIdstringorder_id

ListChargesResponse

holygrail.locopesa.v1.ListChargesResponse

chargesCharge[]

CancelChargeRequest

holygrail.locopesa.v1.CancelChargeRequest

idstring

CancelChargeResponse

holygrail.locopesa.v1.CancelChargeResponse

chargeCharge

Connection

holygrail.locopesa.v1.Connection

connectedboolean
merchantNamestringmerchant_name

The Loco Pesa business account's name and Lipa Namba.

lipaNambastringlipa_namba
keyHintstringkey_hint

The start of the key, e.g. "lp_sk_Ab3d…", to tell keys apart.

webhooksboolean

True when Loco Pesa tells us about payments as they happen; otherwise charges are checked when registers ask.

connectedAtstringconnected_at
currencySupportedbooleancurrency_supported

Loco Pesa takes payments in Tanzanian shillings only.

Charge

holygrail.locopesa.v1.Charge

idstring
orderIdstringorder_id
locationIdstringlocation_id
amountint64 string

Minor units of the business's currency (TZS cents).

qrPayloadstringqr_payload

TANQR / EMVCo text for the customer to scan with any Loco Pesa app.

qrPngbase64 stringqr_png

The same code as a PNG, for screens that can't draw one.

merchantNamestringmerchant_name
lipaNambastringlipa_namba
referencestring

Loco Pesa's transaction reference ("LP…") once paid; the register records it on the payment.

customerPhonestringcustomer_phone
expiresAtstringexpires_at
paidAtstringpaid_at
createdAtstringcreated_at

ConnectStatus enum

holygrail.locopesa.v1.ConnectStatus

CONNECT_STATUS_UNSPECIFIED
CONNECT_STATUS_PENDING

Waiting for the owner to approve in the Loco Pesa app.

CONNECT_STATUS_CONNECTED

Approved and saved: connection is set.

CONNECT_STATUS_DENIED
CONNECT_STATUS_EXPIRED

Ran out of time, or was already used: start again.

ChargeStatus enum

holygrail.locopesa.v1.ChargeStatus

CHARGE_STATUS_UNSPECIFIED
CHARGE_STATUS_PENDING

Waiting for the customer.

CHARGE_STATUS_PAID
CHARGE_STATUS_CANCELLED
CHARGE_STATUS_EXPIRED

Base URL https://api.buziin.tech. Every method is POST with a JSON body; see Making requests.