PHP code example of ovac / hubtel-payment

1. Go to this page and download the library: Download ovac/hubtel-payment 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/ */

    

ovac / hubtel-payment example snippets



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 


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 


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