Download the PHP package sirmekus/ego without Composer

On this page you can find all versions of the php package sirmekus/ego. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ego

About Ego

Ego ("money") is an all-in-one payment gateway library for the PHP (Laravel) community. It is designed to bring together all the possible payment gateways under one "umbrella" via a defined set of interfaces covering regular/day-to-day business/user goals.

With this library, you don't need to worry about switching between different payment gateways; just check it up here, and if it's available, via the guaranteed set of interfaces, use it straight away as it covers simple everyday use cases.

Note that the expected parameters required by your gateway of choice, when making a request via this package, should be sent as well.

For something more complex, you should consider using your preferred gateway's SDK (if available), extending our implementation, or creating a new implementation entirely for your use.

For this, I strongly encourage contributions, please. If you have ever worked with/on a particular payment gateway, please contribute by adding it here for other developers to use. Thank you.

Table of Contents

This documentation will constantly be updated as more interfaces/methods or payment gateways are added.

Getting Started

Install the package like so:

This library obscures the underlying payment gateway by providing, instead, a "factory" for you to interact with. This "factory" also contains the common methods (interface) all the available payment gateways (here) should have, so you can still interact with the payment gateway.

To publish the default config file to customize, run:

Example usage:

The PaymentFactory class accepts two optional parameters:

If none is specified, the default — gotten from the config file — is used.

Available Interface Methods

All of these methods are guaranteed to be accessible regardless of the payment gateway in use. However, you should know what payload parameters your chosen payment gateway expects and pass them when necessary.

Instead of manually crafting parameters, you can "build" them. For example, if your payment gateway expects: amount, currency, metadata, and reference, you can build them like so:

Methods starting with the set keyword are 'magical' and represent a payload item. The parameter acts as the value. When pay() or transfer() is called without any parameter, it takes from the payload already built using the magic methods.

Alternatively, if you already have an array (say from submitted form data), instead of building the payload manually, you can dump it into the library via prepareForPayment() or prepareForTransfer() and the library will automatically build it for you. Even if the array is nested, it will fetch the first matching key/value pair required to create a request payload. This means a model (cast to an array) can be passed to it as well.

NB: How the payload is built is dependent on the underlying payment gateway. A gateway may require 5 parameters while the contributor of that particular gateway (in this package) may only cater for 2 in prepareForPayment() or prepareForTransfer(). If the remaining parameters are important, it is recommended you set the payload manually instead.

Example:

The method will extract the minimal request parameters (or payload) needed to interact with the API endpoint of your preferred service provider or payment gateway.

Accessing Gateway-Specific Methods

If you need to call a method on the underlying gateway that is not part of the general interface, you can access the gateway instance directly:

Swapping Gateway Implementations

If you have a gateway class with custom logic, you can swap our implementation with yours in the providers section of the ego.php config file. It must implement PaymentGatewayInterface. One way to do it is to extend our class and override the methods you need.

Config File Structure

The typical structure of the ego.php config file is shown below. After publishing it, add the relevant environment variables to your .env file.


Available (Underlying) Payment Gateway(s)

Paystack

Once you know the typical request parameters expected by Paystack, you can plug them in directly into the appropriate method discussed above and use it straight away.

The following methods are available for Paystack in this package:

Paystack Special Cases

Case 1: Payment payload fields

When using prepareForPayment($array), the following will be extracted from the array passed in as a parameter:

When using prepareForTransfer($array), the following will be extracted:

Case 2: Authorization URL vs Authorization Code

On Paystack, you can charge customers by directing them to an authorization URL or by charging them directly via an authorization code. You don't need to worry about these details when using this package — the pay() method handles both.

To charge a customer via an authorization code, include a key named authorization_code in your payload/array. The default behaviour (when no authorization code is present) is to create a checkout link and redirect the user.

Case 3: Transfers

On Paystack, making a transfer/withdrawal to a bank account requires first creating a transfer recipient, which generates a unique code used to initiate the transfer.

This process is handled automatically when you use the transfer() method - you don't need to worry about it.

However, if you already have a transfer recipient code, simply include it in your payload as recipient_code and the package will skip the recipient creation step and initiate the transfer directly.


Flutterwave

Once you know the typical request parameters required by Flutterwave, you can plug them in directly into the appropriate method and use it straight away.

The following methods are available for Flutterwave in this package:

When using prepareForPayment($array), the following will be extracted:


Stripe

Once you know the typical request parameters required by Stripe, you can plug them in directly into the appropriate method and use it straight away.

The following methods are available for Stripe in this package:

Stripe Special Cases

Case 1: Payment payload fields

When using prepareForPayment($array), the following will be extracted:

Case 2: Transfers

Stripe transfers are sent to connected Stripe accounts (not directly to bank accounts). You must provide a destination (or destination_id) in your payload, which is the ID of the connected Stripe account to transfer funds to.

Case 3: Webhook verification

Stripe webhook verification requires a signing_secret configured in ego.credentials.stripe.signing_secret. Set the STRIPE_SIGNING_SECRET environment variable to the signing secret from your Stripe dashboard.


Nomba

Nomba is a Nigerian payment infrastructure provider. Once you know the typical request parameters it expects, you can plug them in directly and use it straight away.

The following methods are available for Nomba in this package:

Nomba Configuration

Add the following environment variables to your .env file:

All five values can be found in or generated from your Nomba Dashboard.

Variable Description
NOMBA_CLIENT_ID Your OAuth2 client ID
NOMBA_SECRET_KEY Your OAuth2 client secret
NOMBA_ACCOUNT_ID Your Nomba parent account ID
NOMBA_SIGNATURE_KEY The secret key used to verify incoming webhook payloads
NOMBA_BASE_URL The Nomba API base URL (e.g. https://api.nomba.com/v1/)

Nomba Authentication

Nomba uses OAuth2 client credentials for authentication. The package handles this automatically - you do not need to manage tokens yourself. When a request is made, the package:

  1. Checks Laravel's cache for a valid access token.
  2. If none exists (or it has expired), it requests a new one from Nomba using your client_id and secret_key.
  3. Caches the new token for slightly less than its TTL to avoid edge-case expiry.

This means your app stays authenticated transparently across requests with zero manual token management.

Nomba Special Cases

Case 1: Payment payload fields

When using prepareForPayment($array), the following will be extracted:

Key(s) in your array Description
email Customer's email address
customerId / customer_id / email Customer identifier (falls back to email if absent)
amount Amount to charge
currency Currency code (e.g. NGN)
reference Your unique order reference
callback_url / callbackUrl URL to redirect to after payment
token Tokenized card key (triggers direct card charge)
tokenize Whether to tokenize the card — defaults to true

Case 2: Authorization URL vs Tokenized Card Payment

Similar to Paystack, Nomba supports two payment flows:

The pay() method handles both flows automatically. The presence of a token in the payload is what triggers the direct charge.

Case 3: Verifying Payments

verifyPayment() accepts an optional $paymentType parameter to distinguish between different transaction types:

$paymentType value Description
transaction or deposit Verify a customer payment/deposit
transfer or bank_transfer Verify an outbound bank transfer

The returned array has the following structure:

Case 4: Transfers

When using prepareForTransfer($array), the following will be extracted:

Key(s) in your array Description
accountNumber / account_number Recipient's bank account number
amount Amount to transfer
accountName / account_name Recipient's account name
bankCode / bank_code Recipient's bank code
narration / description Transfer narration
senderName / sender_name Name of the sender
merchantTxRef / reference Your unique transaction reference

Case 5: Account Number Lookup

Before making a transfer, you can verify a bank account number to confirm the account name:

Both accountNumber and bankCode are required. An exception is thrown if either is missing.

Case 6: Webhook Verification

Nomba signs its webhook payloads using HMAC-SHA256. The package verifies the signature automatically when you call verifyWebhook(). Ensure NOMBA_SIGNATURE_KEY is set in your .env file — this is the webhook signing secret from your Nomba dashboard.

The verification process:

  1. Extracts key fields from the webhook payload (event_type, requestId, merchant and transaction details).
  2. Concatenates them with the nomba-timestamp header value.
  3. Computes an HMAC-SHA256 hash using your signature key and compares it against the nomba-signature header.

If the signatures do not match, an ApiException is thrown.


BudPay

BudPay lets you accept payments, verify transactions, validate bank accounts, and make single or bulk payouts. Once you know the typical request parameters required by BudPay, you can plug them into the appropriate method and use it straight away.

The following methods are available for BudPay in this package:

BudPay Configuration

Add the following environment variables to your .env file:

You can get these values from your BudPay dashboard API credentials section.

Variable Description
BUDPAY_SECRET_KEY Secret key used for Bearer-token authentication against BudPay API requests
BUDPAY_PUBLIC_KEY Public key used by this package to sign payout request payloads

BudPay Authentication

BudPay authenticates API requests with your secret key as a Bearer token. The package handles this automatically through the configured BUDPAY_SECRET_KEY.

For payout endpoints, BudPay also requires an HMAC-SHA-512 value in the Encryption header. The package automatically sorts the payout payload, signs it with BUDPAY_PUBLIC_KEY, and adds the Encryption header when you call transfer().

BudPay Special Cases

Case 1: Payment payload fields

BudPay Standard creates a hosted checkout URL by initializing a transaction. When using prepareForPayment($array), the following will be extracted:

Key(s) in your array Description
email Customer's email address
amount Amount to charge
currency Currency code, for example NGN
first_name / firstName Customer's first name
last_name / lastName Customer's last name
reference Your unique transaction reference
callback / callbackUrl / callback_url URL BudPay redirects to after payment

Case 2: Verifying Payments

BudPay payment verification uses the transaction reference. verifyPayment() accepts a string reference or an array containing reference, data.reference, or transferDetails.paymentReference.

If you pass the optional $paymentType, it must be transaction or payout. null or leaving it empty defaults to transaction:

Case 3: Banks and Account Number Lookup

You can fetch the full BudPay bank list with getBanks() or fetch banks for a specific currency with getBanksByCurrency(). BudPay currently documents bank-list support for currencies such as NGN, USD, GHS, and KES.

or

Before making a payout, you can verify the recipient's account name:

Case 4: Transfer payload fields

BudPay supports single payouts to bank accounts. When using prepareForTransfer($array), the following will be extracted:

Key(s) in your array Description
currency Transfer currency, for example NGN, KES, or GHS
amount Transfer amount
account_number Recipient's bank account number
bank_code Recipient's bank code from BudPay's bank list
bank_name Recipient's bank name
narration Transfer narration or purpose
meta_data Optional additional transfer metadata
payment_mode Optional payment mode; useful for supported markets

Case 5: Transfer Fees and Bulk Transfers

BudPay lets you calculate payout fees before sending money:

or

For bulk payouts, prepare a currency and an array of transfer items, then call prepareForTransfer() and transfer():

Case 6: Verifying Transfers

Single and bulk payouts can be verified with the BudPay payout reference returned by the transfer response:

Case 7: Webhook Verification

BudPay webhook verification in this package verifies the webhook by calling BudPay's API again and comparing the webhook reference and status with the verified response. The incoming request must be a POST, include a supported notify value (transaction, virtual_account, or payout), and contain a reference in data.reference, transferDetails.paymentReference, or reference.

For payout notifications, the package calls verifyPayment() with the payout route. For other supported notifications, it calls verifyPayment() for transaction verification. If the verified reference or status does not match the webhook payload, the request is rejected.


Webhook Strategy

Since this package implements a method that verifies webhook requests/payloads, one way of using the same route for all supported payment gateways is shown below:

Step 1: Create a dynamic route

The value assigned to the dynamic part of the URL above should match any of the supported payment gateways listed in the providers section of your ego.php config file.

Step 2: Handle the payload

With this, you have a single route that can handle any webhook. If you move from Gateway A to B, you won't have to create a new route or implement new gateway-specific handling.


Contributing

Please check the 'contrib' directory for more information. I really appreciate you for doing this.


All versions of ego with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sirmekus/ego contains the following files

Loading the files please wait ...