1. Go to this page and download the library: Download sirmekus/ego 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/ */
// Sets the configuration/credentials for the underlying payment gateway
public function setKey(string|array $key): void;
// Builds the appropriate payload from an array of values the target gateway expects.
// The underlying payment gateway class determines which fields it extracts.
public function prepareForPayment(array $data): array;
// Builds the appropriate transfer payload from an array of values.
public function prepareForTransfer(array $data): array;
// Initiates a payment or deposit
public function pay(array $array): array;
/**
* Verifies a payment, deposit, or transfer. The return value is dependent on
* the underlying payment gateway.
*
* $paymentType is optional and can be defined by your implementation. Enums are
* intentionally avoided so each implementation can define its own. An error will
* typically be thrown if the payment type is not supported.
*/
public function verifyPayment(array|string $array, ?string $paymentType = null): array;
// Verifies an incoming webhook. If the webhook is valid, execution continues;
// otherwise it fails with a 401/404 response.
public function verifyWebhook(Request $request): void;
// Fetches a list of banks supported by the underlying payment gateway
public function getBanks(string $countryCode = ""): array;
// Verifies an account number
public function verifyAccountNumber(array $request): array;
// Runs a transfer/withdrawal transaction
public function transfer(array $data): array;
// Returns the crafted payload if magic methods were used to build it
public function getPayload(): array;
$paymentFactory = new PaymentFactory();
// Assuming a validated Laravel request
$paymentFactory->prepareForPayment($request->validated());
$response = $paymentFactory->pay();
$paymentFactory = new PaymentFactory();
$gateway = $paymentFactory->getGatewayInstance();
// Now you can use the actual payment gateway class
$gateway->someGatewaySpecificMethod();
// Verify a customer payment
$status = $paymentFactory->verifyPayment('unique-ref-001', 'transaction');
// Verify a bank transfer
$status = $paymentFactory->verifyPayment('unique-ref-002', 'bank_transfer');
[
'status' => 'success' | 'pending' | 'failed',
'message' => 'Transaction description or narration',
'data' => [...], // Full transaction data from Nomba
'reference' => 'order-reference-string',
]
class WebhookController extends Controller
{
public function __invoke(Request $request, string $gateway)
{
$gateway = new PaymentFactory($gateway);
$gateway->verifyWebhook($request);
$payload = $request->json()->all();
// Handle the payload. Ideally, fire an event to avoid blocking
// on long-running tasks.
return response()->json();
}
}