You can now accept payment on your website with SAFACIL Pay which will make it easier for your customers to purchase your products.
POST
: https://safacilpay.com/sandbox/payment
Request Body
Name | Type |
---|---|
amount | Int |
orderId | Int |
<?php
$url = "https://safacilpay.com/sandbox/payment";
$orderId = time() . $buyerId;
$data = array("amount" => 10, "orderId" => $orderId);
$token = "YOUR TOKEN";
$ch = curl_init($url);
// Set options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
// Set the headers including the Bearer token
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer '. $token
));
$response = curl_exec($ch);
// Check for errors
if(curl_errno($ch)) {
echo 'Request Error:' . curl_error($ch);
}
// Close the cURL session
curl_close($ch);
// Decode the JSON response
$responseData = json_decode($response, true);
echo $response;
?>
Once the request is executed, you will get a URL containing the Safacil pay payment page, where your customers can register their Safacil ID to validate the payment.
{
"mode":"Sandbox",
"url":"https://safacilpay.com/rest/middleware/index.php?r=K1JEQVUNqMkFle0FOSDdsN1RTRGFkRWUxYUJrPQ==",
"status":200
}
Use these identifiers to validate the payment on sandbox environment
Sandbox Phone: 50943000000
Password: 1234
Once the payment is validated, your redirect URLs will be called with a new parameter.
https://Your_ReturnURL?transactionId=00000000
If you have not yet specified your return URLs, please click on the link below.