LipaZone
DEVELOPER API v1.3.0 ยท SANDBOX

Build your LipaZone integration.

Authenticate your application, inspect business capabilities, validate requests and execute simulated collections and refunds. Approved Stripe test arrangements can use hosted test checkout. No live money moves.

Run a merchant order from payment to receipt

Download the standalone PHP sandbox example. It keeps your order, immutable amount and idempotency key in a separate SQLite database, calls the public payment API, verifies signed events and recovers status without creating a replacement charge. The example receipt is a payment confirmation, not a fiscal receipt.

Save all three files together. Configure LIPAZONE_API_URL, LIPAZONE_API_TOKEN, LIPAZONE_APPLICATION_ID, LIPAZONE_WEBHOOK_SECRET and an absolute LIPAZONE_DEMO_DB path outside the web root. Use a sandbox credential with payments:write and payments:read. Keep credentials in your server environment.

php merchant-demo.php create ORDER-001 10000 TZS simulator
php merchant-demo.php create ORDER-002 2000 USD stripe ARRANGEMENT_UUID
php merchant-demo.php refresh ORDER-002
php merchant-demo.php receipt ORDER-002

Open the returned checkout URL for Stripe. A browser return is not confirmation. For webhooks, run php -S 127.0.0.1:8091 merchant-demo.php behind your HTTPS development proxy, then register https://your-test-host/webhooks on the same application. Subscribe to collection events. Only the webhook route is served over HTTP; order creation and receipt access stay in your terminal. This example is a development harness, not a production storefront.

If the first payment response is lost, repeat the original create command. It uses the saved key. A webhook arriving before that mapping is restored returns a retryable failure. Verified event IDs are deduplicated transactionally, and older events cannot undo a final payment result.

Catalog and inventory

Merchant mobile API version 0.4.0 supports products, variants, SKU/barcode search, prices, stock locations, low-stock views and audited stock movements. Issuing a catalog invoice reserves stock. Full payment permits explicit goods fulfillment; it never implies dispatch automatically.

Stock uses whole units. Receipt, adjustment and transfer requests carry a stable UUID idempotency key. Retrying the same instructions returns the same operation. Unpaid stock holds expire after 24 hours; pending or partially paid invoices retain their hold. Goods returns and money refunds are separate operations.

Catalog and inventory API reference

Mobile configuration and exact amounts

Personal and merchant bootstrap endpoints return versioned currency metadata, expiry and sandbox capabilities. Select a business through the business-scoped bootstrap to receive current role, permissions and usable terminal methods. Refresh on foreground resume and expiry; writes always recheck server authorization. Regional currency metadata does not enable regional payments.

The apps retain integer amounts with currency and precision. Existing TZS/USD values keep two decimal places. Tax basis points are separate. Merchant app navigation is Home, Sell, Activity, Catalog and More. Storefront orders come before POS; neither unfinished destination is exposed.

Merchant app, invoices and payment requests

The merchant Flutter app uses /api/v1/merchant with separate device tokens and business-scoped owner, admin or finance access. Customers, itemized invoice drafts, issuance, partial collections, payment links and settlement visibility share the same backend as the native Filament panels. Superadmins can manage every business.

The personal app can scan or paste trusted LipaZone links, review the merchant and amount, and open hosted checkout. Person requests expire after 30 minutes and still require explicit password/MFA transfer confirmation. NFC phone-to-phone transport and contactless card acceptance remain disabled behind capability gates.

Amounts use integer minor units. Invoice tax rates are explicit basis points. Unsubmitted invoice reservations expire after 15 minutes; pending provider payments remain reserved until resolved. Refunds are shown separately and do not reopen the original invoice debt. Issued invoices cannot be edited. Reminders require an email and are limited to one per day.

Merchant mobile reference Personal mobile reference

Personal app and P2P sandbox

The first-party Flutter app uses a separate user/device API at /api/v1/personal. Sign in with a verified user, look up another client by exact email, create an idempotent review and authorize the transfer with a password and enrolled MFA. Device tokens must stay in OS secure storage. Business API secrets do not authenticate personal users.

The source is simulated mobile money. Success, funding rejection, unknown delivery and a refunded delivery rejection are supported. No real money moves and no LipaZone wallet balance is created. Check the same transfer after a timeout; do not create another send. Reviews expire after ten minutes. Pending simulator deliveries resolve after twenty seconds through refresh or scheduled reconciliation.

Download personal OpenAPI

1. Connect an application

  1. Create a LipaZone account and verify your email.
  2. Create or join a business as an owner, administrator or developer.
  3. Open Developer access, create an application and issue a sandbox key with the scopes your integration needs.
  4. Save the secret on your server. It is displayed only once and expires after 90 days.

Use your deployment root as LIPAZONE_BASE_URL, without a trailing slash. Configure LIPAZONE_API_KEY in your local secret store. Use HTTPS outside local development. Do not put server keys into Flutter, frontend JavaScript, URLs or source control.

curl --fail-with-body "$LIPAZONE_BASE_URL/api/v1/account" \
  -H "Authorization: Bearer $LIPAZONE_API_KEY" \
  -H 'Accept: application/json'

Imported Postman variables contain no key. Set base_url and api_key locally, and keep the key out of shared or synced collections. The collection includes positive and negative checks.

LipaZone Pay: Stripe sandbox checkout

POST /api/v1/payments accepts provider=stripe and an arrangement_id from your business. The arrangement must be direct, sandbox, verified against the configured Stripe account and independently approved for collect / USD / card. The server must enable STRIPE_TEST_PAYMENTS_ENABLED and configure STRIPE_WEBHOOK_SECRET. Ordinary merchant credentials are reserved to one arrangement; this is not Stripe Connect.

{"reference":"ORDER-STRIPE-1","provider":"stripe","arrangement_id":"YOUR-ARRANGEMENT-UUID","amount":{"currency":"USD","minor_units":2000},"expires_in":3600}

Requires payments:write and Idempotency-Key. Do not supply scenario. USD amounts range from 50 to 99999999 integer minor units; checkout expiry ranges from 3600 to 86400 seconds. Open data.checkout_url to review the payment and continue to Stripe-hosted checkout. That URL is a seven-day signed bearer link: do not publish it in logs or analytics. Raw card data never enters LipaZone. The return page shows recorded status and never confirms a payment from query parameters.

Read status with GET /api/v1/operations/{operation}. HTTP 201 only means the operation was created. Unknown outcomes must not be retried with a new key or a different provider. Recovery reuses the exact stored Checkout request and key within a 20-minute window. Beyond that window an unresolved submission requires investigation, not a new charge. Known sessions continue to be checked by their provider ID. Credential changes stop automatic lookup until operations reviews the credential binding.

POST /api/v1/provider-callbacks/stripe validates Stripe-Signature against the raw body, accepts only direct-account test events and stores a redacted callback inbox. Checkout completion alone is insufficient: amount, currency, operation metadata, session ID and captured PaymentIntent evidence must match. Run payments:reconcile-stripe through the scheduler to recover callbacks and status lookups. Signed merchant webhooks are dispatched through the existing webhooks worker.

Stripe refunds return 409 provider_refund_not_supported in this release. Simulator resolution and simulator refunds cannot affect Stripe payments. Disconnecting a profile blocks new submissions; an already issued Stripe checkout may still complete and must be reconciled. Confirmation represents a provider test payment, not merchant settlement. Configurable merchant fees, direct fee invoices and managed settlement workflows are implemented separately. Stripe refunds remain unavailable.

2. Authentication and scopes

Send Authorization: Bearer followed by your lz_test_ key. The key is tied to one application, business and sandbox environment. A browser session is not an API credential. Organization IDs supplied by callers never select another business.

ScopePermitted operation
payments:readRead sandbox payment and refund operations
payments:writeCreate sandbox payments with the simulator or an approved Stripe test arrangement
refunds:writeCreate simulated sandbox refunds
sandbox:simulateResolve simulated sandbox outcomes
account:readRead application and business context
sandbox:readRead sandbox scenario definitions
sandbox:validateValidate a sandbox payment request contract

Scope selection defaults to account:read. To run the entire example collection, issue a key with the scopes needed by each example. Wildcards are rejected. Existing keys do not gain new payment scopes automatically. Missing scope returns 403; missing, invalid, expired, revoked, disabled-app or unauthorized-creator credentials return 401.

Live key issuance is unavailable. A stored merchant capability approval does not enable an adapter or make a sandbox key usable for live processing.

3. Available endpoints

GET /api/v1/account

Requires account:read. Returns the application, current business review status, credential scopes and merchant capability approval records. No query parameters are required.

{
  "data": {
    "application_id": "22222222-2222-4222-8222-222222222222",
    "application_name": "Example integration",
    "business": {
      "id": "33333333-3333-4333-8333-333333333333",
      "name": "Example business",
      "onboarding_status": "draft"
    },
    "environment": "sandbox",
    "scopes": ["account:read"],
    "live_payments_enabled": false,
    "capabilities": []
  },
  "meta": {
    "request_id": "11111111-1111-4111-8111-111111111111",
    "api_version": "1.3.0"
  }
}

Capability records identify provider, environment, operation, currency, method, approval_status, enabled and unavailable_reason. A verified, independently approved Stripe sandbox USD card collection can report enabled=true with unavailable_reason=null when server execution and callback settings are configured. Live capabilities remain disabled. Reasons include provider_not_connected, provider_verification_pending, provider_routing_pending, provider_disconnected, business_not_approved, business_suspended, approval_revoked and arrangement_revoked. Approval and execution readiness are separate.

GET /api/v1/sandbox/scenarios

Requires sandbox:read. Returns the executable contract checks, their target endpoints, expected HTTP statuses and setup instructions. It is an unpaginated catalogue, not a list of payment transactions.

POST /api/v1/sandbox/validate

Requires sandbox:validate and Content-Type: application/json. Validates a request without creating a payment, reserving funds, saving a reference, sending a webhook or calling Selcom or Stripe. The maximum body size is 16 KiB.

curl --fail-with-body "$LIPAZONE_BASE_URL/api/v1/sandbox/validate" \
  -H "Authorization: Bearer $LIPAZONE_API_KEY" \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  --data '{"reference":"ORDER-1001","amount":{"currency":"TZS","minor_units":150000}}'
FieldContract
reference1 to 100 ASCII characters. Start with a letter or digit; remaining characters may also include dot, underscore, colon or hyphen. Use a synthetic reference, not customer information.
amount.currencyTZS or USD. These are sandbox validation fixtures, not a claim of live provider availability.
amount.minor_unitsA JSON integer from 1 through 999999999999. Strings, fractions, booleans and zero are rejected. The limit is a contract-validation bound, not a merchant transaction limit.

Only reference and amount are accepted at the top level. Only currency and minor_units are accepted inside amount. Empty bodies, invalid JSON and non-object bodies are rejected.

{
  "data": {
    "valid": true,
    "payment_created": false,
    "normalized_request": {
      "reference": "ORDER-1001",
      "amount": {"currency": "TZS", "minor_units": 150000}
    }
  },
  "meta": {
    "request_id": "11111111-1111-4111-8111-111111111111",
    "api_version": "1.3.0"
  }
}

This validation operation has no financial side effects and may be repeated. Idempotency-Key has no defined behavior on these endpoints.

4. Errors, request IDs and quotas

Responses use JSON, including errors when Accept is omitted. Each response has a server-generated X-Request-ID, also returned as meta.request_id. Incoming request IDs are not trusted or reflected. Keep the returned ID when reporting an integration problem.

{
  "error": {
    "code": "validation_failed",
    "message": "The request does not match the sandbox contract.",
    "details": {
      "amount.minor_units": ["Use a positive integer amount within the documented sandbox limit."]
    }
  },
  "meta": {
    "request_id": "11111111-1111-4111-8111-111111111111",
    "api_version": "1.3.0"
  }
}
HTTPCodeAction
400invalid_jsonSend a valid JSON object.
401invalid_api_keyCheck the key, expiry, application availability and creator access.
403insufficient_scopeIssue a key with the required scope.
404not_foundCheck the documented URL.
409operation_conflictUse a new key for a new operation, or check the operation state and remaining refundable amount.
405method_not_allowedUse the HTTP method advertised by Allow.
413request_too_largeReduce the JSON body to at most 16 KiB.
415unsupported_media_typeSet Content-Type to application/json.
422validation_failedCorrect the fields listed in error.details.
429rate_limitedWait for the Retry-After interval.
500server_errorRetain X-Request-ID and contact support if repeated.

The application quota is 60 requests per minute, shared across its credentials and endpoints. A separate 120-per-minute source-IP limit protects authentication, including unsuccessful requests. Separate applications share the IP limit when they use the same network.

Use X-RateLimit-Limit, X-RateLimit-Remaining and Retry-After. For 429, wait as instructed and add jitter before retrying. Read and validation requests can be retried with a bounded retry policy. Do not assume future money-changing operations have the same retry behavior.

Authenticated request history is visible in Developer access for seven days: request ID, route name, method, status and duration. It excludes keys, request/response bodies, query strings, IP addresses and raw URLs. Unauthenticated requests and unmatched routes do not appear in application history. API responses use Cache-Control: no-store, private.

5. Sandbox checklist

  1. Call account with account:read and confirm the correct business UUID.
  2. Omit the key and expect 401.
  3. Use a sandbox:read-only key on account and expect 403.
  4. Submit the documented validation example and expect valid=true and payment_created=false.
  5. Send 1.5 or "150000" as minor_units and expect 422.
  6. Revoke a key and confirm it immediately returns 401.
  7. Disable an application and confirm all its old keys fail, even after re-enabling it.
  8. Rotate a key, verify the replacement, and confirm the previous key stops working after its overlap window.

Inspect the scenario endpoint for machine-readable checks. The simulator supports success, rejection, pending, timeout, late confirmation and duplicate confirmation. A separately authenticated simulator callback is available. Real provider callback formats remain pending.

6. Key and application lifecycle

Rotation creates a new secret with the same scopes and a fresh 90-day expiry. Choose an overlap of 0 to 1440 minutes; the old key expires at the earlier of its existing expiry and that deadline. Zero revokes it immediately. A key can be rotated only once; subsequent rotations use the replacement.

Save the replacement immediately, update your server, verify access and revoke the old key when ready. If you lose the one-time response, issue another key and revoke the unused one. A rotation does not expand scopes or change business context.

Disabling an application permanently revokes its existing keys. Re-enabling allows new issuance but does not revive old keys. Removing a member, removing developer privileges or recovering their password revokes the relevant keys. Suspending a merchant does not remove sandbox account-read access, so integrations can inspect the restriction.

Laravel client example

$response = Http::withToken(config('services.lipazone.key'))
    ->acceptJson()
    ->connectTimeout(5)
    ->timeout(15)
    ->get(config('services.lipazone.base_url').'/api/v1/account');

$requestId = $response->header('X-Request-ID');
$response->throw();
$business = $response->json('data.business');

Configure services.lipazone.key and services.lipazone.base_url from your application's secret-backed environment. Do not log the Authorization header or the entire client request.

7. Versioning and the next contracts

The current path version is /api/v1 and the published contract release is 1.3.0. Clients should tolerate additional response fields. Breaking schema or behavior changes require a separately published version and migration guidance. No retirement date is announced.

No paginated payment resource is published yet. Future list APIs will document pagination, ordering and limits when implemented. Future timestamps will use UTC RFC 3339; identifiers remain opaque strings.

Simulated payment requests, attempts, partial refunds and balanced sandbox journals are implemented. Stripe sandbox hosted checkout is implemented for eligible configured arrangements. Transfers, Selcom collection routing and live processing remain pending. Signed outbound sandbox webhooks are available. The simulator resolution endpoint is a developer testing tool, not a provider callback endpoint. Webhook signatures, retries and replay rules are documented below.

Merchant onboarding approval and provider arrangements are already represented in account capabilities. The transition to live will additionally require a connected adapter and a deliberate live-credential release. Sandbox keys will never silently become live keys.

The downloadable OpenAPI file contains only implemented integration endpoints. Portal forms and staff operations are browser interfaces, not public server-to-server contracts.

8. Simulated payments and refunds

POST /api/v1/payments requires payments:write. GET /api/v1/operations/{operation} requires payments:read. POST /api/v1/payments/{payment}/refunds requires refunds:write. POST /api/v1/sandbox/operations/{operation}/resolve requires sandbox:simulate. All resources belong to the authenticated application, even when another application belongs to the same business.

curl --fail-with-body "$LIPAZONE_BASE_URL/api/v1/payments" \
  -H "Authorization: Bearer $LIPAZONE_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: example-payment-1001' \
  --data '{"reference":"ORDER-1001","amount":{"currency":"TZS","minor_units":150000},"scenario":"success","expires_in":3600}'

A new operation returns 201, including rejected or unresolved simulated outcomes. Inspect data.status; HTTP creation does not mean payment success. Repeating the same normalized payload and key returns 200, Idempotency-Replayed: true and the existing operation in its current state. Changed payloads return 409. Keys are application-scoped across collections and refunds, survive credential rotation, and remain reserved for the operation lifetime. References are labels, not deduplication keys. Retries must reuse the original key.

Use positive JSON integer minor units. TZS and USD fixtures both use exponent 2: 150000 minor units represents 1500.00. Explicit fee plans can record sandbox fees and settlement obligations. There is no FX conversion or real settlement. Optional scenario defaults to success; expires_in defaults to 3600 seconds and accepts 1 through 86400. Expiry prevents an operation from being submitted after its deadline. A submitted pending or unknown operation never becomes failed merely because time passes.

ScenarioInitial status
success, duplicate_confirmationsucceeded
rejectedfailed
pendingpending
timeout, late_confirmationunknown

Resolve pending or unknown operations using JSON such as {"event_id":"confirmation-1","outcome":"succeeded"}. Outcomes may be succeeded or failed. Repeated evidence cannot duplicate posting; changing an event outcome or contradicting a terminal result returns 409. This endpoint authenticates with a sandbox developer key. It must never be used as a real provider callback.

Refund requests use the same request shape and require their own idempotency key. Currency must match a succeeded collection. Reservations plus completed refunds cannot exceed the collected amount. Unknown refunds retain their reservation. Failed refunds release it. Successful refunds convert reserved amounts into refunded totals. Inspect the parent operation for updated totals.

Every succeeded collection or refund commits its state, balanced sandbox journal and internal event together. The journals represent simulated provider clearing and merchant obligations, not spendable wallet balances or settled bank funds. Subscribed endpoints receive signed terminal events through the outbox dispatcher. If processing stops after an attempt begins, its pending state remains visible; use explicit simulator evidence to complete it. An unsubmitted created operation can resume when its original create request is retried.

9. Signed sandbox webhooks

Open Developer access, register a public HTTPS endpoint for an application, select terminal events and save the signing secret shown once. Webhook registration and changes require a current password. The URL is immutable; use a new endpoint when changing receivers. New registrations and re-enabled endpoints subscribe to new events, not historical events. Up to ten endpoints may be registered per application.

Deliveries contain id, application_id, type, created_at and data. The data object contains operation_id, environment, status and amount. Use the event id for deduplication, not the timestamp. Events may arrive more than once and out of order. Refund events identify the refund operation; retrieve it through the API to find its parent payment.

X-LipaZone-Delivery-ID: <delivery UUID>
X-LipaZone-Signature: t=<Unix timestamp>,v1=<HMAC hex>

signed bytes = timestamp + "." + delivery UUID + "." + exact raw body
signature = HMAC-SHA256(signing secret, signed bytes)

Verify the raw body before JSON parsing. Reject timestamps more than 300 seconds in the past or future, reject malformed headers and use constant-time signature comparison. Load the secret for this receiving endpoint; never accept a secret from the incoming request. Keep server clocks synchronized.

Download PHP signature verifier

After verification, store the event ID and apply its business effects in one transaction, or durably enqueue the event before returning 2xx. Already processed events should also receive 2xx. Signature validation alone does not prevent duplicate business effects.

Automatic delivery uses up to six attempts: immediately, then after 60, 300, 900, 3600 and 21600 seconds following failures. Network failures and non-2xx responses are retried, including redirects, which are never followed. Unsafe destinations fail without a network request. Timeouts and interrupted workers may produce duplicate deliveries even when the receiver processed the first attempt.

Developer access shows status, attempt count, last HTTP status and a safe error code. Response bodies and signing secrets are excluded from diagnostics. Manual redelivery starts a new retry cycle while preserving the original event ID, delivery ID and body. Each attempt uses a fresh signature timestamp.

Rotation reveals a replacement secret once. An overlap from 0 to 1440 minutes can include two v1 signatures, one for each key. Configure the new secret on your receiver, then remove the retired secret after the overlap. Another rotation is blocked while overlap is active. Disabling an endpoint cancels pending retries; an HTTP request already in flight can still finish.

Provider callbacks are separate

POST /api/v1/provider-callbacks/simulator uses a server-only simulator secret configured separately from API keys and endpoint signing secrets. It requires X-LipaZone-Provider-Event-ID and X-LipaZone-Provider-Signature. The signature input is timestamp.event_uuid.raw_body with the same five-minute clock tolerance. The JSON body contains operation_id, provider_reference, outcome and amount. Amount, currency and reference must match the stored simulator attempt.

Repeated event IDs require identical body bytes. Conflicting evidence returns 409 and cannot change a terminal payment result. Authenticated callbacks are persisted before processing, so a processing failure can be recovered. Without the configured server secret the callback endpoint returns 503. Stripe callbacks use the separate endpoint documented below; Selcom callbacks remain pending.

Running delivery workers

Run the Laravel scheduler and a persistent queue worker for the webhooks queue. Use a durable queue connection, not sync, in deployed environments. Configure the queue retry-after or visibility timeout to exceed the 20-second job timeout; 120 seconds is a suitable starting value. The dispatcher and inbox recovery commands run each minute.

php artisan webhooks:dispatch
php artisan providers:process-inbox
php artisan queue:work --queue=webhooks --timeout=20 --tries=1

The transport requires PHP cURL with CURLOPT_PROTOCOLS_STR support. It checks DNS on every attempt, pins a permitted public address, verifies TLS and disables proxies and redirects. Responses are capped at 64 KiB of body and 32 KiB of headers. The transport timeout is ten seconds. Production concurrency and deployment checks remain required before live rollout.