PHP code example of parsepesa / php

1. Go to this page and download the library: Download parsepesa/php 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/ */

    

parsepesa / php example snippets


use ParsePesa\ParsePesa;

$sdk = new ParsePesa('your_api_key');

// Parse a single message
$result = $sdk->parse("Confirmed. You have received KES 500.00 from JOHN DOE...");

echo $result['amount']; // 500
echo $result['counterparty']; // JOHN DOE

$result = $sdk->parse($message);

$results = $sdk->batchParse([$msg1, $msg2]);

$balance = $sdk->getBalance();
echo "KES " . $balance;

$data = $sdk->handleWebhook();
// Process $data['type'], $data['amount'], etc.
bash
composer