PHP code example of plutu / plutu-php

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

    

plutu / plutu-php example snippets





use Plutu\Services\PlutuAdfali;
use Plutu\Services\PlutuSadad;
use Plutu\Services\PlutuLocalBankCards;
use Plutu\Services\PlutuTlync;
use Plutu\Services\PlutuMpgs;

// Adfali service
$api = new PlutuAdfali;
$api->setCredentials('api_key', 'access_token');
// Sadad service
$api = new PlutuSadad;
$api->setCredentials('api_key', 'access_token');
// Local Bank Cards service
$api = new PlutuLocalBankCards;
$api->setCredentials('api_key', 'access_token', 'secret_key');
// Tlync service
$api = new PlutuTlync;
$api->setCredentials('api_key', 'access_token', 'secret_key');
// MPGS service
$api = new PlutuMpgs;
$api->setCredentials('api_key', 'access_token', 'secret_key');

$mobileNumber = '090000000'; // Mobile number should start with 09
$amount = 5.0; // amount in float format

try {

    $api = new PlutuAdfali;
    $api->setCredentials('api_key', 'access_token');
    $apiResponse = $api->verify($mobileNumber, $amount);

    if ($apiResponse->getOriginalResponse()->isSuccessful()) {
        // Process ID should be sent in the confirmation step
        $processId = $apiResponse->getProcessId();
    } elseif ($apiResponse->getOriginalResponse()->hasError()) {
        $errorCode = $apiResponse->getOriginalResponse()->getErrorCode();
        $errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage();
    }

// Handle exceptions that may be thrown during the execution of the code
} catch (\Exception $e) {
    $exception = $e->getMessage();
}

composer