Download the PHP package prinx/sevotransact without Composer

On this page you can find all versions of the php package prinx/sevotransact. 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 sevotransact

Build Status Latest Stable Version License StyleCI

SEVOTRANSACT PHP SDK

Sevotransact Payment Gateway PHP SDK Can be used with your favorite framework or your plain PHP project.

Installation

The package can be installed via composer. Install it if you don't have it yet. Then open a terminal in your project root folder and run:

Usage

First create a .env file in your project root folder, if you don't have any already.

Next, configure the .env by putting your sevotransact credentials and account informations:

The primary and secondary callbacks are URL where SEVOTRANSACT will send the result of the transaction. YOu can check how to handle the transaction callback here.

The secondary callback is optional.

Request a payment

Voucher code

Some networks (typically VODAFONE) require the user to generate a voucher code. This code can be easily passed to the request:

The voucher code is now optional. If not passed, the user will directly receive a prompt on their phone to accept the transaction.

Mobile money request response

The mobile money request will automatically return a response from which you can determine if the request is being processed or not.

WARNING: This response is just to notify you that your request has been received and is been processed or something went wrong when sending the request. This is not the actual response of the mobile money request. The actual response of the mobile money request will be sent to your provided callback URL.

Process callback

The result of the transaction will be sent to the callback URL provided when sending the request. To process the callback, create a new route in your favorite framework, or create an php file in your project to handle the callback. The URL resolving to that route or that file is (must be) the one you provided in the .env. as callback URL.

Now you can create a callback instance that will receive the status of your transactions:

Or if you are using a framework and the callback route is handled by a controller:

We can now register the callback functions that will be run on success, failure or some defined custom condition of the mobile money transaciton. The callback functions will receive the $callback instance.

You are not require to use all the callbacks. Just use the one that is needed.

Now, run everything, by calling the process method on the callback.

The full code will be:

TIP: In case you have only one callback function that will be run whether the transaction is successful or not, you can simply pass the function to the process method:

Successful transaction

The code of the transaction determines if the transaction is successful or has failed. By default, the successful transaction codes are in the array returned by $callback->getSuccessCodes(). You can decide (for any reason it may be) to consider a failure code as success code by adding it to the success codes with the $callback->addSuccessCode($code) method.

The on method

The on method is a powerful way of listening to the transaction request callbacks. It takes as first parameter an array of conditions that can match the request payload and as second parameter a callback function that will be run if the conditions match the payload.

A string can be passed as condition, then it will be considered as the code sent in the payload to the callback URL.

The Callback class implements the fluent interface. You can chain most of its methods (like the on, success, failure methods), in any order.

The callbacks will be run in the order they were registered.

The payload

A payload is sent to the callback URL. It contains 8 parameters:

code

The code of the request.

status

details

The detail message of the status.

id

The transaction ID.

phone

The phone number to which the request was made.

network

The network to which belong the phone number.

amount

The amount of the transaction.

currency

The currency in which the transaction was made.

You can get all the payload array by calling the getPayload method without parameter.

You can also get any of the payload parameters by passing the name of the parameter to the getPayload method, for example:

Message associated to the request

You can get the message associated to the request by calling the message method of the callback instance.

The message is associated to the code in the payload.

Messages

These are the possible messages:

Using the mobile money callback instance in the closure

The callback instance is automatically passed to the closure. You can then use it as below:

Passing other parameter(s) to the closure

You can easily pass other parameters to the closure by using the PHP use keyword on the closure:

Using a class to handle callbacks

Instead of directly passing the callbacks closures to the success, failure or on methods, you can move all the callbacks to a class and just pass the class to the process method.

First, create a class containing a callbacks methods:

The callbacks method must return an array containing the mapping of your conditions with the callback closures:

The mappings can be duplicated:

Or you can rather passed an array of closures:

You can pass the custom conditions success, failure or always:

You can also pass an array of conditions:

All these can be mixed according to your need:

Instead of returning directly closures in the callbacks methods, you can create public methods in the callback handler class and reference those methods in the array returned in the callbacks method:

After writing the callback handler class, you just need to pass it to the process method:

Logging

Logging locally

You can provide a log folder where the transactions will be automatically logged.

If no folder has been set, a default log folder will be created at YOUR_PROJECT_ROOT_FOLDER/storage/logs/sevotransact/.

You can disable local logs by using the env variable (It is enabled by default):

Logging to SLACK

You can provide in your .env file a slack webhook to automatically log transactions to slack.

You can disable logging to SLACK by putting in the .env:

It is enabled by default.

Disable logs

To disable the whole logging system, put in your .env file:

Contribute

Star :star: the repo, fork it, fix a bug, add a new feature, write tests, correct documentation, and submit a pull request.

License

MIT


All versions of sevotransact with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
prinx/dotenv Version ^1.0
prinx/notify Version ^0.0
symfony/http-client Version ^5.1
illuminate/collections Version ^8.16
symfony/http-foundation Version ^5.1
respect/validation Version ^2.2
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 prinx/sevotransact contains the following files

Loading the files please wait ....