class Transaction extends Api (View source)

Transaction Class

This class encapsulates all the Hubtel Transaction properties required and optional that appears both on the SendMoney and ReceiveMoney requests.

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.
protected string $customerEmail The customer email address
protected string $customerMsisdn The customer mobile money number.
protected string $channel The mobile money provider channel
protected string $amount The mobile money transaction amount
protected string $primaryCallbackURL A callback URL to receive the transaction status from Hubtel to your API request.
protected string $secondaryCallbackURL The second URL for callback response in the event of failure of primary callback URL.
protected string $clientReference The reference number that is provided by you to reference a transaction from your end.
protected string $description The short description of the transaction.
protected array $parametersRequired Defines an array of required properties
protected array $parametersOptional Defines an array of the names of optional properties/parameters names

Methods

void
__construct(Config $config)

Constructor.

from Api
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)

Details

in Api at line 59
void __construct(Config $config)

Constructor.

Parameters

Config $config

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

Transaction setChannel(string $channel)

sets the transaction channel (Mobile Network)

Parameters

string $channel

Return Value

Transaction

string getAmount()

Gets the money value for the transaction.

Return Value

string

Transaction setAmount(string $amount)

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

Parameters

string $amount

Return Value

Transaction

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

Transaction setClientReference(string $clientReference)

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

Parameters

string $clientReference

Return Value

Transaction

string getDescription()

gets the description of the transaction.

Return Value

string

Transaction setDescription(string $description)

sets a description for the transaction.

Parameters

string $description

Return Value

Transaction

Transaction setCustomer(array $data = [])

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

Parameters

array $data Customer data

Return Value

Transaction

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

Transaction setCallback(array|string $data = [])

This method sets the callbacks for the Hubtel Payments

Parameters

array|string $data

Return Value

Transaction

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