Download the PHP package nombaone/nombaone-php without Composer
On this page you can find all versions of the php package nombaone/nombaone-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nombaone/nombaone-php
More information about nombaone/nombaone-php
Files in nombaone/nombaone-php
Package nombaone-php
Short Description Official PHP SDK for the NombaOne subscription-billing API — recurring billing for Nigeria over card, direct debit, and bank transfer.
License MIT
Homepage https://docs.nombaone.xyz
Informations about the package nombaone-php
nombaone/nombaone-php
The official PHP SDK for the Nomba One subscription-billing API — recurring billing for Nigeria over card, direct debit, bank transfer, and more, with dunning that recovers and a ledger that never loses a kobo.
Requires PHP 8.2+ and any PSR-18 HTTP client + PSR-17 factories, which the SDK auto-discovers (Guzzle, Symfony HttpClient, Nyholm, …). Server-side only — there is no publishable key.
Quickstart
Grab a sandbox key (nbo_sandbox_…) from the dashboard, set it as NOMBAONE_API_KEY, and you are three objects away from a live subscription:
The client derives the host from your key prefix — nbo_sandbox_… talks to https://sandbox.api.nombaone.xyz, nbo_live_… to https://api.nombaone.xyz.
You pass associative arrays in and receive typed, readonly objects out ($subscription->status, $customer->email) — with your IDE autocompleting every field.
Sandbox first
The sandbox runs the real billing engine. $nomba->sandbox->* gives you the levers to make a month happen in a second:
These methods throw locally (before any network call) if used with a live key.
Money is integer kobo
Every amount in the API is an integer in kobo: ₦1.00 = 100. 250_000 is ₦2,500 — not ₦250,000. No floats, no decimal strings, currency is always "NGN". Multiply naira by 100 exactly once, at the edge of your system; every money field is suffixed InKobo so a mixup is hard to type.
Pagination
Every list() works three ways:
Errors are a feature
Failures throw typed exceptions carrying everything the API said — the stable errorCode to branch on, a hint telling you exactly what to do next (folded into the message), a docUrl into the error reference, per-field details on validation failures, and the requestId to quote to support:
PHP's
\Exceptionreserves$codefor its own numeric code, so the machine-readable error code is on$e->errorCode. Compare it against theNombaOne\ErrorCodeconstants.
| Status | Exception | Notes |
|---|---|---|
| 400 | BadRequestException |
malformed request |
| 401 | AuthenticationException |
missing / invalid / wrong-environment key |
| 403 | PermissionDeniedException |
missing scope, foreign resource |
| 404 | NotFoundException |
wrong id or wrong environment |
| 409 | ConflictException |
state conflicts, idempotency reuse |
| 422 | ValidationException |
$e->fields has the per-field messages |
| 429 | RateLimitException |
$e->retryAfter, $e->limit, $e->remaining |
| 5xx | ServerException |
safe to retry (the SDK already did) |
| — | ConnectionException / TimeoutException |
transport-level |
All of these extend NombaOne\Exceptions\ApiException (except the transport ones), which extends NombaOne\Exceptions\NombaOneException — catch the base to handle any SDK error.
Idempotency & retries
The SDK auto-generates an Idempotency-Key for every POST and reuses it across its automatic retries (network failures, timeouts, 408/429/5xx, and its own in-flight idempotency conflict — 2 retries by default, honoring Retry-After), so a blip can never double-charge. Pass your own key when the operation must stay idempotent across process restarts:
Payouts: the
Idempotency-Keydoubles as the payout's durablemerchantTxRef. Always pass an explicit, stable key (e.g. your own payout id) — an auto-generated key protects SDK-level retries, but a brand-new process retrying with a fresh key would create a second payout.
Every method also accepts a per-call options array as its final argument: idempotencyKey, headers, timeout (seconds), maxRetries.
Webhooks
Verify before you parse, and dedupe on the event id — delivery is at-least-once, never exactly-once. The helper needs only the signing secret, never an API key:
constructEvent checks the X-Nombaone-Signature (t=<unix>,v1=<hex>, HMAC-SHA256 over "{t}.{rawBody}") in constant time, rejects stale timestamps (300s tolerance, configurable), and accepts multiple v1= pairs so secret rotation never drops a delivery. generateTestHeader() lets you unit-test your handler.
Capture the raw body before your framework parses it:
| Framework | Raw body |
|---|---|
| Laravel | $request->getContent() |
| Symfony | $request->getContent() |
| Slim / PSR-7 | (string) $request->getBody() |
| Plain PHP | file_get_contents('php://input') |
Manage endpoints via $nomba->webhookEndpoints (create/rotate return the secret exactly once).
The full surface
customers (+credit, discount) · plans (+nested prices) · prices · subscriptions (pause/resume/cancel/resubscribe/change, schedule, dunning, upcoming invoice, events) · invoices · coupons · paymentMethods (hosted-checkout cards, virtual accounts) · mandates (NIBSS direct debit) · settlements (escrow, refunds, payouts) · webhookEndpoints (+deliveries, replay) · events (+catalog) · organization (+billing policy) · metrics · sandbox — every operation in the API reference, 1:1.
Worth knowing:
- Mandates are asynchronous. They start
consent_pendingand activate when the customer's bank confirms — listen forpayment_method.updated, don't poll, don't charge early. - Bank transfer is a push rail.
paymentMethods->createVirtualAccount()issues a NUBAN; collection completes when the transfer arrives and reconciles. past_dueis not canceled. Readsubscriptions->dunning->retrieve()and honorgraceAccessUntilbefore cutting anyone off. Involuntary churn isstatus: canceledwithcancellationReason: involuntary.- Some request filters use
…Ref, not…Id. Prices filter byplanRef; payment-methods and mandates takecustomerRef. The SDK mirrors these wire names faithfully.
Configuration
$apiKey defaults to NOMBAONE_API_KEY. You can also pass a single options array: new Nombaone(['apiKey' => …, 'timeout' => 10]). Read-only $nomba->mode and $nomba->baseUrl reflect the resolved environment.
Examples & development
Runnable scripts live in examples/ — quickstart, pagination, the subscription lifecycle, a webhook receiver, and a dunning rehearsal with the test clock. To develop the SDK itself:
Requirements & versioning
PHP ≥ 8.2 (tested on 8.2, 8.3, 8.4). Semantic versioning; the API itself is versioned at /v1 and additive changes never break you. MIT licensed. Copyright © Nomba One.
All versions of nombaone-php with dependencies
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
php-http/discovery Version ^1.19