plutu / plutu-php
Plutu for php
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
README
Official Plutu SDK for PHP
The Plutu PHP package provides a streamlined integration of Plutu's services into PHP projects. It offers a generic interface that enables easy interaction with the Plutu API and services.
Getting started
Requirments
Before you can use the Plutu PHP package, you need to have a Plutu API key, access token, and secret key. You can obtain these from your Plutu account dashboard.
- PHP version 8.1 or higher
Official Documentation
Documentation for Plutu API can be found on the Plutu Docs website.
Installation
You can install the Plutu PHP package via Composer by running the following command:
composer require plutu/plutu-php
Usage
To use the Plutu PHP package in your project, you first need to include the Composer autoload file:
require_once __DIR__ . '/vendor/autoload.php';
To set credentials for Plutu PHP, you can use the following method:
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');
You can then use the various methods provided by the Plutu PHP to interact with the Plutu API. Each Plutu service has different methods and arguments, which you can check out in the examples provided examples
section below.
$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(); }
Examples
The Plutu PHP package includes several examples that demonstrate how to use the package to interact with the Plutu API. The examples cover various use cases for Plutu's services. You can find the examples in the Examples document.
Each example includes code snippets with explanations, as well as a link to the full source code. We recommend reviewing the examples to get a better understanding of how to use the package in your own projects.
List of Examples
- Usage
- Initialization
- Services
- Exceptions and Error Handling
Official integrations
The following integrations are fully supported and maintained by the Plutu team.
Resources
License
The Plutu PHP package is open-source software licensed under the MIT License.