class ReceiveMoney extends Transaction (View source)

Class ReceiveMoney

This class encapsulates and implements an expressive API using a set of methods to implement the required properties to place a call to the Hubtel Server in order to receive money from a customer.

Traits

Trait MassAssignable
This trait encapsulates the accessor required to create a new transaction instance
Trait CanCleanParameters

Properties

protected ConfigInterface $config The Config repository instance. from Api
protected string $baseUrl The Default Hubtel Base url for merchant payment from Api
protected Response $response This is the response received from the hubtel server if no exception was thrown. from Api
protected string $customerName The name of the customer. from Transaction
protected string $customerEmail The customer email address from Transaction
protected string $customerMsisdn The customer mobile money number. from Transaction
protected string $channel The mobile money provider channel from Transaction
protected string $amount The mobile money transaction amount from Transaction
protected string $primaryCallbackURL A callback URL to receive the transaction status from Hubtel to your API request. from Transaction
protected string $secondaryCallbackURL The second URL for callback response in the event of failure of primary callback URL. from Transaction
protected string $clientReference The reference number that is provided by you to reference a transaction from your end. from Transaction
protected string $description The short description of the transaction. from Transaction
protected $parametersRequired {@inheritdoc}
protected $parametersOptional {@inheritdoc}
protected string $token The 6 digit unique token required to debit a Vodafone Cash customer. This token has to be generated and provided by the Vodafone customer. The customer dials *110# and selects menu item 6 to create the voucher. It expires after 5 minutes if unused
protected boolean $feesOnCustomer This allows the fees of the transaction to be charged on the customer. If set to true the AmountCharged = Amount + Charges.

Methods

void
__construct(array $data = [])

Construct for creating a new instance of the ReceiveMoney Api class

Api
injectConfig(Config $config)

Injects the configuration tot he Api Instance

from Api
Api
setBaseUrl(string $baseUrl)

Change the Default baseUrl defined by hubtel

from Api
string
getBaseUrl()

Get the Hubtel payment Base Url from the Api Instance

from Api
array
_get(string $url = null, array $parameters = [])

Send a GET request.

from Api
array
_head(string $url = null, array $parameters = [])

Send a HEAD request.

from Api
array
_delete(string $url = null, array $parameters = [])

Send a DELETE request.

from Api
array
_put(string $url = null, array $parameters = [])

Send a PUT request.

from Api
array
_patch(string $url = null, array $parameters = [])

Send a PATCH request.

from Api
array
_post(string $url = null, array $parameters = [])

Send a POST request.

from Api
array
_options(string $url = null, array $parameters = [])

Send an OPTIONS request.

from Api
array
execute(string $httpMethod, string $url, array $parameters = [])

Executes the HTTP request.

from Api
Client
getClient()

Returns an Http client instance.

from Api
HandlerStack
createHandler(Config $config)

Create the client handler.

from Api
getConfig()

No description

from Api
Api
setConfig(ConfigInterface $config)

No description

from Api
string
getCustomerName()

returnes the name of the give customer

setCustomerName(string $customerName)

Sets the name of the customer.

string
getCustomerEmail()

get the customer's email address.

setCustomerEmail(string $customerEmail)

sets the customer's email address.

string
getCustomerMsisdn()

gets the msisdn (Customer's phone number)

setCustomerMsisdn(string $customerMsisdn)

Sets the customer's phone number to be billed or funded.

string
getChannel()

returns the transaction channel (Mobile Network)

setChannel(string $channel)

sets the transaction channel (Mobile Network)

string
getAmount()

Gets the money value for the transaction.

setAmount(string $amount)

sets the money value (Amount) to be sent or received

string
getPrimaryCallbackURL()

Returns the primary callback URL that has been set on the instance.

setPrimaryCallbackURL(string $primaryCallbackURL)

set the callback url to callback if the transaction was successful.

string
getSecondaryCallbackURL()

Returns the callback url on the transaction

setSecondaryCallbackURL(string $secondaryCallbackURL)

Sets the URL to call back if he transaction is unsuccesful.

string
getClientReference()

get the transaction reference.

setClientReference(string $clientReference)

Set's a reference on the transaction for easy identification and transaction tracking.

string
getDescription()

gets the description of the transaction.

setDescription(string $description)

sets a description for the transaction.

setCustomer(array $data = [])

This function sets the customer data (name, email and msisdn|number|phone)

callback(string $primaryCallbackURL)

This method sests a single callback for both the success and Error

setCallback(array|string $data = [])

This method sets the callbacks for the Hubtel Payments

callbackOnFail(string $secondaryCallbackURL)

Sets the URL to call when the payment fails or is unsuccessfull

callbackOnSuccess(string $primaryCallbackURL)

Set the URL to call when the payment is been confirmed successful (requred by the Hubtel ReceiveMoney Api)

make(array $data = [])

This method exposes the mass assignment method.

massAssign(array $data = [])

This method is used to mass assign the properties required by the Hubtel ReceiveMoney and SendMoney Api

assignOnSendMoneyInstance($data = [])

No description

assignOnReceiveMoneyInstance($data = [])

No description

amount(float|number $amount)

This method serves as an entry to a transaction class instane. It creates a new transaction class by first starting with the required amount value of the transaction to be created.

channel(string $channel)

Sets the channel (Mobile Network) (requred by the Hubtel ReceiveMoney|SendMoney Api)

static Transactable
__callStatic(string $method, array $parameters)

Dynamically handle missing Static Api Call to Amount.

__call(string $method, array $parameters)

Dynamically handle missing public method call on Amount.

bool
propertiesPassRequired()

This method checks that all properties marked as required have been assigned a value.

array
propertiesToArray()

This method picks up all the defined properties the $parameterRequired|$parameterOptional property array list from the class object and returns an array containing each list item name as a key and the matching property value from the class

mixed
accessPropertyByKey(string $key)

This method calls the accessors for keys passed in and returns back the value it receives from the class instance

from(string $customerMsisdn)

The phone number of the customer you want to bill (Send Pompt) (requred by the Hubtel ReceiveMoney Api)

description(string $description)

Set the description of the transaction (requred by the Hubtel ReceiveMoney Api)

reference(string|number $reference)

Sets a reference to reference a transaction from your end.

customerName(string $customerName)

Sets the customer name as required by the Hubtel Receive Api (requred by the Hubtel ReceiveMoney Api)

customerEmail(string $customerEmail)

Sets the customer email (Optional)

token(string $token)

Sets the 6 digit unique token required to debit a Vodafone Cash

feesOnCustomer(boolean $feesOnCustomer)

Sets if the hubtel and mobile money fees is charged on the customer or client

string
getToken()

No description

setToken(string $token)

No description

boolean
isFeesOnCustomer()

No description

boolean
getFeesOnCustomer()

No description

setFeesOnCustomer(boolean $feesOnCustomer)

No description

Object
run()

The method runs the transaction

Details

void __construct(array $data = [])

Construct for creating a new instance of the ReceiveMoney Api class

Parameters

array $data An array with configurations for the receive money class

Return Value

void

in Api at line 69
Api injectConfig(Config $config)

Injects the configuration tot he Api Instance

Parameters

Config $config

Return Value

Api

in Api at line 79
Api setBaseUrl(string $baseUrl)

Change the Default baseUrl defined by hubtel

Parameters

string $baseUrl The hubtel Resource Base URL

Return Value

Api

in Api at line 90
string getBaseUrl()

Get the Hubtel payment Base Url from the Api Instance

Return Value

string

in Api at line 97
array _get(string $url = null, array $parameters = [])

Send a GET request.

Parameters

string $url
array $parameters

Return Value

array

array _head(string $url = null, array $parameters = [])

Send a HEAD request.

Parameters

string $url
array $parameters

Return Value

array

array _delete(string $url = null, array $parameters = [])

Send a DELETE request.

Parameters

string $url
array $parameters

Return Value

array

array _put(string $url = null, array $parameters = [])

Send a PUT request.

Parameters

string $url
array $parameters

Return Value

array

array _patch(string $url = null, array $parameters = [])

Send a PATCH request.

Parameters

string $url
array $parameters

Return Value

array

array _post(string $url = null, array $parameters = [])

Send a POST request.

Parameters

string $url
array $parameters

Return Value

array

array _options(string $url = null, array $parameters = [])

Send an OPTIONS request.

Parameters

string $url
array $parameters

Return Value

array

array execute(string $httpMethod, string $url, array $parameters = [])

Executes the HTTP request.

Parameters

string $httpMethod
string $url
array $parameters

Return Value

array

protected Client getClient()

Returns an Http client instance.

Return Value

Client

protected HandlerStack createHandler(Config $config)

Create the client handler.

Parameters

Config $config

Return Value

HandlerStack

ConfigInterface getConfig()

Return Value

ConfigInterface

Api setConfig(ConfigInterface $config)

Parameters

ConfigInterface $config

Return Value

Api

string getCustomerName()

returnes the name of the give customer

Return Value

string the customer name

Transaction setCustomerName(string $customerName)

Sets the name of the customer.

Parameters

string $customerName

Return Value

Transaction

string getCustomerEmail()

get the customer's email address.

Return Value

string

Transaction setCustomerEmail(string $customerEmail)

sets the customer's email address.

Parameters

string $customerEmail

Return Value

Transaction

string getCustomerMsisdn()

gets the msisdn (Customer's phone number)

Return Value

string

Transaction setCustomerMsisdn(string $customerMsisdn)

Sets the customer's phone number to be billed or funded.

Parameters

string $customerMsisdn

Return Value

Transaction

string getChannel()

returns the transaction channel (Mobile Network)

Return Value

string

abstract MassAssignable setChannel(string $channel)

sets the transaction channel (Mobile Network)

Parameters

string $channel

Return Value

MassAssignable

string getAmount()

Gets the money value for the transaction.

Return Value

string

abstract MassAssignable setAmount(string $amount)

sets the money value (Amount) to be sent or received

Parameters

string $amount

Return Value

MassAssignable

string getPrimaryCallbackURL()

Returns the primary callback URL that has been set on the instance.

Return Value

string

Transaction setPrimaryCallbackURL(string $primaryCallbackURL)

set the callback url to callback if the transaction was successful.

Parameters

string $primaryCallbackURL

Return Value

Transaction

string getSecondaryCallbackURL()

Returns the callback url on the transaction

Return Value

string

Transaction setSecondaryCallbackURL(string $secondaryCallbackURL)

Sets the URL to call back if he transaction is unsuccesful.

Parameters

string $secondaryCallbackURL

Return Value

Transaction

string getClientReference()

get the transaction reference.

Return Value

string

abstract MassAssignable setClientReference(string $clientReference)

Set's a reference on the transaction for easy identification and transaction tracking.

Parameters

string $clientReference

Return Value

MassAssignable

string getDescription()

gets the description of the transaction.

Return Value

string

abstract MassAssignable setDescription(string $description)

sets a description for the transaction.

Parameters

string $description

Return Value

MassAssignable

abstract MassAssignable setCustomer(array $data = [])

This function sets the customer data (name, email and msisdn|number|phone)

Parameters

array $data Customer data

Return Value

MassAssignable

Transaction callback(string $primaryCallbackURL)

This method sests a single callback for both the success and Error

Parameters

string $primaryCallbackURL A url for callbacks from the hubtel server

Return Value

Transaction

abstract MassAssignable setCallback(array|string $data = [])

This method sets the callbacks for the Hubtel Payments

Parameters

array|string $data

Return Value

MassAssignable

Transaction callbackOnFail(string $secondaryCallbackURL)

Sets the URL to call when the payment fails or is unsuccessfull

Parameters

string $secondaryCallbackURL Url to call is payment is unsuccessful

Return Value

Transaction

Transaction callbackOnSuccess(string $primaryCallbackURL)

Set the URL to call when the payment is been confirmed successful (requred by the Hubtel ReceiveMoney Api)

Parameters

string $primaryCallbackURL Url to callback when payment is successful

Return Value

Transaction

MassAssignable make(array $data = [])

This method exposes the mass assignment method.

Parameters

array $data

Return Value

MassAssignable

protected MassAssignable massAssign(array $data = [])

This method is used to mass assign the properties required by the Hubtel ReceiveMoney and SendMoney Api

Parameters

array $data

Return Value

MassAssignable

protected assignOnSendMoneyInstance($data = [])

Parameters

$data

protected assignOnReceiveMoneyInstance($data = [])

Parameters

$data

protected Transactable amount(float|number $amount)

This method serves as an entry to a transaction class instane. It creates a new transaction class by first starting with the required amount value of the transaction to be created.

(required by the Hubtel ReceiveMoney Api)

Parameters

float|number $amount the actual money value of the transaction being created

Return Value

Transactable

Transactable channel(string $channel)

Sets the channel (Mobile Network) (requred by the Hubtel ReceiveMoney|SendMoney Api)

Parameters

string $channel The mobile network channel (example: mtn-gh)

Return Value

Transactable

static Transactable __callStatic(string $method, array $parameters)

Dynamically handle missing Static Api Call to Amount.

Parameters

string $method
array $parameters

Return Value

Transactable

Exceptions

BadMethodCallException

Transactable __call(string $method, array $parameters)

Dynamically handle missing public method call on Amount.

Parameters

string $method
array $parameters

Return Value

Transactable

Exceptions

BadMethodCallException

protected bool propertiesPassRequired()

This method checks that all properties marked as required have been assigned a value.

A protected $parametersRequired property must contain the names of the required parameters on the class that will use this trait method. and all parameters must each have a defined get accessor on the class object instance

Return Value

bool

Exceptions

MissingParameterException

protected array propertiesToArray()

This method picks up all the defined properties the $parameterRequired|$parameterOptional property array list from the class object and returns an array containing each list item name as a key and the matching property value from the class

Return Value

array An array of parameters with values

protected mixed accessPropertyByKey(string $key)

This method calls the accessors for keys passed in and returns back the value it receives from the class instance

throws an error if a defined parameter in the $parameterRequired|$parameterOptional does not have a reachable get[PropertyName] accessor defined on the class instance.

Parameters

string $key /$parameterRequired[()]|$parameterOptional[()]/

Return Value

mixed

Exceptions

BadMethodCallException

protected ReceiveMoney from(string $customerMsisdn)

The phone number of the customer you want to bill (Send Pompt) (requred by the Hubtel ReceiveMoney Api)

Parameters

string $customerMsisdn This is the Customer Msisdn

Return Value

ReceiveMoney

ReceiveMoney description(string $description)

Set the description of the transaction (requred by the Hubtel ReceiveMoney Api)

Parameters

string $description The description of the transaction

Return Value

ReceiveMoney

ReceiveMoney reference(string|number $reference)

Sets a reference to reference a transaction from your end.

Parameters

string|number $reference the reference number

Return Value

ReceiveMoney

ReceiveMoney customerName(string $customerName)

Sets the customer name as required by the Hubtel Receive Api (requred by the Hubtel ReceiveMoney Api)

Parameters

string $customerName The full name of the customer being charged

Return Value

ReceiveMoney

ReceiveMoney customerEmail(string $customerEmail)

Sets the customer email (Optional)

Parameters

string $customerEmail The email of the customer to be charged

Return Value

ReceiveMoney

ReceiveMoney token(string $token)

Sets the 6 digit unique token required to debit a Vodafone Cash

Parameters

string $token the 6 digit unique token required to debit a Vodafone Cash

Return Value

ReceiveMoney

ReceiveMoney feesOnCustomer(boolean $feesOnCustomer)

Sets if the hubtel and mobile money fees is charged on the customer or client

Parameters

boolean $feesOnCustomer If the arguement is not passed in, fees will be charged on customer

Return Value

ReceiveMoney

string getToken()

Return Value

string

ReceiveMoney setToken(string $token)

Parameters

string $token

Return Value

ReceiveMoney

boolean isFeesOnCustomer()

Return Value

boolean

boolean getFeesOnCustomer()

Return Value

boolean

ReceiveMoney setFeesOnCustomer(boolean $feesOnCustomer)

Parameters

boolean $feesOnCustomer

Return Value

ReceiveMoney

Object run()

The method runs the transaction

Return Value

Object