PHP code example of blessedjasonmwanza / moneyunify

1. Go to this page and download the library: Download blessedjasonmwanza/moneyunify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

blessedjasonmwanza / moneyunify example snippets


    

   use Blessedjasonmwanza\MoneyUnify\MoneyUnify;

   $muid = 'your_unique_muid'; // Replace with your actual MUID - obtain it at https://MoneyUnify.com
   $moneyUnify = new MoneyUnify($muid);
   

   $payerPhoneNumber = '0xxxxxxxx'; // Replace with payer's phone number
   $amountToPay = '10'; // Amount to be paid

   $response = $moneyUnify->requestPayment($payerPhoneNumber, $amountToPay);
   

   if ($response->isError) {
       echo "Error: " . $response->message . "\n";
       echo "Console: " . ($response->console ?? 'No console message to debug') . "\n";
   } else {
       echo "Success: " . $response->message . "\n";
       echo "Data: " . json_encode($response->data) . "\n";
   }
   

   $transactionReference = 'your_transaction_reference'; // Replace with transaction reference
   $verificationResponse = $moneyUnify->verifyPayment($transactionReference);
   

   if ($verificationResponse->isError) {
       echo "Error: " . $verificationResponse->message . "\n";
       echo "Console: " . ($verificationResponse->console ?? 'No console message to debug') . "\n";
   } else {
       echo "Verification Success: " . $verificationResponse->message . "\n";
       echo "Data: " . json_encode($verificationResponse->data) . "\n";
   }
   

   $settleParams = [
       'moneyunify_email' => '[email protected]', // Replace with your MoneyUnify email
       'receiver_first_name' => 'Blessed',
       'receiver_last_name' => 'Mwanza',
       'receiver_phone_number' => '0971943638', // Replace with receiver's phone number
       'transaction_details' => 'Settling funds to the specified account.'
   ];

   $settlementResponse = $moneyUnify->settleFunds($settleParams);
   

   if ($settlementResponse->isError) {
       echo "Error: " . $settlementResponse->message . "\n";
       echo "Console: " . ($settlementResponse->console ?? 'No console message to debug') . "\n";
   } else {
       echo "Settlement Success: " . $settlementResponse->message . "\n";
       echo "Data: " . json_encode($settlementResponse->data) . "\n";
   }