Plutu Documentation
  • API Documentation
    • Introduction
    • Authentication
      • IP Whitelist
    • Payments
      • Sadad
      • Adfali
      • Local Bank Cards
      • MPGS
      • T-Lync Service
    • Errors
    • Testing
  • SDKs
    • Plutu PHP
    • Plutu Laravel
  • Plugins and extensions
    • Plutu WooCommerce
    • Plutu Formidable
    • Plutu OpenCart
Powered by GitBook
On this page
  • Send OTP
  • Confirm

Was this helpful?

  1. API Documentation
  2. Payments

Adfali

Provided by the Bank of Commerce and Development

PreviousSadadNextLocal Bank Cards

Last updated 6 months ago

Was this helpful?

Send OTP

This request will validate the customer identity, send OTP and register an unpaid invoice.

Send OTP

POST https://api.plutus.ly/api/v1/transaction/edfali/verify

Send the OTP to the customer's phone number to initiate the transaction

Headers

Name
Type
Description

Authorization*

String

Bearer: [Access token]

X-API-KEY*

String

API Key

Request Body

Name
Type
Description

mobile_number*

String

Mobile number 09XXXXXXXX

amount*

String

Transaction amount in Libyan dinars.

Formatting is allowed with a maximum of two decimal places: XXX, XX.X, XX.XX

{
    "status": 200,
    "result": {
        "process_id": xxxxxxxxxxxxx
    },
    "message": "OTP has been sent to your mobile number"
}
{
    "error": {
        "status": 4xx,
        "code": "ERROR_CODE_PLACEHOLDER",
        "message": "ERROR_MESSAGE_PLACEHOLDER"
    }
}

You can review the section for all possible errors

curl --location --request POST 'https://api.plutus.ly/api/v1/transaction/edfali/verify' \
--header 'X-API-KEY: [API_KEY]' \
--header 'Authorization: Bearer [ACCESS_TOEKN]' \
--form 'mobile_number="[MOBILE_NUMBER]"' \
--form 'amount="[AMONUT]"'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.plutus.ly/api/v1/transaction/edfali/verify',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array(
    'mobile_number' => '[MOBILE_NUMBER]', 
    'amount' => '[AMONUT]', 
  ),
  CURLOPT_HTTPHEADER => array(
    'X-API-KEY: [API_KEY]',
    'Authorization: Bearer [ACCESS_TOEKN]'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
<?php

use Plutu\Services\PlutuAdfali;

$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()) {

        // Possible errors from Plutu API
        // @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation
        $errorCode = $apiResponse->getOriginalResponse()->getErrorCode();
        $errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage();
        $statusCode = $apiResponse->getOriginalResponse()->getStatusCode();
        $responseData = $apiResponse->getOriginalResponse()->getBody();

    }

// Handle exceptions that may be thrown during the execution of the code
// The following are the expected exceptions that may be thrown:
// Check the "Handle Exceptions and Errors" section for more details
// 
// InvalidAccessTokenException, InvalidApiKeyException
// InvalidMobileNumberException, InvalidAmountException
} catch (\Exception $e) {
    $exception = $e->getMessage();
}

Confirm

Pay the unpaid transaction

Confirm

POST https://api.plutus.ly/api/v1/transaction/edfali/confirm

Confirm to pay the transaction

Headers

Name
Type
Description

Authorization*

String

Bearer: [Access token]

X-API-KEY*

String

API Key

Request Body

Name
Type
Description

process_id*

String

Process ID is returned in the verify step

code*

String

OTP code is sent to customer's phone number

amount*

String

Transaction amount in Libyan dinars.

Formatting is allowed with a maximum of two decimal places: XXX, XX.X, XX.XX

invoice_no*

String

Invoice number associated with transaction, must be unique and not previously used.

customer_ip

String

Customer IP address

{
    "status": 200,
    "result": {
        "transaction_id": xxxxxxxxxxxxx,
        "amount": xxxxxxxxxxxxx
    },
    "message": "Transaction completed successfully"
}
{
    "error": {
        "status": 4xx,
        "code": "ERROR_CODE_PLACEHOLDER",
        "message": "ERROR_MESSAGE_PLACEHOLDER"
    }
}
curl --location --request POST 'https://api.plutus.ly/api/v1/transaction/edfali/confirm'
--header 'X-API-KEY: API_KEY]'
--header 'Authorization: Bearer [ACCESS_TOEKN]'
--form 'code="[OTP]"'
--form 'amount="[AMONUT]"'
--form 'invoice_no="[INVOICE_NO]"'
--form 'process_id="[PROCESS_ID]"'
--form 'customer_ip="[CUSTOMER_IP]"'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.plutus.ly/api/v1/transaction/edfali/confirm',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array(
    'code' => '[OTP]', 
    'amount' => '[AMONUT]', 
    'invoice_no' => '[INVOICE_NO]', 
    'process_id' => '[PROCESS_ID]', 
    'customer_ip' => '[CUSTOMER_IP]'
  ),
  CURLOPT_HTTPHEADER => array(
    'X-API-KEY: [API_KEY]',
    'Authorization: Bearer [ACCESS_TOEKN]'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
<?php

use Plutu\Services\PlutuAdfali;

$processId = 'xxxxx'; // the Process ID that received in the verification step
$code = '1111'; // OTP
$amount = 5.0; // amount in float format
$invoiceNo = 'inv-12345'; // invoice number

try {

    $api = new PlutuAdfali;
    $api->setCredentials('api_key', 'access_token');

    $apiResponse = $api->confirm($processId, $code, $amount, $invoiceNo);

    if($apiResponse->getOriginalResponse()->isSuccessful()){

        // The transaction has been completed
        // Plutu Transaction ID
        $transactionId = $apiResponse->getTransactionId();
        // Response Data
        $data = $apiResponse->getOriginalResponse()->getBody();

    } elseif($apiResponse->getOriginalResponse()->hasError()) {

        // Possible errors from Plutu API
        // @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation
        $errorCode = $apiResponse->getOriginalResponse()->getErrorCode();
        $errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage();
        $statusCode = $apiResponse->getOriginalResponse()->getStatusCode();
        $responseData = $apiResponse->getOriginalResponse()->getBody();

    }

// Handle exceptions that may be thrown during the execution of the code
// The following are the expected exceptions that may be thrown:
// Check the "Handle Exceptions and Errors" section for more details
// 
// InvalidAccessTokenException, InvalidApiKeyException
// InvalidProcessIdException, InvalidCodeException, InvalidAmountException, InvalidInvoiceNoException
} catch (\Exception $e) {
    $exception = $e->getMessage();
}

Check out the example in the Plutu PHP Examples document on GitHub.

You can review the section for all possible errors

Check out the example in the Plutu PHP Examples document on GitHub.

Errors
Verify Process (Send OTP)
Errors
Confirm Process (Pay)