createBillTransaction() creates a POST request to /transactions/type/billpay
Provided with a valid object representation, this endpoint allows for a new transaction to be created for a given transaction type 'billpay' passed via the URL.
<?php
require_once __DIR__ . './../bootstrap.php';
use mmpsdk\Common\Models\Transaction;
use mmpsdk\Common\Exceptions\MobileMoneyException;
use mmpsdk\BillPayment\BillPayment;
$transaction = new Transaction();
$transaction
->setAmount('16.00')
->setCurrency('USD')
->setCreditParty(['walletid' => '1'])
->setDebitParty(['msisdn' => '+44012345678']);
try {
/**
* Construct request object and set desired parameters
*/
$request = BillPayment::createBillTransaction($transaction);
/**
* Choose notification method can be either Callback or Polling
*/
$request->setNotificationMethod(NotificationMethod::CALLBACK);
/**
* 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());
}3be54a71-90e9-4e48-a938-4a1529deb460
mmpsdk\Common\Models\RequestState Object
(
[serverCorrelationId:mmpsdk\Common\Models\RequestState:private] => 89e9af21-9c05-4a22-bc83-811d711c52c2
[clientCorrelationId:mmpsdk\Common\Models\RequestState:private] => 3be54a71-90e9-4e48-a938-4a1529deb460
[objectReference:mmpsdk\Common\Models\RequestState:private] => 19154
[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
)3be54a71-90e9-4e48-a938-4a1529deb460
mmpsdk\Common\Models\RequestState Object
(
[serverCorrelationId:mmpsdk\Common\Models\RequestState:private] => 89e9af21-9c05-4a22-bc83-811d711c52c2
[clientCorrelationId:mmpsdk\Common\Models\RequestState:private] => 3be54a71-90e9-4e48-a938-4a1529deb460
[objectReference:mmpsdk\Common\Models\RequestState:private] => 19154
[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 viewTransaction() function to acquire the final representation of the Transaction object.