Skip to content

SendMoney

Ariama Victor (A.K.A. OVAC) edited this page Aug 19, 2017 · 2 revisions

SendMoney

Introduction

The SendMoney class allows you to send money from your php application by providing a fluent syntax for building the query to be sent to the Hubtel's Api.

Before getting started, be sure to have a Config object that will be injected into the instance when it will be executed. Check out this documentation for how to setup the Config

Using the SendMoney Class

The send money api can be consumed using a configuration instance with valid data from an existing Hubtel account.

The SendMoney class exposes several methods that can be chained to each other for fluent configuration.

to() {#collection-method}

The to method can be called statically, thus creates an instance of the send money class. The to method takes the phone number that the money is going to be sent to:

	// Sets the receiver of the funds and returns the sendMoney
	// So that it can be changed to other parameter setup methods.
	$sendMoney = SendMoney::to('0553577261');

Putting it all together.

Putting it all together, we will place a call to the Hubtel Api and return a JSON data or throw an error if it was not successful.

You can checkout the expected response types here.

<?php

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

public function someClass(Config $config)
{
    $sendMoney = SendMoney::to(0553577261)          //- The phone number to send the prompt to.
                ->amount(100.00)                    //- The exact amount value of the transaction
                ->desctiption('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.
                
    $sendMoney->injectConfig($config)               //- Inject the configuration
              ->run();                              //- Run the transaction after required data.
}