Adfali
Provided by the Bank of Commerce and Development
This request will validate the customer identity, send OTP and register an unpaid invoice.
post
https://api.plutus.ly/api/v1
/transaction/edfali/verify
Send OTP
Send the OTP to the customer's phone number to initiate the transaction
Parameters
Header
Authorization*
Bearer: [Access token]
X-API-KEY*
API Key
Body
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
Responses
200: OK
400: Bad Request
CURL
PHP
Plutu PHP Package
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]"'
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://api.plutus.ly/api/v1/transaction/edfali/verify',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_FOLLOWLOCATION => true,
9
CURLOPT_CUSTOMREQUEST => 'POST',
10
CURLOPT_POSTFIELDS => array(
11
'mobile_number' => '[MOBILE_NUMBER]',
12
'amount' => '[AMONUT]',
13
),
14
CURLOPT_HTTPHEADER => array(
15
'X-API-KEY: [API_KEY]',
16
'Authorization: Bearer [ACCESS_TOEKN]'
17
),
18
));
19
20
$response = curl_exec($curl);
21
22
curl_close($curl);
23
echo $response;
1
<?php
2
3
use Plutu\Services\PlutuAdfali;
4
5
$mobileNumber = '090000000'; // Mobile number should start with 09
6
$amount = 5.0; // amount in float format
7
8
try {
9
$api = new PlutuAdfali;
10
$api->setCredentials('api_key', 'access_token');
11
12
$apiResponse = $api->verify($mobileNumber, $amount);
13
14
if ($apiResponse->getOriginalResponse()->isSuccessful()) {
15
16
// Process ID should be sent in the confirmation step
17
$processId = $apiResponse->getProcessId();
18
19
} elseif ($apiResponse->getOriginalResponse()->hasError()) {
20
21
// Possible errors from Plutu API
22
// @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation
23
$errorCode = $apiResponse->getOriginalResponse()->getErrorCode();
24
$errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage();
25
$statusCode = $apiResponse->getOriginalResponse()->getStatusCode();
26
$responseData = $apiResponse->getOriginalResponse()->getBody();
27
28
}
29
30
// Handle exceptions that may be thrown during the execution of the code
31
// The following are the expected exceptions that may be thrown:
32
// Check the "Handle Exceptions and Errors" section for more details
33
//
34
// InvalidAccessTokenException, InvalidApiKeyException
35
// InvalidMobileNumberException, InvalidAmountException
36
} catch (\Exception $e) {
37
$exception = $e->getMessage();
38
}
Pay the unpaid transaction
post
https://api.plutus.ly/api/v1
/transaction/edfali/confirm
Confirm
Confirm to pay the transaction
Parameters
Header
Authorization*
String
Bearer: [Access token]
X-API-KEY*
String
API Key
Body
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
customer_ip
String
Customer IP address
Responses
200: OK
Successful response
400: Bad Request
Error response
CURL
PHP
Plutu PHP Package
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]"'
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://api.plutus.ly/api/v1/transaction/edfali/confirm',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_FOLLOWLOCATION => true,
9
CURLOPT_CUSTOMREQUEST => 'POST',
10
CURLOPT_POSTFIELDS => array(
11
'code' => '[OTP]',
12
'amount' => '[AMONUT]',
13
'invoice_no' => '[INVOICE_NO]',
14
'process_id' => '[PROCESS_ID]',
15
'customer_ip' => '[CUSTOMER_IP]'
16
),
17
CURLOPT_HTTPHEADER => array(
18
'X-API-KEY: [API_KEY]',
19
'Authorization: Bearer [ACCESS_TOEKN]'
20
),
21
));
22
23
$response = curl_exec($curl);
24
25
curl_close($curl);
26
echo $response;
1
<?php
2
3
use Plutu\Services\PlutuAdfali;
4
5
$processId = 'xxxxx'; // the Process ID that received in the verification step
6
$code = '1111'; // OTP
7
$amount = 5.0; // amount in float format
8
$invoiceNo = 'inv-12345'; // invoice number
9
10
try {
11
12
$api = new PlutuAdfali;
13
$api->setCredentials('api_key', 'access_token');
14
15
$apiResponse = $api->confirm($processId, $code, $amount, $invoiceNo);
16
17
if($apiResponse->getOriginalResponse()->isSuccessful()){
18
19
// The transaction has been completed
20
// Plutu Transaction ID
21
$transactionId = $apiResponse->getTransactionId();
22
// Response Data
23
$data = $apiResponse->getOriginalResponse()->getBody();
24
25
} elseif($apiResponse->getOriginalResponse()->hasError()) {
26
27
// Possible errors from Plutu API
28
// @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation
29
$errorCode = $apiResponse->getOriginalResponse()->getErrorCode();
30
$errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage();
31
$statusCode = $apiResponse->getOriginalResponse()->getStatusCode();
32
$responseData = $apiResponse->getOriginalResponse()->getBody();
33
34
}
35
36
// Handle exceptions that may be thrown during the execution of the code
37
// The following are the expected exceptions that may be thrown:
38
// Check the "Handle Exceptions and Errors" section for more details
39
//
40
// InvalidAccessTokenException, InvalidApiKeyException
41
// InvalidProcessIdException, InvalidCodeException, InvalidAmountException, InvalidInvoiceNoException
42
} catch (\Exception $e) {
43
$exception = $e->getMessage();
44
}
Last modified 1mo ago