Here, createAuthorisationCode(['identifierType' => 'identifier'], $authorisationObj) creates a POST request to /accounts/{identifierType}/{identifier}/authorisationcodes
This endpoint allows a mobile money payer or payee to generate a code which when presented to the other party, can be redeemed for an amount set by the payer or payee, depending upon the use case where one identifier suffices to uniquely identify an account.
Here, createAuthorisationCode([ 'identifierType1' => 'identifier1', 'identifierType2' => 'identifier2', 'identifierType3' => 'identifier3' ], $authorisationObj) creates a POST request to /accounts/{AccountIdentifiers}/authorisationcodes
This endpoint allows a mobile money payer or payee to generate a code which when presented to the other party, can be redeemed for an amount set by the payer or payee, depending upon the use case where a single identifier is not sufficient to identify an account.
<?php
require_once __DIR__ . './../bootstrap.php';
use mmpsdk\Common\Enums\NotificationMethod;
use mmpsdk\Common\Exceptions\MobileMoneyException;
use mmpsdk\AgentService\AgentService;
use mmpsdk\Common\Models\AuthorisationCode;
$authorisationObj = new AuthorisationCode();
$authorisationObj
->setRequestDate(date('Y-m-d\TH:i:s\.40z'))
->setCurrency('GBP')
->setAmount('1001.00');
$accountIdentifier = [
'accountid' => 2000
];
try {
/**
* Construct request object and set desired parameters
*/
$request = AgentService::createAuthorisationCode(
$accountIdentifier,
$authorisationObj
);
/**
* Choose notification method can be either Callback or Polling
*/
$request->setNotificationMethod(NotificationMethod::POLLING);
/**
* Get Client Correlation Id that will be sent along with request
*/
$clientCorrelationId = $request->getClientCorrelationId()
print_r($clientCorrelationId);
/**
*Execute the request
*/
$response = $request->execute();
print_r($response);
} catch (MobileMoneyException $ex) {
print_r($ex->getMessage());
print_r($ex->getErrorObj());
}0e277ed2-08fd-4872-99bd-8fbf523482d2
mmpsdk\Common\Models\RequestState Object
(
[serverCorrelationId:mmpsdk\Common\Models\RequestState:private] => 3eee90eb-ed25-459f-9653-71ea95c9c04a
[clientCorrelationId:mmpsdk\Common\Models\RequestState:private] => 0e277ed2-08fd-4872-99bd-8fbf523482d2
[objectReference:mmpsdk\Common\Models\RequestState:private] => 2309
[status:mmpsdk\Common\Models\RequestState:private] => pending
[notificationMethod:mmpsdk\Common\Models\RequestState:private] => callback
[pendingReason:mmpsdk\Common\Models\RequestState:private] =>
[expiryTime:mmpsdk\Common\Models\RequestState:private] =>
[pollLimit:mmpsdk\Common\Models\RequestState:private] => 100
[errorReference:mmpsdk\Common\Models\RequestState:private] =>
[hydratorStrategies:protected] =>
[availableCount:protected] => 0
)4890d1ab-0995-4523-94ef-97cedae212c1
mmpsdk\Common\Models\RequestState Object
(
[serverCorrelationId:mmpsdk\Common\Models\RequestState:private] => 75659c6e-d48a-42d7-9355-ee4e2f3b5112
[clientCorrelationId:mmpsdk\Common\Models\RequestState:private] => 4890d1ab-0995-4523-94ef-97cedae212c1
[objectReference:mmpsdk\Common\Models\RequestState:private] => 2308
[status:mmpsdk\Common\Models\RequestState:private] => pending
[notificationMethod:mmpsdk\Common\Models\RequestState:private] => polling
[pendingReason:mmpsdk\Common\Models\RequestState:private] =>
[expiryTime:mmpsdk\Common\Models\RequestState:private] =>
[pollLimit:mmpsdk\Common\Models\RequestState:private] => 100
[errorReference:mmpsdk\Common\Models\RequestState:private] =>
[hydratorStrategies:protected] =>
[availableCount:protected] => 0
)NOTE
In asynchronous flows, a callback mechanism or polling mechanism is utilised to allow the client to determine the request's final state. Use the viewRequestState() function for the polling mechanism to receive the status of a request, and the viewAuthorisationCode() function to acquire the final representation of the AuthorisationCode object.