PHP code example of alex-nguetcha / intouch

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

    

alex-nguetcha / intouch example snippets


$intouch = Intouch::credentials(
    username: 'username',
    password: 'password',
    loginAgent: 'loginAgent',
    passwordAgent: 'passwordAgent',
    intouchId: 'passwordAgent'
)->callback('https://app.test/confirm-payment')
    ->amount(100)
    ->phone(6xxxxxx)
    ->operator('ORANGE')
    ->makeMerchantPayment(
        [
            "recipientEmail" => "[email protected]",
            "recipientFirstName" => "John",
            "recipientLastName" => "Doe",
        ]
    );


if ($intouch->isInitiated()) {
    // Your transaction has been initiated by intouch API
    // echo (string)($intouch->getResult()->getBody());
} else {
    // something went wrong
    // echo $intouch->getError()['request'];
    // echo $intouch->getError()['response'];
}

use AlexNguetcha\Intouch\Intouch;

$intouch = Intouch::credentials(
    username: 'your-username',
    password: 'your-password',
    loginAgent: 'your-login-agent',
    passwordAgent: 'your-password-agent',
    intouchId: 'your-intouch-id'
);

$intouch->amount(100); // Set the amount to be paid
$intouch->phone('1234567890'); // Set the mobile money account to be debited
$intouch->operator('MTN'); // Set the mobile money operator for the transaction
$intouch->callback('https://example.com/payment/callback');
 
$intouch->makeMerchantPayment([
    "recipientEmail" => "[email protected]",
    "recipientFirstName" => "John",
    "recipientLastName" => "Doe",
    "phone" => "1234567890",
    "amount" => 100,
    "operator" => "MTN",
    "reason" => "Payment for goods and services",
]);

 
$intouch->callback('https://your-app.com/intouch-callback');

if ($intouch->isInitiated()) {
    // Your transaction has been initiated by intouch API
    echo (string)($intouch->getResult()->getBody());
} else {
    // something went wrong
    // echo $intouch->getError()['request'];
    echo $intouch->getError()['response'];
}