Giter Site home page Giter Site logo

ovac / hubtel-payment Goto Github PK

View Code? Open in Web Editor NEW
14.0 5.0 8.0 10.38 MB

๐ŸŽ‰A comprehensive PHP Client Package for consuming the Hubtel Payment API

Home Page: https://www.ovac4u.com/hubtel-payment

License: MIT License

Shell 1.20% PHP 98.80%
mobile-money hubtel-payment hubtel ghana mess-detector phpunit watchr ovac ovac4u mtn

hubtel-payment's Introduction



OVAC Hubtel Payment

The best and most comphrensive PHP Client for consuming the Hubtel Payment API and for sending and receiving Mobile Money Payment from a php application with an elegant Write as it sounds syntax.

Build Status Coverage Status Latest Stable Version Total Downloads License Dependency Status

 Follow me anywhere @ovac4u                         | GitHub
 _________                          _________       | Twitter
|   ___   |.-----.--.--.---.-.----.|  |  |.--.--.   | Facboook
|  |  _   ||  _  |  |  |  _  |  __||__    |  |  |   | Instagram
|  |______||_____|\___/|___._|____|   |__||_____|   | Github + @ovac
|_________|                        www.ovac4u.com   | Facebook + @ovacposts

What is it?

OVAC/Hubtel-Payment is a comphrensive PHP client for consuming the Hubtel Mobile Money Payment server API. It's a full-on PHP toolbet sugar-coated by an elegant syntax directly inspired by the Laravel framework.

It features a good set of methods and tests for accessing the Hubtel Mobile Money Payment with a Write as it sounds syntax. Oh also it is growing all the time.

What's the cherry on top? It wraps nicely around native Guzzlehttp client and uses most of PHP best practices in relation to usability and security. What does this mean? This means that Pay::receiveMoney()->from(0553577261)->run(); actually places a dynamic call behind the scene in a very secure manner using the phone number as the Customer's idn as required by the Hubtel's Mobile Money Receive Money api and prompts the owner of the phone number as an agent.

Install OVAC\Hubtel-Payment

To install OVAC\HubtelPayment library, simply run

$ composer require ovac/hubtel-payment

OVAC\Hubtel-Payment Basic Usage

First Obtain a Hubtel Developer Account Number, ClientID and ClientSecret from https://unity.hubtel.com/account/api-accounts-add

The ReceiveMoney class may be used to send a prompt to the customer's phone to receive money like a mobile-money agent as follows:

<?php
require_once __DIR__ . '/vendor/autoload.php';

use OVAC\HubtelPayment\Config;
use OVAC\HubtelPayment\Api\Transaction\ReceiveMoney;

// First Create configuration with your Hubtel Developer Credentials
// The Account Number, ClientID and ClientSecret accordingly.
$config = new Config(Account_Nnumber, ClientId, ClientSecret);

$payment =  ReceiveMoney::from('0553577261')          //- The phone number to send the prompt to.
                ->amount(100.00)                    //- The exact amount value of the transaction
                ->description('Online Purchase')    //- Description of the transaction.
                ->customerName('Ariama Victor')     //- Name of the person making the payment.
                ->callback('http://ovac4u.com/pay') //- The URL to send callback after payment.	
                ->channel('mtn-gh')                 //- The mobile network Channel.
                ->injectConfig($config)             //- Inject the configuration
                ->run();                            //- Run the transaction after required data.

The SendMoney class may also be used to send money to any mobile money customer as follows:

<?php
require_once __DIR__ . '/vendor/autoload.php';

use OVAC\HubtelPayment\Config;
use OVAC\HubtelPayment\Api\Transaction\SendMoney;

// First Create configuration with your Hubtel Developer Credentials
// The Account Number, ClientID and ClientSecret accordingly.
$config = new Config(Account_Nnumber, ClientId, ClientSecret);

$payment = SendMoney::to('0553577261')                //- The phone number to send the prompt to.
                ->amount(100.00)                    //- The exact amount value of the transaction
                ->description('Online Purchase')    //- Description of the transaction.
                ->customerEmail('[email protected]') //- Name of the person making the payment.
                ->callback('http://ovac4u.com/pay') //- The URL to send callback after payment.	
                ->channel('mtn-gh')                 //- The mobile network Channel.
                ->injectConfig($config)             //- Inject the configuration
                ->run();                            //- Run the transaction after required data.

The Refund class may also refund money a customer paid in a previous transaction:

<?php
require_once __DIR__ . '/vendor/autoload.php';

use OVAC\HubtelPayment\Config;
use OVAC\HubtelPayment\Api\Transaction\Refund;

// First Create configuration with your Hubtel Developer Credentials
// The Account Number, ClientID and ClientSecret accordingly.
$config = new Config(Account_Nnumber, ClientId, ClientSecret);

$payment = Refund::transactionId(1234)              //- The ID of the transaction to refund.
                ->amount(100.00)                    //- The exact amount value of the transaction
                ->clientReference('#11212')         //- A refeerence on your end.
                ->description('Useless Purchase')   //- Description of the transaction.
                ->reason('No longer needs a pen')   //- Name of the person making the payment.
                ->full()                            //- Full or partial refund.
                ->injectConfig($config)             //- Inject the configuration
                ->run();                            //- Run the transaction after required data.

Documentation

You can find a detailed summary of all classes and methods on the official page. The changelog is available in the CHANGELOG file.

You can find a detailed summary of all classes and methods in the repo's wiki or the official page. The changelog is available in the CHANGELOG file.

Tests

if you have phpunit installed globally

$ vendor/bin/phpunit

or use the composer script

$ composer phpunit

Code analysis tools

lint/checkstyle with phpcs:

$ composer phpcs

mess detector with phpmd:

$ composer phpmd

copy & paste detector with phpcpd:

$ composer phpcpd

phpunit, lint, mess detector in one command:

$ composer test

CI

A simple ci bash script exists under bin folder

$ bin/ci.sh

Contributing

Thank you for considering contributing to Laravel Hackathon Starter. The contribution guide can be found in the Contribution File

Security

If you discover any security related issues, please email instead of using the issue tracker.

Credits

Licence

Reference

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on Twitter or HackerNews? Spread the word!

Don't forget to follow me on instagram and twitter

Thanks! Ariama Victor (ovac4u).

hubtel-payment's People

Contributors

cuteblacky avatar muomaekene avatar ovac avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hubtel-payment's Issues

Error: Cant find merchant account number

Fatal error: Uncaught exception 'OVAC\HubtelPayment\Exception\BadRequestException' with message 'Sorry, we could not find a merchant account with the provided account number.' in C:\xampp56\htdocs\payplugin\wp-content\plugins\give-payment-gateway-slydepay\vendor\ovac\hubtel-payment\src\Exception\Handler.php:98 Stack trace: #0 C:\xampp56\htdocs\payplugin\wp-content\plugins\give-payment-gateway-slydepay\vendor\ovac\hubtel-payment\src\Exception\Handler.php(73): OVAC\HubtelPayment\Exception\Handler->handleException('Sorry, we could...', 400, NULL, '3900', NULL, Array) #1 C:\xampp56\htdocs\payplugin\wp-content\plugins\give-payment-gateway-slydepay\vendor\ovac\hubtel-payment\src\Api\Api.php(160): OVAC\HubtelPayment\Exception\Handler->__construct(Object(GuzzleHttp\Exception\ClientException)) #2 C:\xampp56\htdocs\payplugin\wp-content\plugins\give-payment-gateway-slydepay\vendor\ovac\hubtel-payment\src\Api\Api.php(134): OVAC\HubtelPayment\Api\Api->execute('post', '/receive/mobile...', Array) #3 C:\xampp56\htdocs\payplugin\wp-conte in C:\xampp56\htdocs\payplugin\wp-content\plugins\give-payment-gateway-slydepay\vendor\ovac\hubtel-payment\src\Exception\Handler.php on line 98

I keep getting this error when I try to Receive money. This is a sample of my code

$config = new Config($account_number, $client_id, $client_secret);

$payment =  ReceiveMoney::from('XXXXXXXXXX')          //- The phone number to send the prompt to.
                        ->amount(10)                    //- The exact amount value of the transaction
                        ->description('just testing')    //- Description of the transaction.
                        ->customerName('Kojo')     //- Name of the person making the payment.
                        ->callback('http://mysite.com/process-hubtel-donation') //- The URL to send callback after payment.
                        ->channel('mtn-gh')                 //- The mobile network Channel.
                        ->injectConfig($config)             //- Inject the configuration
                        ->run();                            //- Run the transaction after required data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.