Adfali
Provided by the Bank of Commerce and Development
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
Request Body
{
"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 Errors 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();
}
Check out the example Verify Process (Send OTP) in the Plutu PHP Examples document on GitHub.
Confirm
Pay the unpaid transaction
Confirm
POST
https://api.plutus.ly/api/v1/transaction/edfali/confirm
Confirm to pay the transaction
Headers
Request Body
{
"status": 200,
"result": {
"transaction_id": xxxxxxxxxxxxx,
"amount": xxxxxxxxxxxxx
},
"message": "Transaction completed successfully"
}
{
"error": {
"status": 4xx,
"code": "ERROR_CODE_PLACEHOLDER",
"message": "ERROR_MESSAGE_PLACEHOLDER"
}
}
You can review the Errors section for all possible errors
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 Confirm Process (Pay) in the Plutu PHP Examples document on GitHub.
Last updated