1. Go to this page and download the library: Download sofizpay/sofizpay-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Recent operations (paginated)
$history = $sdk.getOperationHistory('USER_ENCRYPTED_SK', 10, 0);
if ($history['success']) {
print_r($history['data']);
}
// Details of a specific operation
$details = $sdk.getOperationDetails('OPERATION_ID', 'USER_ENCRYPTED_SK');
// Fetch list of available recharging products
$products = $sdk.getProducts('USER_ENCRYPTED_SK');
if ($products['success']) {
// List all available services and offers
print_r($products['data']);
}
$result = $sdk->makeCIBTransaction([
'account' => 'YOUR_STELLAR_PUBLIC_KEY', // Your merchant Stellar public key
'amount' => 2500, // Amount in DZD (Algerian Dinars)
'full_name' => 'Ahmed Benali', // Customer's full name
'phone' => '0661234567', // Customer's phone number
'email' => '[email protected]', // Customer's email
'memo' => 'Order #789', // Internal order reference
'return_url' => 'https://yoursite.com/callback', // Redirect after payment
'webhook_url' => 'https://yoursite.com/api/cib-webhook', // Asynchronous Webhook callback
'language' => 'ar', // 'ar', 'fr', or 'en'
'redirect' => 'no' // 'yes' for auto-redirect
]);
if ($result['success']) {
// Top-level direct properties
$paymentUrl = $result['payment_url'];
$orderId = $result['cib_transaction_id'];
// Redirect customer to the SATIM checkout page
header('Location: ' . $paymentUrl);
exit;
}
// webhook.php
ySDK;
$sdk = new SofizPaySDK();
// 1. Read input payload
$payload = json_decode(file_get_contents('php://input'), true);
// 2. Validate signature AND that payment_status / amount / order_number match the signed message
if (!is_array($payload) || !$sdk->verifyWebhookPayload($payload)) {
http_response_code(400);
echo "Invalid webhook";
exit;
}
// 3. Process order upon confirmation (only the signed fields are used)
if ($payload['payment_status'] === 'success') {
$orderNumber = $payload['order_number'];
$amountInDZD = $payload['amount'] / 100;
// ✅ Also check $payload['amount'] equals the amount stored for this order, and process each order once
// ✅ Mark order as PAID in your database:
// $db->updateOrder($orderNumber, ['status' => 'PAID', 'amount' => $amountInDZD]);
}
http_response_code(200);
echo "OK";
// Monitor account activity (simulated via polling)
$status = $sdk.getStreamStatus('YOUR_PUBLIC_KEY');