Links

Sadad

Mobile payment service provided by Al-Madar

Send OTP

This request will validate the customer identity, send OTP and register an unpaid invoice.
post
https://api.plutus.ly/api/v1
/transaction/sadadapi/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
Starts with 091 or 093
birth_year*
String
4 digits XXXX
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
Successful response
400: Bad Request
Error response
CURL
PHP
Plutu PHP Package
curl --location --request POST 'https://api.plutus.ly/api/v1/transaction/sadadapi/verify' \
--header 'X-API-KEY: [API_KEY]' \
--header 'Authorization: Bearer [ACCESS_TOEKN]' \
--form 'mobile_number="[MOBILE_NUMBER]"' \
--form 'amount="[AMONUT]"' \
--form 'birth_year="[BIRTH_YEAR]"'
1
<?php
2
3
$curl = curl_init();
4
5
curl_setopt_array($curl, array(
6
CURLOPT_URL => 'https://api.plutus.ly/api/v1/transaction/sadadapi/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
'birth_year' => '[BIRTH_YEAR]'
14
),
15
CURLOPT_HTTPHEADER => array(
16
'X-API-KEY: [API_KEY]',
17
'Authorization: Bearer [ACCESS_TOEKN]'
18
),
19
));
20
21
$response = curl_exec($curl);
22
23
curl_close($curl);
24
echo $response;
1
<?php
2
3
use Plutu\Services\PlutuSadad;
4
5
$mobileNumber = '090000000'; // Mobile number should start with 09
6
$birthYear = '1991'; // Birth year
7
$amount = 5.0; // amount in float format
8
9
try {
10
11
$api = new PlutuSadad;
12
$api->setCredentials('api_key', 'access_token');
13
$apiResponse = $api->verify($mobileNumber, $birthYear, $amount);
14
15
if ($apiResponse->getOriginalResponse()->isSuccessful()) {
16
17
// Process ID should be sent in the confirmation step
18
$processId = $apiResponse->getProcessId();
19
20
} elseif ($apiResponse->getOriginalResponse()->hasError()) {
21
22
// Possible errors from Plutu API
23
// @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation
24
$errorCode = $apiResponse->getOriginalResponse()->getErrorCode();
25
$errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage();
26
$statusCode = $apiResponse->getOriginalResponse()->getStatusCode();
27
$responseData = $apiResponse->getOriginalResponse()->getBody();
28
29
}
30
31
// Handle exceptions that may be thrown during the execution of the code
32
// The following are the expected exceptions that may be thrown:
33
// Check the "Handle Exceptions and Errors" section for more details
34
//
35
// InvalidAccessTokenException, InvalidApiKeyException
36
// InvalidMobileNumberException, InvalidBirthYearException, InvalidAmountException
37
} catch (\Exception $e) {
38
$exception = $e->getMessage();
39
}
Check out the example Verify Process (Send OTP) in the Plutu PHP Examples document on GitHub.

Confirm

Pay the unpaid transaction
post
https://api.plutus.ly/api/v1
/transaction/sadadapi/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
400: Bad Request
CURL
PHP
Plutu PHP Package
curl --location --request POST 'https://api.plutus.ly/api/v1/transaction/sadadapi/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/sadadapi/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;
<?php
use Plutu\Services\PlutuSadad;
$processId = 'xxxxx'; // the Process ID that received in the verification step
$code = '111111'; // OTP
$amount = 5.0; // amount in float format
$invoiceNo = 'inv-12345'; // invoice number
try {
$api = new PlutuSadad;
$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.