1. Go to this page and download the library: Download nombaone/nombaone-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nombaone / nombaone-php example snippets
use NombaOne\Nombaone;
$nomba = new Nombaone(getenv('NOMBAONE_API_KEY'));
$plan = $nomba->plans->create(['name' => 'Pro']);
$price = $nomba->plans->prices->create($plan->id, [
'unitAmountInKobo' => 250_000, // ₦2,500.00 per month
'interval' => 'month',
]);
$customer = $nomba->customers->create([
'email' => '[email protected]',
'name' => 'Ada Lovelace',
]);
// Sandbox: mint a deterministic test card, then subscribe.
$method = $nomba->sandbox->createPaymentMethod(['customerId' => $customer->id]);
$subscription = $nomba->subscriptions->create([
'customerId' => $customer->id,
'priceId' => $price->id,
'paymentMethodId' => $method->id,
]);
echo $subscription->status; // "active"
// A card that declines like a thin balance does — "not yet", not "no".
$nomba->sandbox->createPaymentMethod([
'customerId' => $customer->id,
'behavior' => 'decline_insufficient_funds', // or success | ebhook at your registered endpoints.
$nomba->sandbox->simulateWebhook(['type' => 'invoice.payment_failed']);
// One page.
$page = $nomba->invoices->list(['status' => 'open', 'limit' => 50]);
$page->data; // list<Invoice>
$page->pagination->hasMore;
$page->pagination->nextCursor;
// Manual paging.
if ($page->hasNextPage()) {
$next = $page->nextPage(); // same filters, next cursor
}
// Or let the SDK thread the cursors — foreach walks every page.
foreach ($nomba->invoices->list(['status' => 'open']) as $invoice) {
// every item across every page; pages are fetched as you consume them
}
use NombaOne\ErrorCode;
use NombaOne\Exceptions\NotFoundException;
use NombaOne\Exceptions\RateLimitException;
use NombaOne\Exceptions\ValidationException;
try {
$nomba->subscriptions->create(['customerId' => $id, 'priceId' => $priceId]);
} catch (ValidationException $e) {
print_r($e->fields); // ['paymentMethodId' => ['Required']]
} catch (RateLimitException $e) {
echo $e->retryAfter; // seconds
} catch (NotFoundException $e) {
if ($e->errorCode === ErrorCode::CUSTOMER_NOT_FOUND) { /* … */ }
}
use NombaOne\Webhooks\Webhooks;
use NombaOne\Webhooks\WebhookEventType;
$webhooks = new Webhooks(); // or $nomba->webhooks
$event = $webhooks->constructEvent(
$rawBody, // the RAW request body — never re-serialize
$signatureHeader, // the `X-Nombaone-Signature` header
getenv('NOMBAONE_WEBHOOK_SECRET'), // shown once when you created the endpoint
);
if ($store->alreadyProcessed($event->dedupeKey())) {
http_response_code(200); // at-least-once ⇒ dedupe on the event id
return;
}
match ($event->type) {
WebhookEventType::INVOICE_PAID => unlock($event->data['reference']),
WebhookEventType::INVOICE_ACTION_REQUIRED => notify($event->data['checkoutLink']),
WebhookEventType::INVOICE_PAYMENT_FAILED => flag($event->data['reason']),
default => null,
};
http_response_code(200); // respond 2xx fast; do heavy work async
new Nombaone($apiKey, [
'baseUrl' => 'https://sandbox.api.nombaone.xyz', // override the derived host
'timeout' => 30.0, // per-attempt seconds
'maxRetries' => 2, // automatic retry budget
'httpClient' => $client, // a NombaOne\Http\HttpClient, or any PSR-18 client
'defaultHeaders' => ['X-My-Tag' => 'checkout'],
]);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.