plutu/plutu-php

Plutu for php

1.1.2 2023-08-24 13:34 UTC

This package is auto-updated.

Last update: 2024-10-24 16:27:28 UTC


README

Plutu

Official Plutu SDK for PHP

Version Total Downloads License

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

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.