Links

T-Lync Service

T-Lync service from Tadawul digital solution provider

Pay

Pay the transaction.
post
https://api.plutus.ly/api/v1
/transaction/tlync/confirm
Confirm (Pay)
Pay the transaction
Parameters
Header
Authorization*
Bearer: [Access token]
X-API-KEY*
API Key
Body
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
mobile_number*
String
Valid mobile number format start with 9x or 09
email
String
[Optional] Email address
return_url*
String
URL after payment is completed to allow the customer to return to the order/invoice
callback_url*
String
The URL of your Instant update Server URL to track your order/invoice, instantly sent by Plutu when the transaction is complete
customer_ip
String
[Optional] Customer IP address
lang
String
[Optional] ar or en, by default ar
Responses
200: OK
400: Bad Request
CURL
PHP
Plutu PHP Package
curl --location --request POST 'https://api.plutus.ly/api/v1/transaction/tlync/confirm' \
--header 'X-API-KEY: [API_KEY]' \
--header 'Authorization: Bearer [ACCESS_TOKEN]' \
--form 'amount="[AMONUT]"' \
--form 'invoice_no="[INVOICE_NO]"' \
--form 'return_url="[RETURN_URL]"' \
--form 'callback_url="[CALLBACK_URL]"' \
--form 'mobile_number="[MOBILE_NUMBER]"' \
--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/tlync/confirm',
7
CURLOPT_RETURNTRANSFER => true,
8
CURLOPT_FOLLOWLOCATION => true,
9
CURLOPT_CUSTOMREQUEST => 'POST',
10
CURLOPT_POSTFIELDS => array(
11
'amount' => '[AMONUT]',
12
'invoice_no' => '[INVOICE_NO]',
13
'return_url' => '[RETURN_URL]',
14
'callback_url' => '[CALLBACK_URL]',
15
'mobile_number' => '[MOBILE_NUMBER]',
16
'customer_ip' => '[CUSTOMER_IP]'
17
),
18
CURLOPT_HTTPHEADER => array(
19
'X-API-KEY: [API_KEY]',
20
'Authorization: Bearer [ACCESS_TOKEN]'
21
),
22
));
23
24
$response = curl_exec($curl);
25
26
curl_close($curl);
27
echo $response;
1
<?php
2
3
use Plutu\Services\PlutuTlync;
4
5
$amount = 5.0; // amount in float format
6
$invoiceNo = 'inv-12345'; // invoice number
7
$returnUrl = 'https://example.com/return/handler'; // the url to handle the return from plutu after payment completed from T-Lync
8
$callbackUrl = 'https://example.com/callback/handler'; // the url to handle the callback trgigger from plutu after payment completed from T-Lync
9
10
try {
11
12
$api = new PlutuTlync;
13
$api->setCredentials('api_key', 'access_token', 'secret_key');
14
$apiResponse = $api->confirm($amount, $invoiceNo, $returnUrl, $callbackUrl);
15
16
if ($apiResponse->getOriginalResponse()->isSuccessful()) {
17
18
// Redirect URL for Plutu and T-Lync checkout page
19
$redirectUrl = $apiResponse->getRedirectUrl();
20
21
// You should rediect the customer to payment checkout page
22
// header("location: " . $redirectUrl);
23
24
} elseif ($apiResponse->getOriginalResponse()->hasError()) {
25
26
// Possible errors from Plutu API
27
// @see https://docs.plutu.ly/api-documentation/errors Plutu API Error Documentation
28
$errorCode = $apiResponse->getOriginalResponse()->getErrorCode();
29
$errorMessage = $apiResponse->getOriginalResponse()->getErrorMessage();
30
$statusCode = $apiResponse->getOriginalResponse()->getStatusCode();
31
$responseData = $apiResponse->getOriginalResponse()->getBody();
32
33
}
34
35
// Handle exceptions that may be thrown during the execution of the code
36
// The following are the expected exceptions that may be thrown:
37
// Check the "Handle Exceptions and Errors" section for more details
38
//
39
// InvalidAccessTokenException, InvalidApiKeyException, InvalidSecretKeyException,
40
// InvalidAmountException, InvalidInvoiceNoException, InvalidReturnUrlException, InvalidCallbackUrlException
41
} catch (\Exception $e) {
42
$exception = $e->getMessage();
43
}
Check out the example Confirm (Pay) in the Plutu PHP Examples document on GitHub.

Callback handler

The callback will be received from Plutu when the transaction is completed. This gives a Merchant better control of how the transaction is processed on the Merchant's side. This is useful e.g. when you want to mark an order as paid, update your shop's inventory, or add appropriate records to Merchant’s internal accounting system.
Callback parameters:
The callback is called with HTTP POST as JSON
Parameter
Description
gateway
Gateway name: tlync
approved
Transaction completed
invoice_no
Invoice number sent in the pay request
amount
amount sent in the request
paymet_method
The payment method in which the transaction was completed on T-Lync. Supported payment methods: tadawul, edfaly, sadad, mobicash, and moamalat
transaction_id
Plutu transaction id
hashed
Hash message authorization code (HMAC) is used to verify both the data integrity and the authorization of a message.

Return handler

Once the payment has been completed client can be redirected to the merchant-provided return URL.
Return parameters:
The callback is called with HTTP GET and with the same query string parameters as in the redirect
Parameter
Description
approved
Transaction completed
invoice_no
Invoice number sent in the pay request
hashed
Hash message authorization code (HMAC) is used to verify both the data integrity and the authorization of a message.
SHA-256 HMAC is calculated as follows:
  • The SHA-256 HMAC calculation includes all response parameters and key-value pairs except the “hashed” parameter.
  • Create an SHA-256 HMAC of the resultant string using the secret key created in the Plutu account and convert it to uppercase and compare it with the “hashed” parameter received in the callback or return handler.