djunehor/laravel-vtu

Purchase airtime, data plan and pay utility bills

dev-master 2020-01-13 17:06 UTC

This package is auto-updated.

Last update: 2024-10-09 14:47:06 UTC


README

CircleCI Latest Stable Version Total Downloads License Build Status Scrutinizer Code Quality Code Coverage

Laravel VTU allows you to buy airtime and data plan, as well as pay for utility bill from your Laravel application using one of over 3 vtu providers, or your own vtu provider.

Installation

Step 1

You can install the package via composer:

composer require djunehor/laravel-vtu

Laravel 5.5 and above

The package will automatically register itself, so you can start using it immediately.

Laravel 5.4 and older

In Laravel version 5.4 and older, you have to add the service provider in config/app.php file manually:

'providers' => [
    // ...
    Djunehor\Vtu\VtuServiceProvider::class,
];

Lumen

After installing the package, you will have to register it in bootstrap/app.php file manually:

// Register Service Providers
    // ...
    $app->register(Djunehor\Vtu\VtuServiceProvider::class);
];

Env Keys

VOICE_AND_TEXT_TOKEN
VOICE_AND_TEXT_CALLBACK

COWRIESYS_CLIENT_ID
COWRIESYS_CLIENT_KEY

VTPASS_USERNAME
VTPASS_PASSWORD

FPEVTU_USERNAME
FPEVTU_PASSWORD

UNIK_MOBILE_USERNAME
UNIK_MOBILE_PASSWORD

MOBILE_AIRTIME_USERNAME
MOBILE_AIRTIME_PASSWORD

Step 2 - Publishing files

Run: php artisan vendor:publish --tag=laravel-vtu This will move the migration file, seeder file and config file to your app. You can set your sms details in the config file or via env

Step 3 - Adding SMS credentials

  • Add the env keys to your .env file
  • Or edit the config/laravel-vtu.php file

Usage

//using VoiceAndText
use Djunehor\Vtu\Concrete\VoiceAndText;

$vtu = new VoiceAndText();
$amount = 100;
$mobileNumber = '08149659347';
$mobileNetwork = '01';
$callBackUrl = 'http://www.your-website.com';
$send = $vtu->buyAirtime($amount, $mobileNumber, $mobileNetwork, $callBackUrl);

Using Helper function

//VoiceAndtext
$send = buy_airtime($amount, $mobileNumber, $mobileNetwork, $callBackUrl, $token = 121231112, \Djunehor\Vtu\Concrete\VoiceAndText::class);

The default VTU provider is VoiceAndText. You can set the default SMS provider in config/laravel-vtu.php e.g 'default' => \Djunehor\Vtu\Concrete\VoiceAndText::class,, so you can use the helper function like this:

$send = buy_airtime($amount, $mobileNumber, $mobileNetwork);
//$token, $callbackUrl and $class are optional and better set in the config

Available VTU Providers

Creating custom SMS Provider

  • Create a class that extends Djunehor\Vtu\Concrete\Vtu class
  • Implement the required methods (buyAirtime, buyData, PayUtility) which makes the request and return bool
  • (Optional) You can add the provider keys to the config/laravel-vtu.php

Contributing

  • Fork this project
  • Clone your forked repo
  • Run composer install
  • Make your changes and run tests composer test
  • Push and create Pull request