Update: 2026-06-11 18:22:57
This commit is contained in:
BIN
walletintaleq.intaleq.xyz/v2/main/ride/.DS_Store
vendored
Normal file
BIN
walletintaleq.intaleq.xyz/v2/main/ride/.DS_Store
vendored
Normal file
Binary file not shown.
72
walletintaleq.intaleq.xyz/v2/main/ride/GeminiAi.php
Normal file
72
walletintaleq.intaleq.xyz/v2/main/ride/GeminiAi.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
class GeminiAi {
|
||||
private $apiKey;
|
||||
// Updated to the requested model
|
||||
private $model = "gemini-flash-lite-latest";
|
||||
private $baseUrl = "https://generativelanguage.googleapis.com/v1beta/models/";
|
||||
|
||||
public function __construct($apiKey) {
|
||||
if (empty($apiKey)) {
|
||||
throw new Exception("Gemini API Key is missing.");
|
||||
}
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
public function verifyPayment($invoiceNumber, $amount, $paymentMethod, $proofText, $proofImageBase64 = '') {
|
||||
$prompt = "You are a financial verifier. The user claims they transferred $amount via $paymentMethod for invoice $invoiceNumber. ";
|
||||
if (!empty($proofText)) {
|
||||
$prompt .= "Here is their proof text: '$proofText'. ";
|
||||
}
|
||||
$prompt .= "Does the provided proof clearly indicate a successful transfer of $amount? Respond ONLY with a valid JSON object: {\"verified\": true/false, \"reason\": \"your reasoning\"}.";
|
||||
|
||||
$parts = [["text" => $prompt]];
|
||||
|
||||
if (!empty($proofImageBase64)) {
|
||||
$parts[] = [
|
||||
"inline_data" => [
|
||||
"mime_type" => "image/jpeg",
|
||||
"data" => $proofImageBase64
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$reqData = [
|
||||
"contents" => [
|
||||
[
|
||||
"parts" => $parts
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$url = $this->baseUrl . $this->model . ":generateContent?key=" . $this->apiKey;
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($reqData));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($httpCode !== 200) {
|
||||
error_log("Gemini API Error: " . $response);
|
||||
throw new Exception("AI Verification service unavailable. Details: " . $response);
|
||||
}
|
||||
|
||||
$resData = json_decode($response, true);
|
||||
$aiText = $resData['candidates'][0]['content']['parts'][0]['text'] ?? '';
|
||||
|
||||
// Clean AI Text (remove markdown json block if exists)
|
||||
$aiText = preg_replace('/```json|```/', '', $aiText);
|
||||
$aiResult = json_decode(trim($aiText), true);
|
||||
|
||||
if ($aiResult && isset($aiResult['verified'])) {
|
||||
return $aiResult;
|
||||
}
|
||||
|
||||
throw new Exception("Invalid response format from Gemini: " . $aiText);
|
||||
}
|
||||
}
|
||||
?>
|
||||
48
walletintaleq.intaleq.xyz/v2/main/ride/apiKey/get.php
Normal file
48
walletintaleq.intaleq.xyz/v2/main/ride/apiKey/get.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
include "../../connect.php";
|
||||
|
||||
// Load the .env file and set environment variables
|
||||
$env_file = __DIR__ . '/../../.env'; // Ensure the .env file exists and is named correctly
|
||||
if (file_exists($env_file)) {
|
||||
$lines = file($env_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos(trim($line), '#') === 0) {
|
||||
continue; // Skip comments
|
||||
}
|
||||
putenv(trim($line));
|
||||
}
|
||||
}
|
||||
|
||||
// Get the specific key name from the request
|
||||
$keyName = filterRequest('keyName');
|
||||
|
||||
// Fetch the specific environment variable
|
||||
$envValue = getenv($keyName);
|
||||
|
||||
// Include the specific environment key in the output
|
||||
$output = [];
|
||||
if ($keyName && $envValue !== false) {
|
||||
$output[$keyName] = $envValue;
|
||||
printSuccess($output);
|
||||
} else {
|
||||
$apiKeys = getApiKeys($con);
|
||||
if ($apiKeys) {
|
||||
printSuccess($apiKeys);
|
||||
} else {
|
||||
printFailure("No records found or invalid key name");
|
||||
}
|
||||
}
|
||||
|
||||
function getApiKeys($con) {
|
||||
$sql = "SELECT `id`, `name`, `hashed_key` FROM `api_keys`";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
32
walletintaleq.intaleq.xyz/v2/main/ride/cliq/check_status.php
Normal file
32
walletintaleq.intaleq.xyz/v2/main/ride/cliq/check_status.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// --- check_status.php ---
|
||||
include "../../connect.php";
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$invoiceNumber = filterRequest("invoice_number");
|
||||
|
||||
if (empty($invoiceNumber)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice number is required."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $con->prepare("SELECT status FROM click_invoices WHERE invoice_number = :invoice_number LIMIT 1");
|
||||
$stmt->execute([':invoice_number' => $invoiceNumber]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($invoice) {
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"invoice_status" => $invoice['status']
|
||||
]);
|
||||
} else {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice not found."]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Error in check_status.php: " . $e->getMessage());
|
||||
echo json_encode(["status" => "error", "message" => "Server error."]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS cliq_invoices (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
invoice_number VARCHAR(50) NOT NULL UNIQUE,
|
||||
user_id VARCHAR(50) NOT NULL,
|
||||
user_type VARCHAR(20) NOT NULL,
|
||||
amount DECIMAL(10, 2) NOT NULL,
|
||||
cliq_phone VARCHAR(50) NOT NULL,
|
||||
status VARCHAR(20) DEFAULT 'pending',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||
);
|
||||
86
walletintaleq.intaleq.xyz/v2/main/ride/cliq/cliq_webhook_handler.php
Executable file
86
walletintaleq.intaleq.xyz/v2/main/ride/cliq/cliq_webhook_handler.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// --- click_webhook_handler.php ---
|
||||
// هذا هو الـ Webhook الرئيسي الذي يستقبل إشعار تأكيد الدفع من Click
|
||||
|
||||
include "../../jwtconnect.php";
|
||||
include "./finalize_payment.php"; // تضمين ملف إتمام العملية
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// **مهم جداً: التحقق من مصدر الطلب**
|
||||
// يجب التحقق من أن هذا الطلب قادم فعلاً من Click وليس من أي طرف آخر
|
||||
// المثال التالي يستخدم مفتاح سري مشترك (Shared Secret)
|
||||
$expectedToken = trim(file_get_contents('/home/intaleq-wallet/.clickKey')); // يجب استبداله بتوكن حقيقي
|
||||
$receivedToken = $_SERVER['HTTP_X_AUTH_TOKEN'] ?? '';
|
||||
|
||||
if ($receivedToken !== $expectedToken) {
|
||||
http_response_code(401); // Unauthorized
|
||||
echo json_encode(["status" => "error", "message" => "Authentication failed."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// قراءة البيانات القادمة من Click (عادة تكون بصيغة JSON في الـ body)
|
||||
$json_data = file_get_contents('php://input');
|
||||
$data = json_decode($json_data, true);
|
||||
|
||||
$invoiceNumber = $data['invoice_number'] ?? null;
|
||||
$transactionId = $data['transaction_id'] ?? null;
|
||||
$paymentStatus = $data['status'] ?? null;
|
||||
|
||||
if (empty($invoiceNumber) || empty($transactionId) || $paymentStatus !== 'success') {
|
||||
http_response_code(400); // Bad Request
|
||||
echo json_encode(["status" => "error", "message" => "Missing or invalid payment data."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$con->beginTransaction();
|
||||
|
||||
// 1. البحث عن الفاتورة وتحديث حالتها
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `click_invoices`
|
||||
SET `status` = 'completed', `click_transaction_id` = :transaction_id
|
||||
WHERE `invoice_number` = :invoice_number AND `status` = 'pending'"
|
||||
);
|
||||
$stmt->execute([
|
||||
':transaction_id' => $transactionId,
|
||||
':invoice_number' => $invoiceNumber
|
||||
]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// تم تحديث الفاتورة بنجاح، الآن نقوم بإتمام العملية
|
||||
$invoiceId = $con->lastInsertId(); // ملاحظة: هذا قد لا يعمل دائماً مع UPDATE، الأفضل جلب الـ ID
|
||||
|
||||
// جلب ID الفاتورة بعد التأكد من وجودها
|
||||
$idStmt = $con->prepare("SELECT id FROM `click_invoices` WHERE `invoice_number` = :invoice_number");
|
||||
$idStmt->execute([':invoice_number' => $invoiceNumber]);
|
||||
$invoiceRecord = $idStmt->fetch();
|
||||
$invoiceId = $invoiceRecord['id'];
|
||||
|
||||
$finalizationResult = finalizeClickPayment($con, $invoiceId);
|
||||
|
||||
if ($finalizationResult['success']) {
|
||||
$con->commit();
|
||||
echo json_encode(["status" => "success", "message" => "Transaction finalized."]);
|
||||
} else {
|
||||
$con->rollBack();
|
||||
// يجب هنا التعامل مع الحالة التي فشل فيها الإيداع رغم نجاح الدفع
|
||||
error_log("CRITICAL: Payment received for invoice {$invoiceNumber} but finalization failed.");
|
||||
http_response_code(500);
|
||||
echo json_encode(["status" => "error", "message" => "Finalization failed."]);
|
||||
}
|
||||
} else {
|
||||
// لم يتم العثور على فاتورة معلقة بهذا الرقم (ربما تمت معالجتها سابقاً)
|
||||
$con->rollBack();
|
||||
http_response_code(404);
|
||||
echo json_encode(["status" => "error", "message" => "Invoice not found or already processed."]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$con->rollBack();
|
||||
error_log("Error in click_webhook_handler.php: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(["status" => "error", "message" => "An internal server error occurred."]);
|
||||
}
|
||||
|
||||
?>
|
||||
92
walletintaleq.intaleq.xyz/v2/main/ride/cliq/create_cliq_invoice.php
Executable file
92
walletintaleq.intaleq.xyz/v2/main/ride/cliq/create_cliq_invoice.php
Executable file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
// --- create_cliq_invoice.php ---
|
||||
include "../../connect.php";
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$userId = filterRequest("user_id");
|
||||
$userType = filterRequest("user_type");
|
||||
$amount = filterRequest("amount");
|
||||
$cliqPhone = filterRequest("cliq_phone");
|
||||
|
||||
if (empty($userId) || empty($userType) || !is_numeric($amount) || $amount <= 0 || empty($cliqPhone)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invalid input provided."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$con->beginTransaction();
|
||||
|
||||
$sel = $con->prepare("
|
||||
SELECT id, invoice_number
|
||||
FROM cliq_invoices
|
||||
WHERE user_id = :uid
|
||||
AND user_type = :utype
|
||||
AND status = 'pending'
|
||||
AND DATE(created_at) = CURRENT_DATE
|
||||
ORDER BY id DESC
|
||||
LIMIT 1
|
||||
");
|
||||
$sel->execute([
|
||||
':uid' => $userId,
|
||||
':utype' => $userType,
|
||||
]);
|
||||
$existing = $sel->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($existing) {
|
||||
$upd = $con->prepare("
|
||||
UPDATE cliq_invoices
|
||||
SET amount = :amount,
|
||||
cliq_phone = :cliq_phone,
|
||||
updated_at = NOW()
|
||||
WHERE id = :id
|
||||
");
|
||||
$upd->execute([
|
||||
':amount' => $amount,
|
||||
':cliq_phone' => $cliqPhone,
|
||||
':id' => $existing['id'],
|
||||
]);
|
||||
|
||||
$con->commit();
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Invoice updated.",
|
||||
"invoice_number" => $existing['invoice_number'],
|
||||
"mode" => "updated"
|
||||
]);
|
||||
} else {
|
||||
$invoiceNumber = "CLIQ-" . time() . mt_rand(100, 999);
|
||||
|
||||
$ins = $con->prepare("
|
||||
INSERT INTO cliq_invoices
|
||||
(invoice_number, user_id, user_type, amount, cliq_phone, status, created_at, updated_at)
|
||||
VALUES
|
||||
(:invoice_number, :user_id, :user_type, :amount, :cliq_phone, 'pending', NOW(), NOW())
|
||||
");
|
||||
$ins->execute([
|
||||
':invoice_number' => $invoiceNumber,
|
||||
':user_id' => $userId,
|
||||
':user_type' => $userType,
|
||||
':amount' => $amount,
|
||||
':cliq_phone' => $cliqPhone
|
||||
]);
|
||||
|
||||
$con->commit();
|
||||
|
||||
$cliqAlias = $_ENV['CLIQ_ALIAS'] ?? getenv('CLIQ_ALIAS') ?: 'siro_cliq';
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Invoice created successfully.",
|
||||
"invoice_number" => $invoiceNumber,
|
||||
"cliq_alias" => $cliqAlias,
|
||||
"mode" => "inserted"
|
||||
]);
|
||||
}
|
||||
|
||||
} catch (Throwable $e) {
|
||||
if ($con && $con->inTransaction()) { $con->rollBack(); }
|
||||
error_log("Error in create_cliq_invoice.php: " . $e->getMessage());
|
||||
echo json_encode(["status" => "failure", "message" => "An internal server error occurred."]);
|
||||
}
|
||||
?>
|
||||
106
walletintaleq.intaleq.xyz/v2/main/ride/cliq/finalize_payment.php
Executable file
106
walletintaleq.intaleq.xyz/v2/main/ride/cliq/finalize_payment.php
Executable file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// --- finalize_payment.php ---
|
||||
// يحتوي على الدوال المنطقية لإضافة الرصيد للمستخدمين بعد تأكيد الدفع
|
||||
|
||||
// ملاحظة: هذا الملف لا يتم استدعاؤه مباشرة، بل يتم تضمينه في mtn_webhook_handler.php
|
||||
|
||||
/**
|
||||
* دالة مركزية لإتمام الدفع بعد التحقق منه
|
||||
* @param PDO $con اتصال قاعدة البيانات
|
||||
* @param int $invoiceId معرّف الفاتورة في جدول mtn_invoices
|
||||
* @return array نتيجة العملية
|
||||
*/
|
||||
function finalizeClickPayment(PDO $con, int $invoiceId): array
|
||||
{
|
||||
try {
|
||||
// جلب تفاصيل الفاتورة
|
||||
$stmt = $con->prepare("SELECT * FROM `click_invoices` WHERE id = :id AND status = 'completed' LIMIT 1");
|
||||
$stmt->execute([':id' => $invoiceId]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$invoice) {
|
||||
return ['success' => false, 'message' => 'Invoice not found or not completed.'];
|
||||
}
|
||||
|
||||
$userType = $invoice['user_type'];
|
||||
$userId = $invoice['user_id'];
|
||||
$amount = (float) $invoice['amount'];
|
||||
$paymentMethod = 'click_cash'; // تحديد طريقة الدفع
|
||||
|
||||
// تحديد ما إذا كان المستخدم سائقاً أم راكباً
|
||||
if ($userType === 'driver') {
|
||||
return finalizeForDriver($con, $userId, $amount, $paymentMethod);
|
||||
} elseif ($userType === 'passenger') {
|
||||
return finalizeForPassenger($con, $userId, $amount, $paymentMethod);
|
||||
} else {
|
||||
return ['success' => false, 'message' => 'Unknown user type.'];
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Finalization Exception: " . $e->getMessage());
|
||||
return ['success' => false, 'message' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
// --- دوال مساعدة خاصة بالسائق ---
|
||||
function finalizeForDriver(PDO $con, int $driverId, float $amount, string $paymentMethod): array
|
||||
{
|
||||
// حساب قيمة البونص كما في الكود الأصلي
|
||||
$bonusAmount = match ((int)$amount) {
|
||||
10000 => 10000.0,
|
||||
20000 => 21000.0,
|
||||
40000 => 45000.0,
|
||||
100000 => 110000.0,
|
||||
default => $amount,
|
||||
};
|
||||
|
||||
// إنشاء سجل دفع جديد والحصول على ID
|
||||
$paymentID = generatePaymentID($con, $driverId, $bonusAmount, $paymentMethod);
|
||||
if (!$paymentID) throw new Exception('Failed to generate payment ID for driver.');
|
||||
|
||||
// إضافة الرصيد لمحفظة السائق
|
||||
$stmtDriver = $con->prepare("INSERT INTO driverWallet (driverID, paymentID, amount, paymentMethod) VALUES (:driverID, :paymentID, :amount, :paymentMethod)");
|
||||
$stmtDriver->execute([':driverID' => $driverId, ':paymentID' => $paymentID, ':amount' => $bonusAmount, ':paymentMethod' => $paymentMethod]);
|
||||
if ($stmtDriver->rowCount() === 0) throw new Exception('Insert to driverWallet failed.');
|
||||
|
||||
// إضافة سجل محاسبي لمحفظة سفر
|
||||
$stmtSefer = $con->prepare("INSERT INTO seferWallet (driverId, passengerId, amount, paymentMethod) VALUES (:driverId, 'driver', :amount, :paymentMethod)");
|
||||
$stmtSefer->execute([':driverId' => $driverId, ':amount' => $amount, ':paymentMethod' => $paymentMethod]);
|
||||
if ($stmtSefer->rowCount() === 0) throw new Exception('Insert to seferWallet failed.');
|
||||
|
||||
return ['success' => true, 'message' => 'Driver wallets updated.'];
|
||||
}
|
||||
|
||||
function generatePaymentID(PDO $con, string $driverId, float $amount, string $method): ?string {
|
||||
$stmt = $con->prepare("INSERT INTO paymentsDriverPoints (`amount`, `payment_method`, `driverID`) VALUES (:amount, :method, :driverID)");
|
||||
$stmt->execute([':driverID' => $driverId, ':amount' => $amount, ':method' => $method]);
|
||||
return $stmt->rowCount() > 0 ? $con->lastInsertId() : null;
|
||||
}
|
||||
|
||||
|
||||
// --- دوال مساعدة خاصة بالراكب ---
|
||||
function finalizeForPassenger(PDO $con, string $passengerId, float $amount, string $paymentMethod): array
|
||||
{
|
||||
// حساب البونص للراكب
|
||||
$finalAmount = calculatePassengerBonus($amount);
|
||||
|
||||
// إضافة الرصيد لمحفظة الراكب
|
||||
$stmtPassenger = $con->prepare("INSERT INTO passengerWallet (passenger_id, balance) VALUES (:id, :amount) ON DUPLICATE KEY UPDATE balance = balance + :amount");
|
||||
$stmtPassenger->execute([':id' => $passengerId, ':amount' => $finalAmount]);
|
||||
if ($stmtPassenger->rowCount() === 0) throw new Exception('Update passengerWallet failed.');
|
||||
|
||||
// إضافة سجل محاسبي لمحفظة سفر
|
||||
$stmtSefer = $con->prepare("INSERT INTO seferWallet (passengerId, driverId, amount, paymentMethod) VALUES (:passengerId, 'passenger', :amount, :paymentMethod)");
|
||||
$stmtSefer->execute([':passengerId' => $passengerId, ':amount' => $amount, ':paymentMethod' => $paymentMethod]);
|
||||
if ($stmtSefer->rowCount() === 0) throw new Exception('Insert to seferWallet for passenger failed.');
|
||||
|
||||
return ['success' => true, 'message' => 'Passenger wallets updated.'];
|
||||
}
|
||||
|
||||
function calculatePassengerBonus(float $amount): float {
|
||||
if ($amount == 20000) return 20500;
|
||||
if ($amount == 40000) return 42500;
|
||||
if ($amount == 100000) return 104000;
|
||||
return $amount;
|
||||
}
|
||||
?>
|
||||
64
walletintaleq.intaleq.xyz/v2/main/ride/cliq/query_click_invoice.php
Executable file
64
walletintaleq.intaleq.xyz/v2/main/ride/cliq/query_click_invoice.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// --- query_click_invoice.php ---
|
||||
// هذا السكربت هو نقطة الـ Webhook التي سيستدعيها نظام Click
|
||||
// للاستعلام عن وجود فاتورة دفع معلقة للمستخدم قبل أن يدفع
|
||||
|
||||
include "../../jwtconnect.php"; // تأكد من أن هذا المسار صحيح
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// يمكن إضافة طبقة حماية هنا للتحقق من أن الطلب قادم من سيرفرات Click
|
||||
// مثلاً عبر التحقق من IP أو من وجود Secret Key في الـ Headers
|
||||
// --- آلية الحماية ---
|
||||
$shared_secret_key = trim(file_get_contents('/home/intaleq-wallet/.clickKey'));
|
||||
$receivedToken = $_SERVER['HTTP_X_AUTH_TOKEN'] ?? '';
|
||||
|
||||
if ($receivedToken !== $shared_secret_key) {
|
||||
http_response_code(401); // Unauthorized
|
||||
echo json_encode(['status' => 'error', 'message' => 'Authentication failed. Invalid or missing token.']);
|
||||
exit;
|
||||
}
|
||||
try {
|
||||
// يفترض أن Click سترسل رقم هاتف المستخدم للاستعلام عنه
|
||||
//$clickPhone = filterRequest("click_phone");
|
||||
$clickPhone = $_GET['phone_number'] ?? null;
|
||||
|
||||
if (empty($clickPhone)) {
|
||||
echo json_encode(["status" => "error", "message" => "Phone number is required."]);
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
// البحث عن فاتورة معلقة لهذا الرقم
|
||||
$stmt = $con->prepare(
|
||||
"SELECT invoice_number, amount, user_id, user_type
|
||||
FROM `click_invoices`
|
||||
WHERE `click_phone` = :click_phone AND `status` = 'pending'
|
||||
ORDER BY `created_at` DESC LIMIT 1"
|
||||
);
|
||||
$stmt->execute([':click_phone' => $clickPhone]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($invoice) {
|
||||
// تم العثور على فاتورة، يتم إرجاع تفاصيلها لنظام Click
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"statusInvoice" => "pending",
|
||||
"invoice_number" => $invoice['invoice_number'],
|
||||
"amount" => (float) $invoice['amount'],
|
||||
"description" => "شحن نقاط في تطبيق انطلق", // وصف يظهر للمستخدم في تطبيق Click
|
||||
"biller_name" => "Intaleq App"
|
||||
|
||||
]);
|
||||
} else {
|
||||
// لا توجد فاتورة معلقة
|
||||
echo json_encode(["status" => "error", "message" => "No pending invoice found for this number."]);
|
||||
http_response_code(404);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Error in query_click_invoice.php: " . $e->getMessage());
|
||||
echo json_encode(["status" => "error", "message" => "Internal server error."]);
|
||||
http_response_code(500);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
// --- verify_payment_ai.php ---
|
||||
include "../../connect.php";
|
||||
include "./finalize_payment.php";
|
||||
include "../GeminiAi.php";
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$json_data = file_get_contents('php://input');
|
||||
$data = json_decode($json_data, true) ?: $_POST;
|
||||
|
||||
$invoiceNumber = $data['invoice_number'] ?? '';
|
||||
$proofText = $data['proof_text'] ?? '';
|
||||
$proofImageBase64 = $data['proof_image_base64'] ?? '';
|
||||
|
||||
if (empty($invoiceNumber)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice number is required."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($proofText) && empty($proofImageBase64)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Proof text or image is required."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $con->prepare("SELECT id, amount FROM cliq_invoices WHERE invoice_number = :inv AND status = 'pending'");
|
||||
$stmt->execute([':inv' => $invoiceNumber]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$invoice) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice not found or already processed."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$amount = $invoice['amount'];
|
||||
|
||||
$geminiKey = $_ENV['GEMINI_API_KEY'] ?? getenv('GEMINI_API_KEY') ?: '';
|
||||
|
||||
if (empty($geminiKey)) {
|
||||
echo json_encode(["status" => "error", "message" => "Gemini API key not configured."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$gemini = new GeminiAi($geminiKey);
|
||||
$aiResult = $gemini->verifyPayment($invoiceNumber, $amount, "Cliq", $proofText, $proofImageBase64);
|
||||
|
||||
if (isset($aiResult['verified']) && $aiResult['verified'] === true) {
|
||||
$con->beginTransaction();
|
||||
$upd = $con->prepare("UPDATE cliq_invoices SET status = 'completed', updated_at = NOW() WHERE id = :id AND status = 'pending'");
|
||||
$upd->execute([':id' => $invoice['id']]);
|
||||
|
||||
if ($upd->rowCount() > 0) {
|
||||
$finalizationResult = finalizeClickPayment($con, $invoice['id']); // assume finalizeClickPayment exists in finalize_payment.php or rename it
|
||||
if ($finalizationResult['success']) {
|
||||
$con->commit();
|
||||
echo json_encode(["status" => "success", "message" => "Payment verified and finalized."]);
|
||||
} else {
|
||||
$con->rollBack();
|
||||
echo json_encode(["status" => "error", "message" => "Verification succeeded but finalization failed."]);
|
||||
}
|
||||
} else {
|
||||
$con->rollBack();
|
||||
echo json_encode(["status" => "error", "message" => "Invoice already processed."]);
|
||||
}
|
||||
} else {
|
||||
$reason = $aiResult['reason'] ?? "AI rejected the proof.";
|
||||
echo json_encode(["status" => "failure", "message" => "Verification failed: $reason"]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Error in cliq verify: " . $e->getMessage());
|
||||
echo json_encode(["status" => "error", "message" => "Server error: " . $e->getMessage()]);
|
||||
}
|
||||
?>
|
||||
25
walletintaleq.intaleq.xyz/v2/main/ride/driverPayment/add.php
Normal file
25
walletintaleq.intaleq.xyz/v2/main/ride/driverPayment/add.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
//ridedriverPayment/add.php
|
||||
$amount = filterRequest("amount");
|
||||
$paymentMethod = filterRequest("payment_method");
|
||||
$driverID = filterRequest("driverID");
|
||||
|
||||
$sql = "INSERT INTO `paymentsDriverPoints` (`amount`, `payment_method`, `driverID`)
|
||||
VALUES ('$amount', '$paymentMethod', '$driverID')";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
|
||||
$insertedID = $con->lastInsertId(); // Get the last inserted ID
|
||||
printSuccess($message = $insertedID);
|
||||
} else {
|
||||
$response = array(
|
||||
"success" => false,
|
||||
"message" => "Failed to save payment data"
|
||||
);
|
||||
echo json_encode($response);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$sql = "DELETE FROM `paymentsDriverPoints` WHERE `id` = '$id'";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Print a success message
|
||||
echo "Record deleted successfully";
|
||||
} else {
|
||||
// Print a failure message
|
||||
echo "Failed to delete the record";
|
||||
}
|
||||
?>
|
||||
20
walletintaleq.intaleq.xyz/v2/main/ride/driverPayment/get.php
Normal file
20
walletintaleq.intaleq.xyz/v2/main/ride/driverPayment/get.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
$sql = "SELECT `id`, `amount`, `payment_method`, `driverID`, `created_at`, `updated_at`
|
||||
FROM `paymentsDriverPoints`";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
} else {
|
||||
// No records found
|
||||
echo "No records found.";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
$id = filterRequest("id");
|
||||
$amount = filterRequest("amount");
|
||||
$paymentMethod = filterRequest("paymentMethod");
|
||||
$driverID = filterRequest("driverID");
|
||||
|
||||
$sql = "UPDATE `paymentsDriverPoints` SET `amount` = '$amount', `payment_method` = '$paymentMethod',
|
||||
`driverID` = '$driverID' WHERE `id` = '$id'";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Print a success message
|
||||
echo "Record updated successfully";
|
||||
} else {
|
||||
// Print a failure message
|
||||
echo "Failed to update the record";
|
||||
}
|
||||
?>
|
||||
58
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/add.php
Normal file
58
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/add.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
// Include the database connection file
|
||||
include "../../connect.php";
|
||||
//ride/driverWallet/add.php
|
||||
// Get the request parameters
|
||||
$driverID = filterRequest("driverID");
|
||||
$paymentID = filterRequest("paymentID");
|
||||
$amount = filterRequest("amount");
|
||||
$paymentMethod = filterRequest("paymentMethod");
|
||||
$token = filterRequest("token");
|
||||
|
||||
// Retrieve token details from the database
|
||||
$stmt = $con->prepare("SELECT * FROM payment_tokens WHERE token = :token AND isUsed = FALSE");
|
||||
$stmt->execute(array(
|
||||
':token' => $token
|
||||
));
|
||||
|
||||
$tokenData = $stmt->fetch();
|
||||
|
||||
if ($tokenData) {
|
||||
// Add payment to the driver's wallet table
|
||||
$sql = "INSERT INTO `driverWallet` (
|
||||
`driverID`,
|
||||
`paymentID`,
|
||||
`amount`,
|
||||
`paymentMethod`
|
||||
) VALUES (
|
||||
:driverID,
|
||||
:paymentID,
|
||||
:amount,
|
||||
:paymentMethod
|
||||
);";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute(array(
|
||||
':driverID' => $driverID,
|
||||
':paymentID' => $paymentID,
|
||||
':amount' => $amount,
|
||||
':paymentMethod' => $paymentMethod
|
||||
));
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Print a success message
|
||||
printSuccess("Record saved successfully");
|
||||
|
||||
// Mark the token as used in the database
|
||||
$stmt = $con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE id = :tokenID");
|
||||
$stmt->execute(array(
|
||||
':tokenID' => $tokenData['id']
|
||||
));
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure("Failed to save record");
|
||||
}
|
||||
} else {
|
||||
printFailure("Invalid or already used token");
|
||||
}
|
||||
84
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/add300ToDriver.php
Executable file
84
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/add300ToDriver.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
// Include the database connection file
|
||||
include "../../jwtconnect.php";
|
||||
|
||||
//add300ToDriver.php
|
||||
|
||||
// Get the request parameters
|
||||
$driverID = filterRequest("driverID");
|
||||
$paymentID = filterRequest("paymentID");
|
||||
$amount = filterRequest("amount");
|
||||
$paymentMethod = filterRequest("paymentMethod");
|
||||
$phone = filterRequest("phone");
|
||||
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 1) CHECK IF DRIVER ALREADY RECEIVED THIS PAYMENT BEFORE
|
||||
// -------------------------------------------------------------
|
||||
$check = $con->prepare("
|
||||
SELECT id
|
||||
FROM driverWallet
|
||||
WHERE driverID = :driverID AND paymentMethod = :paymentMethod
|
||||
LIMIT 1
|
||||
");
|
||||
|
||||
$check->execute([
|
||||
':driverID' => $driverID,
|
||||
':paymentMethod' => $paymentMethod
|
||||
]);
|
||||
|
||||
if ($check->rowCount() > 0) {
|
||||
// Driver already received this "New Driver" payment
|
||||
printFailure("لقد تم منح هذا الدفع للسائق مسبقاً — لا يمكن تكراره.");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 2) INSERT INTO driverWallet
|
||||
// -------------------------------------------------------------
|
||||
$sql = "INSERT INTO `driverWallet` (
|
||||
`driverID`,
|
||||
`paymentID`,
|
||||
`amount`,
|
||||
`paymentMethod`
|
||||
) VALUES (
|
||||
:driverID,
|
||||
:paymentID,
|
||||
:amount,
|
||||
:paymentMethod
|
||||
);";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute(array(
|
||||
':driverID' => $driverID,
|
||||
':paymentID' => $paymentID,
|
||||
':amount' => $amount,
|
||||
':paymentMethod' => $paymentMethod
|
||||
));
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
|
||||
printSuccess("Record saved successfully");
|
||||
|
||||
// Notify driver
|
||||
$messageBody = "تم إضافة رصيد بقيمة $amount إلى محفظتك بنجاح.";
|
||||
// sendWhatsAppFromServer($phone, $messageBody);
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// 3) INSERT 30,000 POINTS FOR NEW DRIVER
|
||||
// -------------------------------------------------------------
|
||||
$sqlPoints = "INSERT INTO `paymentsDriverPoints`
|
||||
(`amount`, `payment_method`, `driverID`, `created_at`, `updated_at`)
|
||||
VALUES (:amount, :method, :driverID, NOW(), NOW())";
|
||||
|
||||
$stmtPoints = $con->prepare($sqlPoints);
|
||||
$stmtPoints->execute(array(
|
||||
':amount' => 300,
|
||||
':method' => $paymentMethod,
|
||||
':driverID' => $driverID
|
||||
));
|
||||
|
||||
} else {
|
||||
printFailure("Failed to save record");
|
||||
}
|
||||
51
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/addFromAdmin.php
Executable file
51
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/addFromAdmin.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
// Include the database connection file
|
||||
include "../../jwtconnect.php";
|
||||
//ride/driverWallet/add.php
|
||||
// Get the request parameters
|
||||
$driverID = filterRequest("driverID");
|
||||
$paymentID = filterRequest("paymentID");
|
||||
$amount = filterRequest("amount");
|
||||
$paymentMethod = filterRequest("paymentMethod");
|
||||
$phone = filterRequest("phone");
|
||||
|
||||
|
||||
// Add payment to the driver's wallet table
|
||||
$sql = "INSERT INTO `driverWallet` (
|
||||
`driverID`,
|
||||
`paymentID`,
|
||||
`amount`,
|
||||
`paymentMethod`
|
||||
) VALUES (
|
||||
:driverID,
|
||||
:paymentID,
|
||||
:amount,
|
||||
:paymentMethod
|
||||
);";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute(array(
|
||||
':driverID' => $driverID,
|
||||
':paymentID' => $paymentID,
|
||||
':amount' => $amount,
|
||||
':paymentMethod' => $paymentMethod
|
||||
));
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Print a success message
|
||||
printSuccess("Record saved successfully");
|
||||
$messageBody = "تم إضافة رصيد بقيمة $amount إلى محفظتك بنجاح."; // "Balance of $amount added successfully."
|
||||
|
||||
sendWhatsAppFromServer($phone, $messageBody);
|
||||
|
||||
// Mark the token as used in the database
|
||||
/* $stmt = $con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE id = :tokenID");
|
||||
$stmt->execute(array(
|
||||
':tokenID' => $tokenData['id']
|
||||
));*/
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure("Failed to save record");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
//addPaymentToken.php
|
||||
$driverID = filterRequest("driverID");
|
||||
$amount = filterRequest("amount");
|
||||
|
||||
// Check if required fields are present
|
||||
if ($driverID === null || $amount === null) {
|
||||
printFailure("Missing required fields: driverID and amount must be provided");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Generate a more secure token
|
||||
$token = generateSecureToken($driverID, $amount);
|
||||
|
||||
// Store the token in the database
|
||||
$stmt = $con->prepare("INSERT INTO payment_tokens (token, driverID, dateCreated, amount) VALUES (?, ?, NOW(), ?)");
|
||||
|
||||
try {
|
||||
$stmt->execute([$token, $driverID, $amount]);
|
||||
if ($stmt->rowCount() > 0) {
|
||||
printSuccess($token);
|
||||
} else {
|
||||
printFailure("Failed to save record");
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
printFailure("Database error: " . $e->getMessage());
|
||||
}
|
||||
|
||||
function generateSecureToken($driverID, $amount) {
|
||||
global $secretKey;
|
||||
// Concatenate the parameters
|
||||
$data = $driverID . $amount . time();
|
||||
|
||||
// Add the secret key from the environment variable
|
||||
$data .= $secretKey;
|
||||
|
||||
// Generate a hash
|
||||
$hash = hash('sha256', $data);
|
||||
|
||||
// Add some randomness
|
||||
$randomBytes = bin2hex(random_bytes(16));
|
||||
|
||||
// Combine hash and random bytes
|
||||
$token = $hash . $randomBytes;
|
||||
|
||||
// Truncate to a reasonable length (e.g., 64 characters)
|
||||
return substr($token, 0, 64);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
// ==========================================
|
||||
// Cron Job: Remove Duplicate Records Daily
|
||||
// Tables: driverWallet, paymentsDriverPoints
|
||||
// ==========================================
|
||||
|
||||
// Load DB Connection
|
||||
include "../../jwtconnect.php";
|
||||
|
||||
// Function to run cleanup query
|
||||
function runCleanup($con, $deleteQuery, $tableName) {
|
||||
try {
|
||||
$stmt = $con->prepare($deleteQuery);
|
||||
$stmt->execute();
|
||||
|
||||
echo "Cleanup completed for table: $tableName\n";
|
||||
echo "Rows affected: " . $stmt->rowCount() . "\n\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Error cleaning $tableName: " . $e->getMessage() . "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// DELETE DUPLICATES FOR driverWallet
|
||||
// ==========================================
|
||||
|
||||
$deleteDriverWallet = "
|
||||
DELETE FROM driverWallet
|
||||
WHERE id NOT IN (
|
||||
SELECT id FROM (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER(PARTITION BY driverID ORDER BY dateCreated DESC) AS rn
|
||||
FROM driverWallet
|
||||
) AS subquery
|
||||
WHERE rn = 1
|
||||
);";
|
||||
|
||||
runCleanup($con, $deleteDriverWallet, "driverWallet");
|
||||
|
||||
|
||||
// ==========================================
|
||||
// DELETE DUPLICATES FOR paymentsDriverPoints
|
||||
// ==========================================
|
||||
|
||||
$deletePaymentsPoints = "
|
||||
DELETE FROM paymentsDriverPoints
|
||||
WHERE id NOT IN (
|
||||
SELECT id FROM (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER(PARTITION BY driverID ORDER BY created_at DESC) AS rn
|
||||
FROM paymentsDriverPoints
|
||||
) AS subquery
|
||||
WHERE rn = 1
|
||||
);";
|
||||
|
||||
runCleanup($con, $deletePaymentsPoints, "paymentsDriverPoints");
|
||||
|
||||
echo "Cron job completed successfully.\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$driverID = filterRequest("driverID");
|
||||
|
||||
$sql = "SELECT
|
||||
YEAR(`driver_orders`.`created_at`) AS `year`,
|
||||
MONTH(`driver_orders`.`created_at`) AS `month`,
|
||||
COUNT(*) AS `total_orders`,
|
||||
SUM(CASE WHEN `ride`.`status` = 'Finished' THEN 1 ELSE 0 END) AS `completed_orders`,
|
||||
SUM(CASE WHEN `ride`.`status` = 'Apply' THEN 1 ELSE 0 END) AS `pending_orders`,
|
||||
SUM(CASE WHEN `ride`.`status` = 'Cancel' THEN 1 ELSE 0 END) AS `canceled_orders`,
|
||||
ROUND(SUM(CASE WHEN `ride`.`status` = 'Finished' THEN 1 ELSE 0 END) / COUNT(*) * 100, 2) AS `percent_completed`,
|
||||
ROUND(SUM(CASE WHEN `ride`.`status` = 'Apply' THEN 1 ELSE 0 END) / COUNT(*) * 100, 2) AS `percent_pending`,
|
||||
ROUND(SUM(CASE WHEN `ride`.`status` = 'Cancel' THEN 1 ELSE 0 END) / COUNT(*) * 100, 2) AS `percent_canceled`,
|
||||
SUM(CASE WHEN `ride`.`status` = 'Refused' THEN 1 ELSE 0 END) AS `rejected_orders`,
|
||||
ROUND(SUM(CASE WHEN `ride`.`status` = 'Refused' THEN 1 ELSE 0 END) / COUNT(*) * 100, 2) AS `percent_rejected`
|
||||
FROM
|
||||
`driver_orders`
|
||||
LEFT JOIN `ride` ON `ride`.`id` = `driver_orders`.`order_id`
|
||||
WHERE
|
||||
`driver_orders`.`driver_id` = '$driverID'
|
||||
AND YEAR(`driver_orders`.`created_at`) = YEAR(CURDATE())
|
||||
AND MONTH(`driver_orders`.`created_at`) = MONTH(CURDATE())
|
||||
GROUP BY
|
||||
YEAR(`driver_orders`.`created_at`),
|
||||
MONTH(`driver_orders`.`created_at`)
|
||||
ORDER BY
|
||||
`year`,
|
||||
`month`;
|
||||
|
||||
";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
42
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/get.php
Normal file
42
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/get.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$driverID = filterRequest("driverID");
|
||||
|
||||
$sql = "SELECT
|
||||
COALESCE(dw.id, 0) AS id,
|
||||
COALESCE(dw.driverID, '0') AS driverID,
|
||||
COALESCE(dw.paymentID, '0') AS paymentID,
|
||||
COALESCE(dw.dateCreated, '1970-01-01 00:00:00') AS dateCreated,
|
||||
COALESCE(dw.amount, 0) AS amount,
|
||||
COALESCE(dw.paymentMethod, '0') AS paymentMethod,
|
||||
COALESCE(dw.dateUpdated, '1970-01-01 00:00:00') AS dateUpdated,
|
||||
COALESCE((SELECT SUM(amount) FROM driverWallet WHERE driverID = '$driverID'), 0) AS total_amount
|
||||
FROM
|
||||
driverWallet dw
|
||||
WHERE
|
||||
dw.driverID = '$driverID'
|
||||
GROUP BY
|
||||
dw.id,
|
||||
dw.driverID,
|
||||
dw.paymentID,
|
||||
dw.dateCreated,
|
||||
dw.amount,
|
||||
dw.paymentMethod,
|
||||
dw.dateUpdated
|
||||
|
||||
";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
$driver_phone = filterRequest("driver_phone");
|
||||
|
||||
$sql = "SELECT
|
||||
`driverToken`.`token`,
|
||||
`driver`.`id`,
|
||||
`driver`.`phone`,
|
||||
`driver`.`name_arabic`as name,
|
||||
driver.national_number
|
||||
FROM
|
||||
`driverToken`
|
||||
LEFT JOIN `driver` ON `driver`.`id` = `driverToken`.`captain_id`
|
||||
WHERE
|
||||
`driver`.`phone` = '$driver_phone'";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($data) {
|
||||
// Print the car location data as JSON
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
|
||||
'data' => $data
|
||||
]);
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure($message = "No car locations found");
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$driverID = filterRequest("driverID");
|
||||
|
||||
$sql = "SELECT
|
||||
`id`,
|
||||
`driverID`,
|
||||
`paymentID`,
|
||||
`dateCreated`,
|
||||
`amount`,
|
||||
`paymentMethod`,
|
||||
`dateUpdated`,
|
||||
(SELECT SUM(`amount`)
|
||||
FROM `driverWallet`
|
||||
WHERE `driverID` = '$driverID'
|
||||
AND `dateCreated` >= DATE_SUB(NOW(), INTERVAL 1 WEEK)
|
||||
) AS totalAmount
|
||||
FROM `driverWallet`
|
||||
WHERE `driverID` = '$driverID'
|
||||
AND `dateCreated` >= DATE_SUB(NOW(), INTERVAL 1 WEEK)
|
||||
ORDER BY `dateCreated` DESC;
|
||||
";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
30
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/getWalletByDriver.php
Executable file
30
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/getWalletByDriver.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$driverID = filterRequest("driverID");
|
||||
|
||||
$sql = "SELECT
|
||||
driverWallet.`id`,
|
||||
driverWallet.amount,
|
||||
driverWallet.dateCreated as created_at
|
||||
FROM
|
||||
`driverWallet`
|
||||
WHERE
|
||||
driverWallet.driverID = '$driverID' AND driverWallet.dateCreated >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
|
||||
ORDER BY
|
||||
`driverWallet`.`id`
|
||||
DESC";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
60
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/promotionDriver.php
Executable file
60
walletintaleq.intaleq.xyz/v2/main/ride/driverWallet/promotionDriver.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
// Include the database connection file
|
||||
include "../../connect.php";
|
||||
|
||||
// Get the request parameters
|
||||
$driver_id = filterRequest("driver_id");
|
||||
$payment_amount = filterRequest("payment_amount");
|
||||
$timePromo = filterRequest("timePromo"); // Example: 'morning' or 'afternoon'
|
||||
//$createdAt = date("Y-m-d H:i:s"); // Get the current date and time
|
||||
$currentDate = date("Y-m-d"); // Current date for comparison
|
||||
|
||||
// Check if a promotion record for the same driver already exists today
|
||||
$sqlCheck = "SELECT COUNT(*) FROM `driver_promotions` WHERE `driver_id` = :driver_id AND DATE(`created_at`) = :current_date
|
||||
and timePromo=:timePromo
|
||||
";
|
||||
$stmtCheck = $con->prepare($sqlCheck);
|
||||
$stmtCheck->execute(array(
|
||||
':driver_id' => $driver_id,
|
||||
':current_date' => $currentDate
|
||||
':timePromo' =>$timePromo
|
||||
));
|
||||
|
||||
$count = $stmtCheck->fetchColumn();
|
||||
|
||||
if ($count > 0) {
|
||||
// A record exists for today, so prevent the insertion
|
||||
printFailure("A promotion record for this driver already exists for today.");
|
||||
} else {
|
||||
// No record exists for today, so insert the new promotion
|
||||
$sqlInsert = "INSERT INTO `driver_promotions` (
|
||||
`driver_id`,
|
||||
`payment_amount`,
|
||||
`timePromo`
|
||||
) VALUES (
|
||||
:driver_id,
|
||||
:payment_amount,
|
||||
:timePromo
|
||||
);";
|
||||
|
||||
// Prepare the insert statement
|
||||
$stmtInsert = $con->prepare($sqlInsert);
|
||||
$stmtInsert->execute(array(
|
||||
':driver_id' => $driver_id,
|
||||
':payment_amount' => $payment_amount,
|
||||
':timePromo' => $timePromo,
|
||||
':createdAt' => $createdAt
|
||||
));
|
||||
|
||||
// Check if the query was successful
|
||||
if ($stmtInsert->rowCount() > 0) {
|
||||
// Print a success message
|
||||
printSuccess("Promotion record saved successfully");
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure("Failed to save promotion record");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
// Connect to database
|
||||
include '../../connect.php';
|
||||
|
||||
// Get trip details
|
||||
$driverName = filterRequest('name');
|
||||
$driverEmail = filterRequest('email');
|
||||
$driverPhone = filterRequest('phone');
|
||||
$amount = filterRequest('amount');
|
||||
$newDriverName = filterRequest('newDriver');
|
||||
$newEmail=filterRequest('newEmail');
|
||||
|
||||
// Get language preference from database or user input
|
||||
$language = 'en'; // Default to English
|
||||
// Email content
|
||||
if ($language === 'ar') {
|
||||
$bodyEmail = "<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f5f8fa;
|
||||
color: #14171a;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: white;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 {
|
||||
color: #1da1f2;
|
||||
margin-top: 0;
|
||||
}
|
||||
p {
|
||||
line-height: 1.5;
|
||||
}
|
||||
a {
|
||||
color: #1da1f2;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='container'>
|
||||
<h1>تفاصيل نقلك على سفر</h1>
|
||||
<p>شكراً لاستخدام خدمتنا. نتمنى لك يوماً رائعاً!</p>
|
||||
<p>نريد إعلامك أن مبلغ $amount تم نقله من حسابك إلى السائق الجديد، $newDriverName (هاتف: $driverPhone).</p>
|
||||
<p>مع خالص التحية،<br> فريق سفر</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
} else {
|
||||
$bodyEmail = "<html>
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f5f8fa;
|
||||
color: #14171a;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: white;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
h1 {
|
||||
color: #1da1f2;
|
||||
margin-top: 0;
|
||||
}
|
||||
p {
|
||||
line-height: 1.5;
|
||||
}
|
||||
a {
|
||||
color: #1da1f2;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='container'>
|
||||
<img src='https://lh3.googleusercontent.com/a/ACg8ocLe5TgvmTjoFx7KjIoWGxX0G2ryKBTzUZi2-mBYb9DI1dsKQ0WEYh5ZPdnA3WeFbp9VnaTNzJuA0w8S4RiQ7042AKrOwXo3=s576-c-no' alt='SEFER App Logo' style='width: 150px; margin: 20px auto; display: block;'>
|
||||
|
||||
<h1>Your SEFER Transfer Details</h1>
|
||||
<p>Thank you for using our service. We hope you have a great day!</p>
|
||||
<p>We want to inform you that an amount of $amount has been transferred from your account to the new driver: $newDriverName (Phone: $driverPhone).</p>
|
||||
<p>Regards,<br> SEFER Team</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
}
|
||||
|
||||
// Email headers
|
||||
$supportEmail = 'seferteam@sefer.live';
|
||||
$headers = "MIME-Version: 1.0\r\n";
|
||||
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
|
||||
$headers .= "From: $supportEmail\r\n";
|
||||
|
||||
// Send email
|
||||
if (!empty($driverEmail)) {
|
||||
if (mail($driverEmail, "Your SEFER Transfer Details", $bodyEmail, $headers)) {
|
||||
|
||||
mail($newEmail, "Your SEFER Transfer Details", $bodyEmail, $headers);
|
||||
echo "Email sent successfully.";
|
||||
} else {
|
||||
echo "Email sending failed.";
|
||||
}
|
||||
} else {
|
||||
echo "Invalid email address: $driverEmail";
|
||||
}
|
||||
148
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/ecash_verify.php
Executable file
148
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/ecash_verify.php
Executable file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
// هذا الملف هو نقطة النهاية بعد الدفع، ويقوم بكل عمليات التحقق وإضافة الرصيد
|
||||
// This file is the final endpoint after payment, handling all verification and balance updates.
|
||||
include "../../../jwtconnect.php";
|
||||
|
||||
// -------------------------------------------------
|
||||
// دوال مساعدة لإنشاء التوكنات ومعرفات الدفع
|
||||
// Helper functions for creating tokens and payment IDs
|
||||
// -------------------------------------------------
|
||||
|
||||
/**
|
||||
* إنشاء توكن فريد لعملية المحفظة وتخزينه في قاعدة البيانات
|
||||
* Creates a unique token for a wallet transaction and stores it in the database.
|
||||
*/
|
||||
define("BASE_URL", "https://wl.tripz-egypt.com/v1/main/ride"); // تأكد من صحة هذا الرابط
|
||||
define("LOG_FILE", "../logs/payment_verification.log");
|
||||
|
||||
function logError($step, $message, $data = null) {
|
||||
$logDir = dirname(LOG_FILE);
|
||||
if (!is_dir($logDir)) { mkdir($logDir, 0755, true); }
|
||||
$logEntry = "[" . date('Y-m-d H:i:s') . "] STEP {$step}: {$message}";
|
||||
if ($data !== null) { $logEntry .= " | Data: " . json_encode($data, JSON_UNESCAPED_UNICODE); }
|
||||
file_put_contents(LOG_FILE, $logEntry . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
function generateToken($con, $driverId, $amount): ?string
|
||||
{
|
||||
global $secretKey; // يفترض أن هذا المتغير متاح من ملف الاتصال
|
||||
$data = $driverId . $amount . time() . ($secretKey ?? 'default_secret');
|
||||
$hash = hash('sha256', $data);
|
||||
$randomBytes = bin2hex(random_bytes(16));
|
||||
$token = substr($hash . $randomBytes, 0, 64);
|
||||
|
||||
$stmt = $con->prepare("INSERT INTO payment_tokens (token, driverID, dateCreated, amount) VALUES (:token, :driverID, NOW(), :amount)");
|
||||
$stmt->execute([':token' => $token, ':driverID' => $driverId, ':amount' => $amount]);
|
||||
return $stmt->rowCount() > 0 ? $token : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* تسجيل دفعة في جدول النقاط وإعادة المعرف الخاص بها
|
||||
* Logs a payment in the points table and returns its ID.
|
||||
*/
|
||||
function generatePaymentID($con, $driverId, $amount, $method): ?string
|
||||
{
|
||||
$stmt = $con->prepare("INSERT INTO paymentsDriverPoints (`amount`, `payment_method`, `driverID`) VALUES (:amount, :method, :driverID)");
|
||||
$stmt->execute([':driverID' => $driverId, ':amount' => $amount, ':method' => $method]);
|
||||
return $stmt->rowCount() > 0 ? $con->lastInsertId() : null;
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------
|
||||
// المنطق الرئيسي للمعالجة
|
||||
// Main processing logic
|
||||
// -------------------------------------------------
|
||||
|
||||
// 1. استقبال الرقم المرجعي من الرابط
|
||||
// 1. Receive the order reference from the URL.
|
||||
$orderRef = $_GET['orderRef'] ?? null;
|
||||
if (empty($orderRef)) {
|
||||
echo "<h1>خطأ: الرقم المرجعي للطلب مفقود.</h1>";
|
||||
exit;
|
||||
}
|
||||
|
||||
// 2. الانتظار والتأكد من وصول الـ Webhook
|
||||
// 2. Wait and verify that the webhook has updated the status.
|
||||
$payment = null;
|
||||
$max_attempts = 5; // محاولة لمدة 10 ثوانٍ - Poll for 10 seconds
|
||||
for ($attempts = 0; $attempts < $max_attempts; $attempts++) {
|
||||
// تأكد من أن اسم الجدول صحيح
|
||||
// Make sure the table name is correct.
|
||||
$stmt = $con->prepare("SELECT * FROM `paymentsLogSyriaDriver` WHERE order_ref = :order_ref AND status = 1 LIMIT 1");
|
||||
$stmt->execute([':order_ref' => $orderRef]);
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($payment) {
|
||||
break; // تم العثور على الدفعة الناجحة - Successful payment found
|
||||
}
|
||||
sleep(2); // الانتظار لمدة ثانيتين قبل المحاولة التالية - Wait 2 seconds before retrying
|
||||
}
|
||||
|
||||
// 3. التحقق من نتيجة البحث
|
||||
// 3. Check the polling result.
|
||||
if (!$payment) {
|
||||
echo "<h1>خطأ في تأكيد الدفع</h1><p>لم نتمكن من تأكيد دفعتك. قد تستغرق العملية بضع لحظات. يرجى التحقق من رصيدك في التطبيق لاحقاً أو التواصل مع الدعم الفني.</p>";
|
||||
exit;
|
||||
}
|
||||
|
||||
// 4. تمت عملية الدفع بنجاح، لنقم بإضافة الرصيد
|
||||
// 4. Payment successful, proceed to add balance.
|
||||
try {
|
||||
$driverId = $payment['user_id'];
|
||||
// eCash لا تحتاج للقسمة على 100
|
||||
// eCash amount does not need division by 100.
|
||||
$originalAmount = floatval($payment['amount']);
|
||||
$paymentMethod = $payment['payment_method'] ?? 'ecash';
|
||||
|
||||
// حساب المكافأة
|
||||
// Calculate the bonus.
|
||||
$bonusAmount = match ((int)$originalAmount) {
|
||||
80 => 80.0,
|
||||
200 => 215.0,
|
||||
400 => 450.0,
|
||||
1000 => 1140.0,
|
||||
default => $originalAmount,
|
||||
};
|
||||
|
||||
// --- تنفيذ منطق تحديث المحافظ ---
|
||||
// --- Execute wallet update logic ---
|
||||
|
||||
$tokenDriver = generateToken($con, $driverId, $bonusAmount);
|
||||
if (!$tokenDriver) throw new Exception('Failed to generate token for driver wallet.');
|
||||
|
||||
$tokenSefer = generateToken($con, $driverId, $originalAmount);
|
||||
if (!$tokenSefer) throw new Exception('Failed to generate token for sefer wallet.');
|
||||
|
||||
$paymentID = generatePaymentID($con, $driverId, $bonusAmount, $paymentMethod);
|
||||
if (!$paymentID) throw new Exception('Failed to generate payment ID.');
|
||||
|
||||
// إضافة الرصيد إلى driverWallet
|
||||
// Add balance to driverWallet
|
||||
$insertDriver = $con->prepare("INSERT INTO driverWallet (driverID, paymentID, amount, paymentMethod) VALUES (:driverID, :paymentID, :amount, :paymentMethod)");
|
||||
$insertDriver->execute([':driverID' => $driverId, ':paymentID' => $paymentID, ':amount' => $bonusAmount, ':paymentMethod' => $paymentMethod]);
|
||||
if ($insertDriver->rowCount() === 0) throw new Exception('Failed to insert into driverWallet.');
|
||||
|
||||
$markTokenDriver = $con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token");
|
||||
$markTokenDriver->execute([':token' => $tokenDriver]);
|
||||
|
||||
// إضافة الرصيد إلى seferWallet
|
||||
// Add balance to seferWallet
|
||||
$insertSefer = $con->prepare("INSERT INTO seferWallet (driverId, passengerId, amount, paymentMethod, token, createdAt) VALUES (:driverId, :passengerId, :amount, :paymentMethod, :token, CURRENT_TIMESTAMP)");
|
||||
$insertSefer->execute([':driverId' => $driverId, ':passengerId' => 'driver', ':amount' => $originalAmount, ':paymentMethod' => $paymentMethod, ':token' => $tokenSefer]);
|
||||
|
||||
$markTokenSefer = $con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token");
|
||||
$markTokenSefer->execute([':token' => $tokenSefer]);
|
||||
|
||||
// 5. عرض صفحة النجاح النهائية
|
||||
// 5. Display final success page.
|
||||
echo "<h1>تمت العملية بنجاح</h1><p>تمت إضافة الرصيد إلى محفظتك. يمكنك الآن العودة إلى التطبيق.</p>";
|
||||
|
||||
} catch (Throwable $e) {
|
||||
// في حال حدوث خطأ، يتم تسجيله وعرض رسالة للمستخدم
|
||||
// In case of an error, log it and display a message to the user.
|
||||
error_log("VERIFY_ERROR: " . $e->getMessage() . " | OrderRef: " . $orderRef);
|
||||
echo "<h1>حدث خطأ</h1><p>لقد تم استلام دفعتك بنجاح، ولكن حدث خطأ أثناء تحديث رصيدك. يرجى التواصل مع الدعم الفني وتزويدهم بالرقم المرجعي: " . htmlspecialchars($orderRef) . "</p>";
|
||||
}
|
||||
|
||||
?>
|
||||
91
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/ecash_webhook.php
Executable file
91
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/ecash_webhook.php
Executable file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
// استخدام ملف اتصال خاص بالـ Webhook لا يحتوي على أي تحقق من الهوية
|
||||
include "../../../jwtconnect.php";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ملف Webhook النهائي الخاص بـ eCash (مع تسجيل إضافي للتصحيح)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// --- الإعدادات ---
|
||||
$ecash_merchant_id = getenv('ECASH_MERCHANT_ID');
|
||||
$ecash_merchant_secret = getenv('ECASH_MERCHANT_SECRET');
|
||||
|
||||
// --- إعداد ملف اللوج (Log File) ---
|
||||
$log_dir = __DIR__ . '/../logs';
|
||||
$log_file = $log_dir . '/ecash_production.log';
|
||||
|
||||
if (!is_dir($log_dir)) {
|
||||
mkdir($log_dir, 0755, true);
|
||||
}
|
||||
|
||||
// --- قراءة البيانات القادمة من eCash ---
|
||||
$raw_body = file_get_contents("php://input");
|
||||
$data = json_decode($raw_body, true);
|
||||
|
||||
// --- تسجيل الـ Callback كاملاً لأغراض المراقبة ---
|
||||
file_put_contents($log_file, "--- NEW WEBHOOK ---\n" . date('Y-m-d H:i:s') . " - RAW BODY: " . $raw_body . PHP_EOL, FILE_APPEND);
|
||||
|
||||
if (!$data || !isset($data['Token'])) {
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- استخراج البيانات ---
|
||||
$isSuccess = $data['IsSuccess'] ?? false;
|
||||
$transactionNo = $data['TransactionNo'] ?? '';
|
||||
$amount = $data['Amount'] ?? '';
|
||||
$orderRef = $data['OrderRef'] ?? '';
|
||||
$receivedToken = $data['Token'];
|
||||
|
||||
// --- **تصحيح الأخطاء: بناء وتسجيل سلسلة التحقق** ---
|
||||
$verification_string = $ecash_merchant_id . $ecash_merchant_secret . $transactionNo . $amount . $orderRef;
|
||||
$expectedToken = strtoupper(md5($verification_string));
|
||||
|
||||
// تسجيل السلسلة المستخدمة في التوقيع والقيم الفردية
|
||||
$debug_log = "VERIFICATION STRING: " . $verification_string . PHP_EOL;
|
||||
$debug_log .= " - Merchant ID Used: " . $ecash_merchant_id . PHP_EOL;
|
||||
$debug_log .= " - TransactionNo Used: " . $transactionNo . PHP_EOL;
|
||||
$debug_log .= " - Amount Used: " . $amount . PHP_EOL;
|
||||
$debug_log .= " - OrderRef Used: " . $orderRef . PHP_EOL;
|
||||
$debug_log .= "CALCULATED TOKEN: " . $expectedToken . PHP_EOL;
|
||||
$debug_log .= "RECEIVED TOKEN: " . $receivedToken . PHP_EOL;
|
||||
|
||||
file_put_contents($log_file, $debug_log, FILE_APPEND);
|
||||
|
||||
|
||||
// --- التحقق من صحة الـ Token ---
|
||||
if (!hash_equals($expectedToken, $receivedToken)) {
|
||||
http_response_code(401);
|
||||
file_put_contents($log_file, "TOKEN MISMATCH! Process stopped." . PHP_EOL, FILE_APPEND);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- تحديث حالة الدفعة في قاعدة البيانات ---
|
||||
file_put_contents($log_file, "TOKEN MATCH! Proceeding to update database." . PHP_EOL, FILE_APPEND);
|
||||
$payment_status = $isSuccess ? 1 : 0;
|
||||
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `paymentsLogSyriaDriver` SET status = :status, updated_at = NOW() WHERE order_ref = :order_ref AND status = 2"
|
||||
);
|
||||
$stmt->execute([
|
||||
':status' => $payment_status,
|
||||
|
||||
':order_ref' => $orderRef
|
||||
]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
http_response_code(200);
|
||||
file_put_contents($log_file, "SUCCESS: Database updated." . PHP_EOL, FILE_APPEND);
|
||||
} else {
|
||||
http_response_code(200);
|
||||
file_put_contents($log_file, "INFO: Order not found or already processed." . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
http_response_code(500);
|
||||
file_put_contents($log_file, "FATAL: Database update failed: " . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
?>
|
||||
79
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/finalize_payment.php
Executable file
79
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/finalize_payment.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// هذا الملف يجب أن يستخدم ملف الاتصال الذي يتحقق من الهوية
|
||||
include "../../../connect.php";
|
||||
// يجب استدعاء دالة التحقق هنا لضمان أن الطلب قادم من تطبيقك فقط
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ملف إتمام الدفع النهائي
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| هذا الملف مسؤول عن:
|
||||
| 1. استقبال طلب من تطبيق فلاتر بعد عودة المستخدم.
|
||||
| 2. التحقق من وجود دفعة ناجحة حديثة للمستخدم في قاعدة البيانات.
|
||||
| 3. حساب المكافآت.
|
||||
| 4. استدعاء واجهات API داخلية لإضافة الرصيد إلى المحافظ.
|
||||
|
|
||||
*/
|
||||
|
||||
// --- استقبال البيانات من تطبيق فلاتر ---
|
||||
$userId = filterRequest("userId"); // أو driverId
|
||||
$paymentMethod = filterRequest("paymentMethod") ?? 'ecash';
|
||||
|
||||
if (empty($userId)) {
|
||||
printFailure("معرّف المستخدم غير صالح.");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// خطوة 1: البحث عن آخر دفعة ناجحة للمستخدم (تم تحديثها بواسطة الـ Webhook)
|
||||
$stmt = $con->prepare(
|
||||
"SELECT * FROM `paymentsLogSyria`
|
||||
WHERE user_id = :user_id
|
||||
AND status = 1
|
||||
AND updated_at >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||
ORDER BY updated_at DESC
|
||||
LIMIT 1"
|
||||
);
|
||||
$stmt->bindParam(':user_id', $userId, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$payment) {
|
||||
printFailure("لم يتم العثور على دفعة ناجحة حديثة.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// خطوة 2: الحصول على المبلغ (لا يحتاج للقسمة على 100)
|
||||
$amount = $payment['amount'];
|
||||
|
||||
// خطوة 3: حساب المكافأة
|
||||
$finalAmount = calculateBonus($amount); // استخدم دالة حساب المكافآت الخاصة بك
|
||||
|
||||
$passengerId = $userId; // نفترض أن معرّف المستخدم هو نفسه معرّف الراكب
|
||||
|
||||
// --- هنا تضع نفس منطق إضافة الرصيد الذي كان في ملف payment_verify.php القديم ---
|
||||
// (مثال)
|
||||
// $token = generatePaymentToken($passengerId, $finalAmount);
|
||||
// addToPassengerWallet($passengerId, $finalAmount, $token);
|
||||
// ... إلخ
|
||||
|
||||
// --- النجاح النهائي ---
|
||||
printSuccess("تمت معالجة الدفع وتحديث الرصيد بنجاح.");
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log("Finalize Payment Error: " . $e->getMessage());
|
||||
printFailure("حدث خطأ في قاعدة البيانات أثناء إتمام العملية.");
|
||||
}
|
||||
|
||||
// --- يمكنك وضع دوال المساعدة هنا (calculateBonus, etc.) ---
|
||||
function calculateBonus($amount) {
|
||||
$result = $amount;
|
||||
if ($amount == 200) $result = 215;
|
||||
else if ($amount == 400) $result = 450;
|
||||
else if ($amount == 100) $result = 100.0;
|
||||
else if ($amount == 1000) $result = 1140;
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
88
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/payWithEcash.php
Executable file
88
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/payWithEcash.php
Executable file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
include "../../../connect.php"; // تأكد من أن هذا الملف يحتوي على الاتصال بقاعدة البيانات ودوال المساعدة
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ملف بدء الدفع مع eCash
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| هذا الملف مسؤول عن:
|
||||
| 1. استقبال طلب الدفع من تطبيق فلاتر (المبلغ ومعرّف المستخدم/السائق).
|
||||
| 2. إنشاء رابط دفع فريد وخاص ببوابة eCash.
|
||||
| 3. حساب رمز التحقق (Verification Code) المطلوب من eCash.
|
||||
| 4. تسجيل محاولة الدفع في قاعدة البيانات بحالة "قيد الانتظار".
|
||||
| 5. إعادة رابط الدفع إلى التطبيق ليتم عرضه في WebView.
|
||||
|
|
||||
*/
|
||||
|
||||
// --- الإعدادات الرئيسية - يجب تخزينها كمتغيرات بيئة (Environment Variables) ---
|
||||
$ecash_merchant_id = getenv('ECASH_MERCHANT_ID'); // معرّف التاجر الخاص بك من eCash
|
||||
$ecash_merchant_secret = getenv('ECASH_MERCHANT_SECRET'); // المفتاح السري الخاص بك من eCash
|
||||
$ecash_terminal_key = getenv('ECASH_TERMINAL_KEY'); // مفتاح المحطة الطرفية (Terminal Key) من eCash
|
||||
$ecash_checkout_url = 'https://checkout.ecash-pay.com/'; //
|
||||
$ecash_checkout_url_stage = 'https://checkout.ecash-pay.co/';//رابط بوابة الدفع
|
||||
$base_app_url = getenv('APP_BASE_URL'); // الرابط الأساسي لواجهة API الخاصة بك
|
||||
|
||||
// --- استقبال البيانات من تطبيق فلاتر ---
|
||||
$amount = filterRequest("amount");
|
||||
$driverId = filterRequest("driverId"); // معرّف السائق أو المستخدم
|
||||
|
||||
// --- التحقق من صحة البيانات المدخلة ---
|
||||
if (empty($amount) || empty($driverId) || !is_numeric($amount) || $amount <= 0) {
|
||||
printFailure("المبلغ أو معرّف المستخدم غير صالح.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- إعداد متغيرات الدفع ---
|
||||
$currency = "SYP"; // العملة حسب متطلبات eCash
|
||||
$lang = "AR"; // لغة واجهة الدفع (AR أو EN)
|
||||
//$orderRef = uniqid($driverId . "_"); // إنشاء رقم مرجعي فريد للطلب لربطه بالمستخدم
|
||||
$orderRef = "tripz_" . $driverId . "_" . time();
|
||||
// --- إنشاء رمز التحقق (Verification Code) ---
|
||||
// هو عبارة عن MD5 لمجموعة من الحقول ويجب أن يكون بأحرف كبيرة
|
||||
$verification_string = $ecash_merchant_id . $ecash_merchant_secret . $amount . $orderRef;
|
||||
$verificationCode = strtoupper(md5($verification_string));
|
||||
|
||||
// --- تحديد روابط إعادة التوجيه والاستدعاء (Redirect & Callback) ---
|
||||
// الرابط الذي يتم توجيه المستخدم إليه بعد إتمام الدفع
|
||||
$redirectUrl = urlencode($base_app_url . "/driver/ecash_verify.php?orderRef=" . $orderRef);
|
||||
// الرابط الذي تستدعيه eCash لإبلاغ سيرفرك بنتيجة العملية (Webhook)
|
||||
$callbackUrl = urlencode($base_app_url . "/driver/ecash_webhook.php");
|
||||
|
||||
// --- بناء رابط الدفع النهائي الخاص بـ eCash ---
|
||||
$paymentUrl = "{$ecash_checkout_url}Checkout/CardCheckout" .
|
||||
"?tk=" . urlencode($ecash_terminal_key) .
|
||||
"&mid=" . urlencode($ecash_merchant_id) .
|
||||
"&vc=" . urlencode($verificationCode) .
|
||||
"&c=" . urlencode($currency) .
|
||||
"&a=" . urlencode($amount) .
|
||||
"&lang=" . urlencode($lang) .
|
||||
"&or=" . urlencode($orderRef) .
|
||||
"&ru=" . $redirectUrl .
|
||||
"&cu=" . $callbackUrl;
|
||||
|
||||
// --- تسجيل العملية المبدئية في قاعدة البيانات ---
|
||||
// هذا يساعد على تتبع الطلب وربطه بالـ callback القادم من eCash
|
||||
// نفترض أن حقل status يقبل القيم: 0=فشل، 1=نجاح، 2=قيد الانتظار
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"INSERT INTO `paymentsLogSyriaDriver`( `user_id`, `amount`, `status`, `order_ref`, `payment_method`, `created_at`)
|
||||
VALUES (:user_id, :amount, 2, :order_ref,'ecash-driver', NOW())"
|
||||
);
|
||||
$stmt->execute([
|
||||
':user_id' => $driverId,
|
||||
':amount' => $amount,
|
||||
':order_ref' => $orderRef
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
error_log("eCash - فشل تسجيل الدفعة المبدئية: " . $e->getMessage());
|
||||
printFailure("حدث خطأ أثناء بدء عملية الدفع. يرجى المحاولة مرة أخرى.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- إعادة رابط الدفع إلى تطبيق فلاتر ---
|
||||
// التطبيق سيستقبل هذا الرابط ويفتحه في WebView
|
||||
// نرسل الرابط داخل حقل 'message' كما يتوقع كود فلاتر
|
||||
printSuccess($paymentUrl);
|
||||
|
||||
?>
|
||||
42
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/webhook_connect.php
Executable file
42
walletintaleq.intaleq.xyz/v2/main/ride/ecash/driver/webhook_connect.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// Load environment variables from .env file
|
||||
// **FIX:** Corrected the path to go up three levels to find the 'vendor' directory
|
||||
require_once realpath(__DIR__ . '/../../../vendor/autoload.php');
|
||||
// **FIX:** Corrected the path to go up two levels to find 'load_env.php'
|
||||
require_once realpath(__DIR__ . '/../../load_env.php');
|
||||
|
||||
$env_file = '/home/tripz-egypt-wl/env/.env';
|
||||
loadEnvironment($env_file);
|
||||
|
||||
// --- CORS Headers ---
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type");
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
$dbname = getenv('dbname');
|
||||
// --- Database Connection ONLY ---
|
||||
try {
|
||||
$dsn = "mysql:host=localhost;dbname=$dbname;charset=utf8mb4";
|
||||
$options = [
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8"
|
||||
];
|
||||
$user = getenv('USER');
|
||||
$pass = getenv('PASS');
|
||||
$con = new PDO($dsn, $user, $pass, $options);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log("Webhook DB Connection Error: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Internal Server Error']);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
44
walletintaleq.intaleq.xyz/v2/main/ride/ecash/ecash_config.php
Executable file
44
walletintaleq.intaleq.xyz/v2/main/ride/ecash/ecash_config.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// --- ecash_config.php ---
|
||||
// Central configuration file for ecash, loading from a .env file.
|
||||
|
||||
// This assumes you have a function or a library (like Dotenv) to load the .env file.
|
||||
|
||||
|
||||
// --- IMPORTANT ---
|
||||
// Define the path to your .env file. Adjust if necessary.
|
||||
//$env_file_path = '/home/tripz-egypt-wl/env/.env'; // Or use realpath(__DIR__ . '/../.env');
|
||||
//loadEnvironment($env_file_path);
|
||||
require "../../connect.php";
|
||||
// --- Load ecash Credentials from Environment Variables ---
|
||||
define('ECASH_MERCHANT_ID', getenv('ECASH_MERCHANT_ID'));
|
||||
define('ECASH_MERCHANT_SECRET', getenv('ECASH_MERCHANT_SECRET'));
|
||||
define('ECASH_TERMINAL_KEY', getenv('ECASH_TERMINAL_KEY'));
|
||||
|
||||
// --- Set Mode (Staging/Live) from Environment Variable ---
|
||||
// Add ECASH_STAGING_MODE=true to your .env for testing
|
||||
$is_staging = getenv('ECASH_STAGING_MODE') === 'false';
|
||||
define('ECASH_STAGING_MODE', $is_staging);
|
||||
|
||||
// --- URLs (Automatically switch based on mode) ---
|
||||
$checkout_base_url = ECASH_STAGING_MODE ? 'https://checkout.ecash-pay.co' : 'https://checkout.ecash-pay.com';
|
||||
define('ECASH_CHECKOUT_URL', $checkout_base_url);
|
||||
|
||||
// --- Your Application URLs (Load from .env or define here) ---
|
||||
// It's best practice to also put these in your .env file.
|
||||
define('APP_BASE_URL', getenv('APP_BASE_URL')); // e.g., https://yourdomain.com/api
|
||||
define('APP_REDIRECT_URL_SUCCESS', APP_BASE_URL . '/success.php');
|
||||
define('APP_CALLBACK_URL', APP_BASE_URL . '/webhook_ecash.php'); // Use a specific webhook for ecash
|
||||
|
||||
// --- Other Settings ---
|
||||
define('ECASH_CURRENCY', 'SYP');
|
||||
define('ECASH_LANG', 'EN'); // 'EN' for English, 'AR' for Arabic
|
||||
|
||||
// --- Basic Validation ---
|
||||
if (!ECASH_MERCHANT_ID || !ECASH_MERCHANT_SECRET || !ECASH_TERMINAL_KEY) {
|
||||
http_response_code(500);
|
||||
error_log("ecash config: Missing one or more required ecash environment variables.");
|
||||
echo json_encode(['status' => 'error', 'message' => 'Payment gateway not configured correctly.']);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,264 @@
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:33:55 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108408","TransactionNo":"2515118257","Amount":"10000.00","Token":"386BBEDFFA3FBCEFCCF7F546FB4BC622"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE2251511825710000.00tripz_109270481246447459618_1753108408
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2515118257
|
||||
- Amount Used: 10000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108408
|
||||
CALCULATED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
RECEIVED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:34:00 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108408","TransactionNo":"2515118257","Amount":"10000.00","Token":"386BBEDFFA3FBCEFCCF7F546FB4BC622"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE2251511825710000.00tripz_109270481246447459618_1753108408
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2515118257
|
||||
- Amount Used: 10000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108408
|
||||
CALCULATED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
RECEIVED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:34:05 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108408","TransactionNo":"2515118257","Amount":"10000.00","Token":"386BBEDFFA3FBCEFCCF7F546FB4BC622"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE2251511825710000.00tripz_109270481246447459618_1753108408
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2515118257
|
||||
- Amount Used: 10000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108408
|
||||
CALCULATED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
RECEIVED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:34:11 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108408","TransactionNo":"2515118257","Amount":"10000.00","Token":"386BBEDFFA3FBCEFCCF7F546FB4BC622"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE2251511825710000.00tripz_109270481246447459618_1753108408
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2515118257
|
||||
- Amount Used: 10000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108408
|
||||
CALCULATED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
RECEIVED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:34:16 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108408","TransactionNo":"2515118257","Amount":"10000.00","Token":"386BBEDFFA3FBCEFCCF7F546FB4BC622"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE2251511825710000.00tripz_109270481246447459618_1753108408
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2515118257
|
||||
- Amount Used: 10000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108408
|
||||
CALCULATED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
RECEIVED TOKEN: 386BBEDFFA3FBCEFCCF7F546FB4BC622
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:38:33 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108680","TransactionNo":"3434918048","Amount":"2000.00","Token":"5E397F3BCFC8DBC277E67BBE909A4C25"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE234349180482000.00tripz_109270481246447459618_1753108680
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 3434918048
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108680
|
||||
CALCULATED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
RECEIVED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:38:38 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108680","TransactionNo":"3434918048","Amount":"2000.00","Token":"5E397F3BCFC8DBC277E67BBE909A4C25"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE234349180482000.00tripz_109270481246447459618_1753108680
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 3434918048
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108680
|
||||
CALCULATED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
RECEIVED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:38:44 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108680","TransactionNo":"3434918048","Amount":"2000.00","Token":"5E397F3BCFC8DBC277E67BBE909A4C25"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE234349180482000.00tripz_109270481246447459618_1753108680
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 3434918048
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108680
|
||||
CALCULATED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
RECEIVED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:38:49 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108680","TransactionNo":"3434918048","Amount":"2000.00","Token":"5E397F3BCFC8DBC277E67BBE909A4C25"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE234349180482000.00tripz_109270481246447459618_1753108680
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 3434918048
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108680
|
||||
CALCULATED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
RECEIVED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:38:54 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753108680","TransactionNo":"3434918048","Amount":"2000.00","Token":"5E397F3BCFC8DBC277E67BBE909A4C25"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE234349180482000.00tripz_109270481246447459618_1753108680
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 3434918048
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753108680
|
||||
CALCULATED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
RECEIVED TOKEN: 5E397F3BCFC8DBC277E67BBE909A4C25
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'payment_id' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:43:55 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753109008","TransactionNo":"2925347460","Amount":"2000.00","Token":"16EC668D7C9A4105D464BC925D0F35B3"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE229253474602000.00tripz_109270481246447459618_1753109008
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2925347460
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753109008
|
||||
CALCULATED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
RECEIVED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:44:00 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753109008","TransactionNo":"2925347460","Amount":"2000.00","Token":"16EC668D7C9A4105D464BC925D0F35B3"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE229253474602000.00tripz_109270481246447459618_1753109008
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2925347460
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753109008
|
||||
CALCULATED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
RECEIVED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:44:06 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753109008","TransactionNo":"2925347460","Amount":"2000.00","Token":"16EC668D7C9A4105D464BC925D0F35B3"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE229253474602000.00tripz_109270481246447459618_1753109008
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2925347460
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753109008
|
||||
CALCULATED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
RECEIVED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:44:11 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753109008","TransactionNo":"2925347460","Amount":"2000.00","Token":"16EC668D7C9A4105D464BC925D0F35B3"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE229253474602000.00tripz_109270481246447459618_1753109008
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2925347460
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753109008
|
||||
CALCULATED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
RECEIVED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:44:16 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753109008","TransactionNo":"2925347460","Amount":"2000.00","Token":"16EC668D7C9A4105D464BC925D0F35B3"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE229253474602000.00tripz_109270481246447459618_1753109008
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2925347460
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753109008
|
||||
CALCULATED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
RECEIVED TOKEN: 16EC668D7C9A4105D464BC925D0F35B3
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
FATAL: Database update failed: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'updated_at' in 'field list'
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 17:51:29 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753109456","TransactionNo":"2487921821","Amount":"2000.00","Token":"1EA870532F15308A41780C06AC852C33"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE224879218212000.00tripz_109270481246447459618_1753109456
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 2487921821
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753109456
|
||||
CALCULATED TOKEN: 1EA870532F15308A41780C06AC852C33
|
||||
RECEIVED TOKEN: 1EA870532F15308A41780C06AC852C33
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 18:54:15 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753113200","TransactionNo":"1725092256","Amount":"2000.00","Token":"983B8B9FDA5947CEE1D16D6ECC29FAF9"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE217250922562000.00tripz_109270481246447459618_1753113200
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 1725092256
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753113200
|
||||
CALCULATED TOKEN: 983B8B9FDA5947CEE1D16D6ECC29FAF9
|
||||
RECEIVED TOKEN: 983B8B9FDA5947CEE1D16D6ECC29FAF9
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 19:06:34 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753113966","TransactionNo":"1477094275","Amount":"2000.00","Token":"01AF3E8E7C921FF72ADB09300971F2D2"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE214770942752000.00tripz_109270481246447459618_1753113966
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 1477094275
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753113966
|
||||
CALCULATED TOKEN: 01AF3E8E7C921FF72ADB09300971F2D2
|
||||
RECEIVED TOKEN: 01AF3E8E7C921FF72ADB09300971F2D2
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 19:15:57 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753114529","TransactionNo":"746605967","Amount":"2000.00","Token":"7102931A8851540F14F4E259751EA776"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE27466059672000.00tripz_109270481246447459618_1753114529
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 746605967
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753114529
|
||||
CALCULATED TOKEN: 7102931A8851540F14F4E259751EA776
|
||||
RECEIVED TOKEN: 7102931A8851540F14F4E259751EA776
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 19:20:54 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753114829","TransactionNo":"10119078","Amount":"2000.00","Token":"11DEB7F0AA5121F048E94CF385D5FC3D"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE2101190782000.00tripz_109270481246447459618_1753114829
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 10119078
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753114829
|
||||
CALCULATED TOKEN: 11DEB7F0AA5121F048E94CF385D5FC3D
|
||||
RECEIVED TOKEN: 11DEB7F0AA5121F048E94CF385D5FC3D
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-21 19:23:26 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_109270481246447459618_1753114985","TransactionNo":"532601241","Amount":"2000.00","Token":"18DCD7E952332EB655B036B0C76EEDC7"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE25326012412000.00tripz_109270481246447459618_1753114985
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 532601241
|
||||
- Amount Used: 2000.00
|
||||
- OrderRef Used: tripz_109270481246447459618_1753114985
|
||||
CALCULATED TOKEN: 18DCD7E952332EB655B036B0C76EEDC7
|
||||
RECEIVED TOKEN: 18DCD7E952332EB655B036B0C76EEDC7
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-22 00:11:03 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_14a51b422c9972299e109c7db5f65a2c_1753132198","TransactionNo":"947634072","Amount":"200000.00","Token":"E6811EE374F921257C45DC84CCCF48DC"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE2947634072200000.00tripz_14a51b422c9972299e109c7db5f65a2c_1753132198
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 947634072
|
||||
- Amount Used: 200000.00
|
||||
- OrderRef Used: tripz_14a51b422c9972299e109c7db5f65a2c_1753132198
|
||||
CALCULATED TOKEN: E6811EE374F921257C45DC84CCCF48DC
|
||||
RECEIVED TOKEN: E6811EE374F921257C45DC84CCCF48DC
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-22 00:17:06 - RAW BODY: {"IsSuccess":false,"Message":"OTP is not valid!","OrderRef":"tripz_14a51b422c9972299e109c7db5f65a2c_1753132598","TransactionNo":"1773754242","Amount":"200000.00","Token":"2654D3390FF25082FF5A8A1BA59D6CDA"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE21773754242200000.00tripz_14a51b422c9972299e109c7db5f65a2c_1753132598
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 1773754242
|
||||
- Amount Used: 200000.00
|
||||
- OrderRef Used: tripz_14a51b422c9972299e109c7db5f65a2c_1753132598
|
||||
CALCULATED TOKEN: 2654D3390FF25082FF5A8A1BA59D6CDA
|
||||
RECEIVED TOKEN: 2654D3390FF25082FF5A8A1BA59D6CDA
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
--- NEW WEBHOOK ---
|
||||
2025-07-22 00:19:54 - RAW BODY: {"IsSuccess":true,"Message":null,"OrderRef":"tripz_14a51b422c9972299e109c7db5f65a2c_1753132768","TransactionNo":"1048082327","Amount":"100000.00","Token":"DCF7C2AEE0A81DB6C5F40C086E396928"}
|
||||
VERIFICATION STRING: UOMACVPA8BQ8U99BRDDONSLAKW2IDSLBTCQFR776E8L55C0DLBYFB6NJJOWJ7FOLWEYQE21048082327100000.00tripz_14a51b422c9972299e109c7db5f65a2c_1753132768
|
||||
- Merchant ID Used: UOMACV
|
||||
- TransactionNo Used: 1048082327
|
||||
- Amount Used: 100000.00
|
||||
- OrderRef Used: tripz_14a51b422c9972299e109c7db5f65a2c_1753132768
|
||||
CALCULATED TOKEN: DCF7C2AEE0A81DB6C5F40C086E396928
|
||||
RECEIVED TOKEN: DCF7C2AEE0A81DB6C5F40C086E396928
|
||||
TOKEN MATCH! Proceeding to update database.
|
||||
SUCCESS: Database updated.
|
||||
@@ -0,0 +1,9 @@
|
||||
[2025-07-21 17:38:50] STEP VERIFY: لم يتم تأكيد الدفع بعد عدة محاولات | Data: {"orderRef":"tripz_109270481246447459618_1753108680"}
|
||||
[2025-07-21 17:38:56] STEP VERIFY: لم يتم تأكيد الدفع بعد عدة محاولات | Data: {"orderRef":"tripz_109270481246447459618_1753108680"}
|
||||
[2025-07-21 17:44:13] STEP VERIFY: لم يتم تأكيد الدفع بعد عدة محاولات | Data: {"orderRef":"tripz_109270481246447459618_1753109008"}
|
||||
[2025-07-21 17:51:41] STEP VERIFY: اكتملت العملية بنجاح | Data: {"orderRef":"tripz_109270481246447459618_1753109456","userId":"109270481246447459618"}
|
||||
[2025-07-21 19:06:39] STEP VERIFY: اكتملت العملية بنجاح | Data: {"orderRef":"tripz_109270481246447459618_1753113966","userId":"109270481246447459618"}
|
||||
[2025-07-21 19:20:58] STEP VERIFY: اكتملت العملية بنجاح | Data: {"orderRef":"tripz_109270481246447459618_1753114829","userId":"109270481246447459618"}
|
||||
[2025-07-21 19:23:30] STEP VERIFY: اكتملت العملية بنجاح | Data: {"orderRef":"tripz_109270481246447459618_1753114985","userId":"109270481246447459618"}
|
||||
[2025-07-22 00:11:08] STEP VERIFY: اكتملت العملية بنجاح | Data: {"orderRef":"tripz_14a51b422c9972299e109c7db5f65a2c_1753132198","userId":"14a51b422c9972299e109c7db5f65a2c"}
|
||||
[2025-07-22 00:20:01] STEP VERIFY: اكتملت العملية بنجاح | Data: {"orderRef":"tripz_14a51b422c9972299e109c7db5f65a2c_1753132768","userId":"14a51b422c9972299e109c7db5f65a2c"}
|
||||
181
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/ecash_verify.php
Executable file
181
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/ecash_verify.php
Executable file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
// هذا الملف هو نقطة النهاية بعد الدفع، ويقوم بكل عمليات التحقق وإضافة الرصيد
|
||||
include "../../../jwtconnect.php";
|
||||
|
||||
define("BASE_URL", "https://wl.tripz-egypt.com/v1/main/ride");
|
||||
define("LOG_FILE", "../logs/payment_verification.log");
|
||||
|
||||
function logError($step, $message, $data = null) {
|
||||
$logDir = dirname(LOG_FILE);
|
||||
if (!is_dir($logDir)) { mkdir($logDir, 0755, true); }
|
||||
$logEntry = "[" . date('Y-m-d H:i:s') . "] STEP {$step}: {$message}";
|
||||
if ($data !== null) { $logEntry .= " | Data: " . json_encode($data, JSON_UNESCAPED_UNICODE); }
|
||||
file_put_contents(LOG_FILE, $logEntry . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
function showHTMLPage($type, $title, $message) {
|
||||
$color = $type === 'success' ? '#28a745' : '#dc3545';
|
||||
$icon = $type === 'success' ? '✔' : '✖';
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ar" dir="rtl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><?= htmlspecialchars($title) ?></title>
|
||||
<style>
|
||||
body {
|
||||
background-color: #f4f6f9;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
text-align: center;
|
||||
padding-top: 100px;
|
||||
color: #333;
|
||||
}
|
||||
.container {
|
||||
background: #fff;
|
||||
padding: 40px 30px;
|
||||
margin: auto;
|
||||
max-width: 450px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 8px 20px rgba(0,0,0,0.1);
|
||||
animation: fadeIn 1s ease-out;
|
||||
}
|
||||
.icon {
|
||||
font-size: 64px;
|
||||
color: <?= $color ?>;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
h1 {
|
||||
font-size: 28px;
|
||||
color: <?= $color ?>;
|
||||
}
|
||||
p {
|
||||
font-size: 18px;
|
||||
margin-top: 10px;
|
||||
color: #555;
|
||||
}
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(-20px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="icon"><?= $icon ?></div>
|
||||
<h1><?= htmlspecialchars($title) ?></h1>
|
||||
<p><?= htmlspecialchars($message) ?></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$orderRef = $_GET['orderRef'] ?? null;
|
||||
if (empty($orderRef)) {
|
||||
showHTMLPage("error", "خطأ في الرابط", "الرقم المرجعي للطلب غير موجود.");
|
||||
}
|
||||
|
||||
$payment = null;
|
||||
$max_attempts = 5;
|
||||
for ($attempts = 0; $attempts < $max_attempts; $attempts++) {
|
||||
$stmt = $con->prepare("SELECT * FROM `paymentsLogSyria` WHERE order_ref = :order_ref AND status = 1 LIMIT 1");
|
||||
$stmt->execute([':order_ref' => $orderRef]);
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if ($payment) break;
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
if (!$payment) {
|
||||
logError("VERIFY", "لم يتم تأكيد الدفع بعد عدة محاولات", ["orderRef" => $orderRef]);
|
||||
showHTMLPage("error", "لم يتم تأكيد الدفع", "لم نتمكن من تأكيد دفعتك بعد. قد تستغرق العملية بضع لحظات. يرجى التحقق من رصيدك في التطبيق لاحقاً أو التواصل مع الدعم الفني.");
|
||||
}
|
||||
|
||||
try {
|
||||
$userId = $payment['user_id'];
|
||||
$amount = $payment['amount'];
|
||||
$paymentMethod = $payment['payment_method'] ?? 'ecash';
|
||||
|
||||
$finalAmount = calculateBonus($amount);
|
||||
|
||||
$token = generatePaymentToken($userId, $finalAmount);
|
||||
if (!$token) throw new Exception("فشل إنشاء توكن محفظة الراكب");
|
||||
|
||||
$walletResult = addToPassengerWallet($userId, $finalAmount, $token);
|
||||
if (!$walletResult || ($walletResult['status'] ?? 'fail') != "success") {
|
||||
throw new Exception("فشل إضافة الرصيد لمحفظة الراكب");
|
||||
}
|
||||
|
||||
$seferToken = generatePaymentToken($userId, $amount);
|
||||
if (!$seferToken) throw new Exception("فشل إنشاء توكن محفظة سفر");
|
||||
|
||||
$seferWalletResult = addToSeferWallet($userId, $amount, $paymentMethod, $seferToken);
|
||||
if (!$seferWalletResult || ($seferWalletResult['status'] ?? 'fail') != "success") {
|
||||
throw new Exception("فشل إضافة الرصيد لمحفظة سفر");
|
||||
}
|
||||
|
||||
logError("VERIFY", "اكتملت العملية بنجاح", ["orderRef" => $orderRef, "userId" => $userId]);
|
||||
showHTMLPage("success", "تم الدفع بنجاح", "تمت إضافة الرصيد إلى محفظتك. شكرًا لاستخدامك Intaleq.");
|
||||
} catch (Exception $e) {
|
||||
logError("VERIFY_ERROR", $e->getMessage(), ["orderRef" => $orderRef]);
|
||||
showHTMLPage("error", "حدث خطأ", "لقد تم استلام دفعتك بنجاح، ولكن حدث خطأ أثناء تحديث رصيدك. يرجى التواصل مع الدعم الفني وتزويدهم بالرقم المرجعي: " . htmlspecialchars($orderRef));
|
||||
}
|
||||
|
||||
// --- دوال مساعدة ---
|
||||
|
||||
function calculateBonus($amount) {
|
||||
if ($amount == 200000) return 205000;
|
||||
if ($amount == 400000) return 425000;
|
||||
if ($amount == 1000000) return 1040000;
|
||||
return $amount;
|
||||
}
|
||||
|
||||
function generatePaymentToken($passengerId, $amount) {
|
||||
$url = BASE_URL . "/passengerWallet/addPaymentTokenPassenger.php";
|
||||
$postData = ['passengerId' => $passengerId, 'amount' => $amount];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200) return null;
|
||||
$data = json_decode($response, true);
|
||||
return $data['message'] ?? null;
|
||||
}
|
||||
|
||||
function addToPassengerWallet($passengerId, $amount, $token) {
|
||||
$url = BASE_URL . "/passengerWallet/add.php";
|
||||
$postData = ['passenger_id' => $passengerId, 'balance' => $amount, 'token' => $token];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200) return null;
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
function addToSeferWallet($passengerId, $amount, $paymentMethod, $token) {
|
||||
$url = BASE_URL . "/seferWallet/add.php";
|
||||
$postData = [
|
||||
'amount' => $amount,
|
||||
'paymentMethod' => $paymentMethod,
|
||||
'passengerId' => $passengerId,
|
||||
'token' => $token,
|
||||
'driverId' => 'passenger'
|
||||
];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200) return null;
|
||||
return json_decode($response, true);
|
||||
}
|
||||
?>
|
||||
91
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/ecash_webhook.php
Executable file
91
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/ecash_webhook.php
Executable file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
// استخدام ملف اتصال خاص بالـ Webhook لا يحتوي على أي تحقق من الهوية
|
||||
include "../../../jwtconnect.php";
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ملف Webhook النهائي الخاص بـ eCash (مع تسجيل إضافي للتصحيح)
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// --- الإعدادات ---
|
||||
$ecash_merchant_id = getenv('ECASH_MERCHANT_ID');
|
||||
$ecash_merchant_secret = getenv('ECASH_MERCHANT_SECRET');
|
||||
|
||||
// --- إعداد ملف اللوج (Log File) ---
|
||||
$log_dir = __DIR__ . '/../logs';
|
||||
$log_file = $log_dir . '/ecash_production.log';
|
||||
|
||||
if (!is_dir($log_dir)) {
|
||||
mkdir($log_dir, 0755, true);
|
||||
}
|
||||
|
||||
// --- قراءة البيانات القادمة من eCash ---
|
||||
$raw_body = file_get_contents("php://input");
|
||||
$data = json_decode($raw_body, true);
|
||||
|
||||
// --- تسجيل الـ Callback كاملاً لأغراض المراقبة ---
|
||||
file_put_contents($log_file, "--- NEW WEBHOOK ---\n" . date('Y-m-d H:i:s') . " - RAW BODY: " . $raw_body . PHP_EOL, FILE_APPEND);
|
||||
|
||||
if (!$data || !isset($data['Token'])) {
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- استخراج البيانات ---
|
||||
$isSuccess = $data['IsSuccess'] ?? false;
|
||||
$transactionNo = $data['TransactionNo'] ?? '';
|
||||
$amount = $data['Amount'] ?? '';
|
||||
$orderRef = $data['OrderRef'] ?? '';
|
||||
$receivedToken = $data['Token'];
|
||||
|
||||
// --- **تصحيح الأخطاء: بناء وتسجيل سلسلة التحقق** ---
|
||||
$verification_string = $ecash_merchant_id . $ecash_merchant_secret . $transactionNo . $amount . $orderRef;
|
||||
$expectedToken = strtoupper(md5($verification_string));
|
||||
|
||||
// تسجيل السلسلة المستخدمة في التوقيع والقيم الفردية
|
||||
$debug_log = "VERIFICATION STRING: " . $verification_string . PHP_EOL;
|
||||
$debug_log .= " - Merchant ID Used: " . $ecash_merchant_id . PHP_EOL;
|
||||
$debug_log .= " - TransactionNo Used: " . $transactionNo . PHP_EOL;
|
||||
$debug_log .= " - Amount Used: " . $amount . PHP_EOL;
|
||||
$debug_log .= " - OrderRef Used: " . $orderRef . PHP_EOL;
|
||||
$debug_log .= "CALCULATED TOKEN: " . $expectedToken . PHP_EOL;
|
||||
$debug_log .= "RECEIVED TOKEN: " . $receivedToken . PHP_EOL;
|
||||
|
||||
file_put_contents($log_file, $debug_log, FILE_APPEND);
|
||||
|
||||
|
||||
// --- التحقق من صحة الـ Token ---
|
||||
if (!hash_equals($expectedToken, $receivedToken)) {
|
||||
http_response_code(401);
|
||||
file_put_contents($log_file, "TOKEN MISMATCH! Process stopped." . PHP_EOL, FILE_APPEND);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- تحديث حالة الدفعة في قاعدة البيانات ---
|
||||
file_put_contents($log_file, "TOKEN MATCH! Proceeding to update database." . PHP_EOL, FILE_APPEND);
|
||||
$payment_status = $isSuccess ? 1 : 0;
|
||||
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `paymentsLogSyria` SET status = :status, updated_at = NOW() WHERE order_ref = :order_ref AND status = 2"
|
||||
);
|
||||
$stmt->execute([
|
||||
':status' => $payment_status,
|
||||
|
||||
':order_ref' => $orderRef
|
||||
]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
http_response_code(200);
|
||||
file_put_contents($log_file, "SUCCESS: Database updated." . PHP_EOL, FILE_APPEND);
|
||||
} else {
|
||||
http_response_code(200);
|
||||
file_put_contents($log_file, "INFO: Order not found or already processed." . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
http_response_code(500);
|
||||
file_put_contents($log_file, "FATAL: Database update failed: " . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
?>
|
||||
79
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/finalize_payment.php
Executable file
79
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/finalize_payment.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
// هذا الملف يجب أن يستخدم ملف الاتصال الذي يتحقق من الهوية
|
||||
include "../../../connect.php";
|
||||
// يجب استدعاء دالة التحقق هنا لضمان أن الطلب قادم من تطبيقك فقط
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ملف إتمام الدفع النهائي
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| هذا الملف مسؤول عن:
|
||||
| 1. استقبال طلب من تطبيق فلاتر بعد عودة المستخدم.
|
||||
| 2. التحقق من وجود دفعة ناجحة حديثة للمستخدم في قاعدة البيانات.
|
||||
| 3. حساب المكافآت.
|
||||
| 4. استدعاء واجهات API داخلية لإضافة الرصيد إلى المحافظ.
|
||||
|
|
||||
*/
|
||||
|
||||
// --- استقبال البيانات من تطبيق فلاتر ---
|
||||
$userId = filterRequest("userId"); // أو driverId
|
||||
$paymentMethod = filterRequest("paymentMethod") ?? 'ecash';
|
||||
|
||||
if (empty($userId)) {
|
||||
printFailure("معرّف المستخدم غير صالح.");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// خطوة 1: البحث عن آخر دفعة ناجحة للمستخدم (تم تحديثها بواسطة الـ Webhook)
|
||||
$stmt = $con->prepare(
|
||||
"SELECT * FROM `paymentsLogSyria`
|
||||
WHERE user_id = :user_id
|
||||
AND status = 1
|
||||
AND updated_at >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
|
||||
ORDER BY updated_at DESC
|
||||
LIMIT 1"
|
||||
);
|
||||
$stmt->bindParam(':user_id', $userId, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$payment) {
|
||||
printFailure("لم يتم العثور على دفعة ناجحة حديثة.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// خطوة 2: الحصول على المبلغ (لا يحتاج للقسمة على 100)
|
||||
$amount = $payment['amount'];
|
||||
|
||||
// خطوة 3: حساب المكافأة
|
||||
$finalAmount = calculateBonus($amount); // استخدم دالة حساب المكافآت الخاصة بك
|
||||
|
||||
$passengerId = $userId; // نفترض أن معرّف المستخدم هو نفسه معرّف الراكب
|
||||
|
||||
// --- هنا تضع نفس منطق إضافة الرصيد الذي كان في ملف payment_verify.php القديم ---
|
||||
// (مثال)
|
||||
// $token = generatePaymentToken($passengerId, $finalAmount);
|
||||
// addToPassengerWallet($passengerId, $finalAmount, $token);
|
||||
// ... إلخ
|
||||
|
||||
// --- النجاح النهائي ---
|
||||
printSuccess("تمت معالجة الدفع وتحديث الرصيد بنجاح.");
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log("Finalize Payment Error: " . $e->getMessage());
|
||||
printFailure("حدث خطأ في قاعدة البيانات أثناء إتمام العملية.");
|
||||
}
|
||||
|
||||
// --- يمكنك وضع دوال المساعدة هنا (calculateBonus, etc.) ---
|
||||
function calculateBonus($amount) {
|
||||
$result = $amount;
|
||||
if ($amount == 500) return 530;
|
||||
if ($amount == 1000) return 1070;
|
||||
if ($amount == 2000) return 2180;
|
||||
if ($amount == 5000) return 5700;
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
88
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/payWithEcash.php
Executable file
88
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/payWithEcash.php
Executable file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
include "../../../connect.php"; // تأكد من أن هذا الملف يحتوي على الاتصال بقاعدة البيانات ودوال المساعدة
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ملف بدء الدفع مع eCash
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| هذا الملف مسؤول عن:
|
||||
| 1. استقبال طلب الدفع من تطبيق فلاتر (المبلغ ومعرّف المستخدم/السائق).
|
||||
| 2. إنشاء رابط دفع فريد وخاص ببوابة eCash.
|
||||
| 3. حساب رمز التحقق (Verification Code) المطلوب من eCash.
|
||||
| 4. تسجيل محاولة الدفع في قاعدة البيانات بحالة "قيد الانتظار".
|
||||
| 5. إعادة رابط الدفع إلى التطبيق ليتم عرضه في WebView.
|
||||
|
|
||||
*/
|
||||
|
||||
// --- الإعدادات الرئيسية - يجب تخزينها كمتغيرات بيئة (Environment Variables) ---
|
||||
$ecash_merchant_id = getenv('ECASH_MERCHANT_ID'); // معرّف التاجر الخاص بك من eCash
|
||||
$ecash_merchant_secret = getenv('ECASH_MERCHANT_SECRET'); // المفتاح السري الخاص بك من eCash
|
||||
$ecash_terminal_key = getenv('ECASH_TERMINAL_KEY'); // مفتاح المحطة الطرفية (Terminal Key) من eCash
|
||||
$ecash_checkout_url = 'https://checkout.ecash-pay.com/'; //
|
||||
$ecash_checkout_url_stage = 'https://checkout.ecash-pay.co/';//رابط بوابة الدفع
|
||||
$base_app_url = getenv('APP_BASE_URL'); // الرابط الأساسي لواجهة API الخاصة بك
|
||||
|
||||
// --- استقبال البيانات من تطبيق فلاتر ---
|
||||
$amount = filterRequest("amount");
|
||||
$passengerId = filterRequest("passengerId"); // معرّف السائق أو المستخدم
|
||||
|
||||
// --- التحقق من صحة البيانات المدخلة ---
|
||||
if (empty($amount) || empty($passengerId) || !is_numeric($amount) || $amount <= 0) {
|
||||
printFailure("المبلغ أو معرّف المستخدم غير صالح.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- إعداد متغيرات الدفع ---
|
||||
$currency = "SYP"; // العملة حسب متطلبات eCash
|
||||
$lang = "AR"; // لغة واجهة الدفع (AR أو EN)
|
||||
//$orderRef = uniqid($passengerId . "_"); // إنشاء رقم مرجعي فريد للطلب لربطه بالمستخدم
|
||||
$orderRef = "tripz_" . $passengerId . "_" . time();
|
||||
// --- إنشاء رمز التحقق (Verification Code) ---
|
||||
// هو عبارة عن MD5 لمجموعة من الحقول ويجب أن يكون بأحرف كبيرة
|
||||
$verification_string = $ecash_merchant_id . $ecash_merchant_secret . $amount . $orderRef;
|
||||
$verificationCode = strtoupper(md5($verification_string));
|
||||
|
||||
// --- تحديد روابط إعادة التوجيه والاستدعاء (Redirect & Callback) ---
|
||||
// الرابط الذي يتم توجيه المستخدم إليه بعد إتمام الدفع
|
||||
$redirectUrl = urlencode($base_app_url . "/passenger/ecash_verify.php?orderRef=" . $orderRef);
|
||||
// الرابط الذي تستدعيه eCash لإبلاغ سيرفرك بنتيجة العملية (Webhook)
|
||||
$callbackUrl = urlencode($base_app_url . "/passenger/ecash_webhook.php");
|
||||
|
||||
// --- بناء رابط الدفع النهائي الخاص بـ eCash ---
|
||||
$paymentUrl = "{$ecash_checkout_url}Checkout/CardCheckout" .
|
||||
"?tk=" . urlencode($ecash_terminal_key) .
|
||||
"&mid=" . urlencode($ecash_merchant_id) .
|
||||
"&vc=" . urlencode($verificationCode) .
|
||||
"&c=" . urlencode($currency) .
|
||||
"&a=" . urlencode($amount) .
|
||||
"&lang=" . urlencode($lang) .
|
||||
"&or=" . urlencode($orderRef) .
|
||||
"&ru=" . $redirectUrl .
|
||||
"&cu=" . $callbackUrl;
|
||||
//error_log("eCash - فشل تسجيل الدفعة المبدئية: " . $paymentUrl);
|
||||
// --- تسجيل العملية المبدئية في قاعدة البيانات ---
|
||||
// هذا يساعد على تتبع الطلب وربطه بالـ callback القادم من eCash
|
||||
// نفترض أن حقل status يقبل القيم: 0=فشل، 1=نجاح، 2=قيد الانتظار
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"INSERT INTO `paymentsLogSyria`( `user_id`, `amount`, `status`, `order_ref`, `payment_method`, `created_at`)
|
||||
VALUES (:user_id, :amount, 2, :order_ref,'ecash-passenger', NOW())"
|
||||
);
|
||||
$stmt->execute([
|
||||
':user_id' => $passengerId,
|
||||
':amount' => $amount,
|
||||
':order_ref' => $orderRef
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
error_log("eCash - فشل تسجيل الدفعة المبدئية: " . $e->getMessage());
|
||||
printFailure("حدث خطأ أثناء بدء عملية الدفع. يرجى المحاولة مرة أخرى.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- إعادة رابط الدفع إلى تطبيق فلاتر ---
|
||||
// التطبيق سيستقبل هذا الرابط ويفتحه في WebView
|
||||
// نرسل الرابط داخل حقل 'message' كما يتوقع كود فلاتر
|
||||
printSuccess($paymentUrl);
|
||||
|
||||
?>
|
||||
42
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/webhook_connect.php
Executable file
42
walletintaleq.intaleq.xyz/v2/main/ride/ecash/passenger/webhook_connect.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// Load environment variables from .env file
|
||||
// **FIX:** Corrected the path to go up three levels to find the 'vendor' directory
|
||||
require_once realpath(__DIR__ . '/../../../vendor/autoload.php');
|
||||
// **FIX:** Corrected the path to go up two levels to find 'load_env.php'
|
||||
require_once realpath(__DIR__ . '/../../load_env.php');
|
||||
|
||||
$env_file = '/home/tripz-egypt-wl/env/.env';
|
||||
loadEnvironment($env_file);
|
||||
|
||||
// --- CORS Headers ---
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: POST, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type");
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
|
||||
$dbname = getenv('dbname');
|
||||
// --- Database Connection ONLY ---
|
||||
try {
|
||||
$dsn = "mysql:host=localhost;dbname=$dbname;charset=utf8mb4";
|
||||
$options = [
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8"
|
||||
];
|
||||
$user = getenv('USER');
|
||||
$pass = getenv('PASS');
|
||||
$con = new PDO($dsn, $user, $pass, $options);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log("Webhook DB Connection Error: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Internal Server Error']);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
73
walletintaleq.intaleq.xyz/v2/main/ride/ecash/payWithEcash.php
Executable file
73
walletintaleq.intaleq.xyz/v2/main/ride/ecash/payWithEcash.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
// --- payWithEcash.php (Updated) ---
|
||||
// This script now saves transaction details before generating the payment link.
|
||||
|
||||
require "../../connect.php"; // Your existing connection/auth script
|
||||
require_once "ecash_config.php"; // The ecash config file
|
||||
|
||||
// --- Get Input Data ---
|
||||
$amount = filterRequest("amount", "numeric");
|
||||
$passengerId = filterRequest("passengerId"); // Get passengerId from the request
|
||||
|
||||
if (!$amount || $amount <= 0) {
|
||||
printFailure("Invalid or missing amount.");
|
||||
exit;
|
||||
}
|
||||
if (!$passengerId) {
|
||||
printFailure("Passenger ID is required.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// The user ID from your JWT authentication in connect.php
|
||||
$userId = $decodedToken->user_id ?? null;
|
||||
if (!$userId) {
|
||||
printFailure("Authentication failed.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// 1. --- Create a unique order reference ---
|
||||
$orderRef = 'INTALEQ_' . $userId . '_' . time();
|
||||
|
||||
// 2. --- Save the initial transaction to your database ---
|
||||
// This step is CRITICAL for the webhook to work correctly.
|
||||
// Create a table named 'ecash_transactions' with columns like:
|
||||
// id, order_ref, user_id, passenger_id, amount, status, created_at, updated_at
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"INSERT INTO ecash_transactions (order_ref, user_id, passenger_id, amount, status) VALUES (?, ?, ?, ?, 'pending')"
|
||||
);
|
||||
$stmt->execute([$orderRef, $userId, $passengerId, $amount]);
|
||||
} catch (PDOException $e) {
|
||||
// Log the database error
|
||||
error_log("ecash_initiate DB Error: " . $e->getMessage());
|
||||
printFailure("Failed to initiate payment transaction.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// 3. --- Generate the Verification Code (VC) ---
|
||||
$stringToHash = ECASH_MERCHANT_ID . ECASH_MERCHANT_SECRET . $amount . $orderRef;
|
||||
$verificationCode = strtoupper(md5($stringToHash));
|
||||
|
||||
// 4. --- Construct URLs ---
|
||||
$redirectUrl = urlencode(APP_REDIRECT_URL_SUCCESS);
|
||||
$callbackUrl = urlencode(APP_CALLBACK_URL);
|
||||
|
||||
// 5. --- Build the Final Checkout URL ---
|
||||
$checkoutUrl = sprintf(
|
||||
"%s/Checkout/CardCheckout?tk=%s&mid=%s&vc=%s&c=%s&a=%s&lang=%s&or=%s&ru=%s&cu=%s",
|
||||
ECASH_CHECKOUT_URL,
|
||||
ECASH_TERMINAL_KEY,
|
||||
ECASH_MERCHANT_ID,
|
||||
$verificationCode,
|
||||
ECASH_CURRENCY,
|
||||
$amount,
|
||||
ECASH_LANG,
|
||||
$orderRef,
|
||||
$redirectUrl,
|
||||
$callbackUrl
|
||||
);
|
||||
|
||||
// 6. --- Return the URL to Flutter ---
|
||||
printSuccess($checkoutUrl);
|
||||
|
||||
?>
|
||||
310
walletintaleq.intaleq.xyz/v2/main/ride/ecash/webhook_ecash.php
Executable file
310
walletintaleq.intaleq.xyz/v2/main/ride/ecash/webhook_ecash.php
Executable file
@@ -0,0 +1,310 @@
|
||||
|
||||
<?php
|
||||
// --- webhook_ecash.php ---
|
||||
// This script securely handles the callback from ecash and updates user wallets.
|
||||
|
||||
// Include necessary files
|
||||
require_once "../../connect.php"; // Adjust path as needed
|
||||
require_once "ecash_config.php"; // Adjust path as needed
|
||||
|
||||
define("BASE_URL", "https://wl.tripz-egypt.com/v1/main/ride");
|
||||
define("LOG_FILE", "../logs/ecash_webhook.log");
|
||||
|
||||
// --- Start Webhook Processing ---
|
||||
|
||||
// 1. Log the raw incoming data from ecash
|
||||
$raw_post_data = file_get_contents('php://input');
|
||||
logError("0", "Webhook received", ["payload" => $raw_post_data]);
|
||||
|
||||
$data = json_decode($raw_post_data, true);
|
||||
if (!$data) {
|
||||
logError("0.1", "Invalid JSON payload.");
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 2. Extract data and verify the token from ecash
|
||||
$isSuccess = $data['isSuccess'] ?? null;
|
||||
$orderRef = $data['orderRef'] ?? null;
|
||||
$transactionNo = $data['transactionNo'] ?? null;
|
||||
$amount = $data['amount'] ?? null;
|
||||
$receivedToken = $data['token'] ?? '';
|
||||
|
||||
$string_to_hash = ECASH_MERCHANT_ID . ECASH_MERCHANT_SECRET . $transactionNo . $amount . $orderRef;
|
||||
$expected_token = md5($string_to_hash);
|
||||
|
||||
if (strcasecmp($expected_token, $receivedToken) !== 0) {
|
||||
logError("1", "Token Mismatch", [
|
||||
"expected" => $expected_token,
|
||||
"received" => $receivedToken,
|
||||
"string" => $string_to_hash
|
||||
]);
|
||||
http_response_code(401); // Unauthorized
|
||||
exit;
|
||||
}
|
||||
logError("1", "Token Verified Successfully.");
|
||||
|
||||
// 3. Check if payment was successful
|
||||
if ($isSuccess !== true) {
|
||||
logError("2", "Payment was not successful according to ecash.", $data);
|
||||
// Optionally, update your database to mark the order as 'failed'
|
||||
updateTransactionStatus($orderRef, 'failed', $transactionNo);
|
||||
http_response_code(200); // Respond OK to ecash, but do nothing else
|
||||
exit;
|
||||
}
|
||||
logError("2", "Payment reported as SUCCESS by ecash.");
|
||||
|
||||
// 4. Find the original transaction in your database using the Order Reference
|
||||
try {
|
||||
$stmt = $con->prepare("SELECT * FROM ecash_transactions WHERE order_ref = ? LIMIT 1");
|
||||
$stmt->execute([$orderRef]);
|
||||
$transaction = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$transaction) {
|
||||
logError("3", "OrderRef not found in our database.", ["orderRef" => $orderRef]);
|
||||
http_response_code(404); // Not Found
|
||||
exit;
|
||||
}
|
||||
|
||||
// Security Check: Ensure this transaction hasn't already been processed
|
||||
if ($transaction['status'] !== 'pending') {
|
||||
logError("3.1", "Transaction already processed.", ["orderRef" => $orderRef, "status" => $transaction['status']]);
|
||||
http_response_code(200); // Acknowledge receipt, but prevent double-spending
|
||||
exit;
|
||||
}
|
||||
|
||||
$passengerId = $transaction['passenger_id'];
|
||||
$paidAmount = $transaction['amount']; // Use the amount from your DB as the source of truth
|
||||
logError("3", "Transaction found in DB.", ["passengerId" => $passengerId, "amount" => $paidAmount]);
|
||||
|
||||
// 5. --- Start Wallet Update Logic (from your paymet_verfy.php) ---
|
||||
|
||||
// Calculate bonus
|
||||
$finalAmount = calculateBonus($paidAmount);
|
||||
logError("4", "Bonus calculated.", ["original" => $paidAmount, "final" => $finalAmount]);
|
||||
|
||||
// Add to Passenger Wallet
|
||||
$passengerToken = generatePaymentToken($passengerId, $finalAmount);
|
||||
if ($passengerToken) {
|
||||
addToPassengerWallet($passengerId, $finalAmount, $passengerToken);
|
||||
}
|
||||
|
||||
// Add to Sefer Wallet
|
||||
$paymentMethod = 'ecash'; // Or another identifier
|
||||
addToSeferWallet($passengerId, $paidAmount, $paymentMethod);
|
||||
|
||||
// 6. Mark the transaction as 'success' in your database to prevent reprocessing
|
||||
updateTransactionStatus($orderRef, 'success', $transactionNo);
|
||||
logError("7", "Process completed successfully.");
|
||||
|
||||
} catch (PDOException $e) {
|
||||
logError("DB_ERROR", "Database error: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
exit;
|
||||
} catch (Exception $e) {
|
||||
logError("GENERAL_ERROR", "General error: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 7. Respond to ecash server
|
||||
http_response_code(200);
|
||||
echo "Webhook processed.";
|
||||
|
||||
|
||||
// --- ALL HELPER FUNCTIONS FROM paymet_verfy.php ---
|
||||
|
||||
function updateTransactionStatus($orderRef, $status, $transactionNo) {
|
||||
global $con;
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE ecash_transactions SET status = ?, ecash_transaction_no = ?, updated_at = NOW() WHERE order_ref = ?"
|
||||
);
|
||||
$stmt->execute([$status, $transactionNo, $orderRef]);
|
||||
} catch (PDOException $e) {
|
||||
logError("DB_UPDATE_ERROR", "Failed to update transaction status", ["error" => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function generatePaymentToken($passengerId, $amount) {
|
||||
$url = BASE_URL . "/passengerWallet/addPaymentTokenPassenger.php";
|
||||
|
||||
$postData = [
|
||||
'passengerId' => $passengerId,
|
||||
'amount' => $amount
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($curlError) {
|
||||
logError("4.1", "cURL error in token generation", [
|
||||
"error" => $curlError,
|
||||
"url" => $url
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($httpCode != 200) {
|
||||
logError("4.2", "HTTP error in token generation", [
|
||||
"http_code" => $httpCode,
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (!$data || !isset($data['message'])) {
|
||||
logError("4.3", "Invalid response format in token generation", [
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data['message']; // ✅ Return token
|
||||
}
|
||||
|
||||
// 🎯 Function to add balance to passenger's wallet with error logging
|
||||
function addToPassengerWallet($passengerId, $amount, $token) {
|
||||
$url = BASE_URL . "/passengerWallet/add.php";
|
||||
|
||||
$postData = [
|
||||
'passenger_id' => $passengerId,
|
||||
'balance' => $amount,
|
||||
'token' => $token
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($curlError) {
|
||||
logError("5.1", "cURL error in passenger wallet update", [
|
||||
"error" => $curlError,
|
||||
"url" => $url
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($httpCode != 200) {
|
||||
logError("5.2", "HTTP error in passenger wallet update", [
|
||||
"http_code" => $httpCode,
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (!$data) {
|
||||
logError("5.3", "Invalid response format in passenger wallet update", [
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data; // ✅ Return result
|
||||
}
|
||||
|
||||
// 🎯 Function to add balance to Sefer wallet with error logging
|
||||
|
||||
|
||||
function addToSeferWallet($passengerId, $amount, $paymentMethod) {
|
||||
|
||||
|
||||
// Generate a new token specifically for the Sefer wallet
|
||||
$seferToken = generatePaymentToken($passengerId, $amount);
|
||||
|
||||
if (!$seferToken) {
|
||||
logError("6.0.1", "Failed to generate Sefer token");
|
||||
return null;
|
||||
}
|
||||
|
||||
logError("6.0.2", "Generated new Sefer token", [
|
||||
"token_length" => ($seferToken)
|
||||
]);
|
||||
|
||||
$url = BASE_URL . "/seferWallet/add.php";
|
||||
|
||||
$postData = [
|
||||
'amount' => $amount,
|
||||
'paymentMethod' => $paymentMethod,
|
||||
'passengerId' => $passengerId,
|
||||
'token' => $seferToken, // Use the new Sefer-specific token
|
||||
'driverId' => 'passenger'
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($curlError) {
|
||||
logError("6.1", "cURL error in Sefer wallet update", [
|
||||
"error" => $curlError,
|
||||
"url" => $url
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($httpCode != 200) {
|
||||
logError("6.2", "HTTP error in Sefer wallet update", [
|
||||
"http_code" => $httpCode,
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (!$data) {
|
||||
logError("6.3", "Invalid response format in Sefer wallet update", [
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data; // ✅ Return result
|
||||
}
|
||||
|
||||
|
||||
// 🎯 Function to calculate bonus
|
||||
function calculateBonus($amount) {
|
||||
logError("3.1", "Bonus calculation input", ["amount" => $amount]);
|
||||
|
||||
$result = 0;
|
||||
if ($amount == 100) $result = 100;
|
||||
else if ($amount == 200) $result = 215;
|
||||
else if ($amount == 400) $result = 450;
|
||||
else if ($amount == 1000) $result = 1140;
|
||||
|
||||
logError("3.2", "Bonus calculation result", [
|
||||
"input" => $amount,
|
||||
"output" => $result
|
||||
]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
45
walletintaleq.intaleq.xyz/v2/main/ride/kazan/add.php
Executable file
45
walletintaleq.intaleq.xyz/v2/main/ride/kazan/add.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
$kazan = filterRequest("kazan");
|
||||
$adminId = filterRequest("adminId");
|
||||
$latePrice = filterRequest("latePrice");
|
||||
$heavyPrice = filterRequest("heavyPrice");
|
||||
$naturePrice = filterRequest("naturePrice");
|
||||
$comfortPrice = filterRequest("comfortPrice");
|
||||
$speedPrice = filterRequest("speedPrice");
|
||||
$deliveryPrice = filterRequest("deliveryPrice");
|
||||
$freePrice = filterRequest("freePrice");
|
||||
$country = filterRequest("country");
|
||||
$fuelPrice = filterRequest("fuelPrice");
|
||||
|
||||
// Prepare an SQL statement with placeholders for the values
|
||||
$sql = "INSERT INTO `kazan`( `country`,`kazan`, `comfortPrice`, `speedPrice`, `deliveryPrice`, `freePrice`, `latePrice`, `heavyPrice`, `adminId`, `naturePrice`, `fuelPrice`) VALUES (:country,:kazan, :comfortPrice, :speedPrice, :deliveryPrice, :freePrice, :latePrice, :heavyPrice, :adminId, :naturePrice,:fuelPrice)";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
|
||||
// Bind the parameters to the SQL query
|
||||
$stmt->bindParam(':kazan', $kazan);
|
||||
$stmt->bindParam(':comfortPrice', $comfortPrice);
|
||||
$stmt->bindParam(':speedPrice', $speedPrice);
|
||||
$stmt->bindParam(':deliveryPrice', $deliveryPrice);
|
||||
$stmt->bindParam(':freePrice', $freePrice);
|
||||
$stmt->bindParam(':latePrice', $latePrice);
|
||||
$stmt->bindParam(':heavyPrice', $heavyPrice);
|
||||
$stmt->bindParam(':adminId', $adminId);
|
||||
$stmt->bindParam(':naturePrice', $naturePrice);
|
||||
$stmt->bindParam(':country', $country);
|
||||
$stmt->bindParam(':fuelPrice', $fuelPrice);
|
||||
|
||||
// Execute the statement
|
||||
if ($stmt->execute()) {
|
||||
// Print a success message
|
||||
printSuccess("Kazan saved successfully");
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure("Failed to save Kazan");
|
||||
}
|
||||
|
||||
// Close the statement
|
||||
$stmt->close();
|
||||
?>
|
||||
27
walletintaleq.intaleq.xyz/v2/main/ride/kazan/get.php
Normal file
27
walletintaleq.intaleq.xyz/v2/main/ride/kazan/get.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$country = filterRequest("country");
|
||||
|
||||
$sql = " SELECT *
|
||||
FROM
|
||||
`kazan`
|
||||
WHERE `country`='$country'";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row){
|
||||
// Fetch the record
|
||||
// $row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
|
||||
printFailure($message = "No Kazan record found");
|
||||
}
|
||||
?>
|
||||
72
walletintaleq.intaleq.xyz/v2/main/ride/kazan/update.php
Normal file
72
walletintaleq.intaleq.xyz/v2/main/ride/kazan/update.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
// Create an empty array to store the column-value pairs
|
||||
$columnValues = array();
|
||||
|
||||
// Check if each column is set in the request and add it to the array
|
||||
if (isset($_POST["kazan"])) {
|
||||
$kazan = filterRequest("kazan");
|
||||
$columnValues[] = "`kazan` = '$kazan'";
|
||||
}
|
||||
|
||||
if (isset($_POST["comfortPrice"])) {
|
||||
$comfortPrice = filterRequest("comfortPrice");
|
||||
$columnValues[] = "`comfortPrice` = '$comfortPrice'";
|
||||
}
|
||||
|
||||
if (isset($_POST["speedPrice"])) {
|
||||
$speedPrice = filterRequest("speedPrice");
|
||||
$columnValues[] = "`speedPrice` = '$speedPrice'";
|
||||
}
|
||||
|
||||
if (isset($_POST["deliveryPrice"])) {
|
||||
$deliveryPrice = filterRequest("deliveryPrice");
|
||||
$columnValues[] = "`deliveryPrice` = '$deliveryPrice'";
|
||||
}
|
||||
if (isset($_POST["freePrice"])) {
|
||||
$freePrice = filterRequest("freePrice");
|
||||
$columnValues[] = "`freePrice` = '$freePrice'";
|
||||
}
|
||||
if (isset($_POST["latePrice"])) {
|
||||
$latePrice = filterRequest("latePrice");
|
||||
$columnValues[] = "`latePrice` = '$latePrice'";
|
||||
}
|
||||
|
||||
if (isset($_POST["heavyPrice"])) {
|
||||
$heavyPrice = filterRequest("heavyPrice");
|
||||
$columnValues[] = "`heavyPrice` = '$heavyPrice'";
|
||||
}
|
||||
|
||||
if (isset($_POST["adminId"])) {
|
||||
$adminId = filterRequest("adminId");
|
||||
$columnValues[] = "`adminId` = '$adminId'";
|
||||
}
|
||||
|
||||
if (isset($_POST["createdAt"])) {
|
||||
$createdAt = filterRequest("createdAt");
|
||||
$columnValues[] = "`createdAt` = '$createdAt'";
|
||||
}
|
||||
|
||||
if (isset($_POST["naturePrice"])) {
|
||||
$naturePrice = filterRequest("naturePrice");
|
||||
$columnValues[] = "`naturePrice` = '$naturePrice'";
|
||||
}
|
||||
|
||||
// Construct the SET clause of the update query using the column-value pairs
|
||||
$setClause = implode(", ", $columnValues);
|
||||
|
||||
$sql = "UPDATE `kazan` SET $setClause WHERE `id` = '$id'";
|
||||
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Print a success message
|
||||
printSuccess($message = "Kazan data updated successfully");
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure($message = "Failed to update kazan data");
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
[2025-03-20 21:01:11] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:01:11] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:01:11] STEP 1: Payment found | Data: {"payment_id":"13","status":"1","amount":"2800.00"}
|
||||
[2025-03-20 21:01:11] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:01:11] STEP 3: Calculating bonus | Data: {"amount":"2800.00"}
|
||||
[2025-03-20 21:01:11] STEP 3.1: Bonus calculation input | Data: {"amount":"2800.00"}
|
||||
[2025-03-20 21:01:11] STEP 3.2: Bonus calculation result | Data: {"input":"2800.00","output":0}
|
||||
[2025-03-20 21:01:11] STEP 3: Bonus calculation failed | Data: {"original_amount":"2800.00","calculated_amount":0}
|
||||
[2025-03-20 21:07:36] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:07:36] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:07:36] STEP 1: Payment found | Data: {"payment_id":"14","status":"1","amount":28}
|
||||
[2025-03-20 21:07:36] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:07:36] STEP 3: Calculating bonus | Data: {"amount":"2800.00"}
|
||||
[2025-03-20 21:07:36] STEP 3.1: Bonus calculation input | Data: {"amount":"2800.00"}
|
||||
[2025-03-20 21:07:36] STEP 3.2: Bonus calculation result | Data: {"input":"2800.00","output":0}
|
||||
[2025-03-20 21:07:36] STEP 3: Bonus calculation failed | Data: {"original_amount":"2800.00","calculated_amount":0}
|
||||
[2025-03-20 21:10:41] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:10:41] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:10:41] STEP 1: Payment found | Data: {"payment_id":"15","status":"1","amount":80}
|
||||
[2025-03-20 21:10:41] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:10:41] STEP 3: Calculating bonus | Data: {"amount":80}
|
||||
[2025-03-20 21:10:41] STEP 3.1: Bonus calculation input | Data: {"amount":80}
|
||||
[2025-03-20 21:10:41] STEP 3.2: Bonus calculation result | Data: {"input":80,"output":0}
|
||||
[2025-03-20 21:10:41] STEP 3: Bonus calculation failed | Data: {"original_amount":80,"calculated_amount":0}
|
||||
[2025-03-20 21:11:51] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:11:51] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:11:51] STEP 1: Payment found | Data: {"payment_id":"16","status":"1","amount":100}
|
||||
[2025-03-20 21:11:51] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:11:51] STEP 3: Calculating bonus | Data: {"amount":100}
|
||||
[2025-03-20 21:11:51] STEP 3.1: Bonus calculation input | Data: {"amount":100}
|
||||
[2025-03-20 21:11:51] STEP 3.2: Bonus calculation result | Data: {"input":100,"output":100}
|
||||
[2025-03-20 21:11:51] STEP 3: Bonus calculated | Data: {"original_amount":100,"final_amount":100}
|
||||
[2025-03-20 21:11:51] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:11:51] STEP 4.2: HTTP error in token generation | Data: {"http_code":404,"response":"<!DOCTYPE HTML PUBLIC \"-\/\/IETF\/\/DTD HTML 2.0\/\/EN\">\n<html><head>\n<title>404 Not Found<\/title>\n<\/head><body>\n<h1>Not Found<\/h1>\n<p>The requested URL was not found on this server.<\/p>\n<p>Additionally, a 404 Not Found\nerror was encountered while trying to use an ErrorDocument to handle the request.<\/p>\n<\/body><\/html>\n"}
|
||||
[2025-03-20 21:11:51] STEP 4: Token generation failed
|
||||
[2025-03-20 21:15:42] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:15:42] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:15:42] STEP 1: Payment found | Data: {"payment_id":"17","status":"1","amount":100}
|
||||
[2025-03-20 21:15:42] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:15:42] STEP 3: Calculating bonus | Data: {"amount":100}
|
||||
[2025-03-20 21:15:42] STEP 3.1: Bonus calculation input | Data: {"amount":100}
|
||||
[2025-03-20 21:15:42] STEP 3.2: Bonus calculation result | Data: {"input":100,"output":100}
|
||||
[2025-03-20 21:15:42] STEP 3: Bonus calculated | Data: {"original_amount":100,"final_amount":100}
|
||||
[2025-03-20 21:15:42] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:15:42] STEP 4.2: HTTP error in token generation | Data: {"http_code":401,"response":"{\"error\":\"Authorization token required\"}"}
|
||||
[2025-03-20 21:15:42] STEP 4: Token generation failed
|
||||
[2025-03-20 21:27:10] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:27:10] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:27:10] STEP 1: Payment found | Data: {"payment_id":"18","status":"1","amount":100}
|
||||
[2025-03-20 21:27:10] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:27:10] STEP 3: Calculating bonus | Data: {"amount":100}
|
||||
[2025-03-20 21:27:10] STEP 3.1: Bonus calculation input | Data: {"amount":100}
|
||||
[2025-03-20 21:27:10] STEP 3.2: Bonus calculation result | Data: {"input":100,"output":100}
|
||||
[2025-03-20 21:27:10] STEP 3: Bonus calculated | Data: {"original_amount":100,"final_amount":100}
|
||||
[2025-03-20 21:27:10] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:27:10] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 21:27:10] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:27:10] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 21:27:10] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":100,"paymentMethod":"unknown"}
|
||||
[2025-03-20 21:27:10] STEP 6.1: cURL error in Sefer wallet update | Data: {"error":"Could not resolve host: wallet.sefer.live","url":"https:\/\/wallet.sefer.live\/seferpw.shop\/sefer\/ride\/seferWallet\/add.php"}
|
||||
[2025-03-20 21:27:10] STEP 6: Failed to add balance to Sefer wallet
|
||||
[2025-03-20 21:31:51] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:31:51] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:31:51] STEP 1: Payment found | Data: {"payment_id":"19","status":"1","amount":100}
|
||||
[2025-03-20 21:31:51] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:31:51] STEP 3: Calculating bonus | Data: {"amount":100}
|
||||
[2025-03-20 21:31:51] STEP 3.1: Bonus calculation input | Data: {"amount":100}
|
||||
[2025-03-20 21:31:51] STEP 3.2: Bonus calculation result | Data: {"input":100,"output":100}
|
||||
[2025-03-20 21:31:51] STEP 3: Bonus calculated | Data: {"original_amount":100,"final_amount":100}
|
||||
[2025-03-20 21:31:51] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:31:51] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 21:31:51] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:31:51] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 21:31:51] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":100,"paymentMethod":"unknown"}
|
||||
[2025-03-20 21:31:51] STEP 6: Failed to add balance to Sefer wallet | Data: {"status":"failure","message":"Invalid or already used token"}
|
||||
[2025-03-20 21:35:58] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:35:58] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:35:58] STEP 1: Payment found | Data: {"payment_id":"20","status":"1","amount":100}
|
||||
[2025-03-20 21:35:58] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:35:58] STEP 3: Calculating bonus | Data: {"amount":100}
|
||||
[2025-03-20 21:35:58] STEP 3.1: Bonus calculation input | Data: {"amount":100}
|
||||
[2025-03-20 21:35:58] STEP 3.2: Bonus calculation result | Data: {"input":100,"output":100}
|
||||
[2025-03-20 21:35:58] STEP 3: Bonus calculated | Data: {"original_amount":100,"final_amount":100}
|
||||
[2025-03-20 21:35:58] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:35:58] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 21:35:58] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:35:58] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 21:35:58] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":100,"paymentMethod":"unknown"}
|
||||
[2025-03-20 21:35:58] STEP 4: tokenSefer generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 21:35:58] STEP 6: Failed to add balance to Sefer wallet | Data: {"status":"failure","message":"Invalid or already used token"}
|
||||
[2025-03-20 21:52:30] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 21:52:30] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 21:52:30] STEP 1: Payment found | Data: {"payment_id":"21","status":"1","amount":100}
|
||||
[2025-03-20 21:52:30] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 21:52:30] STEP 3: Calculating bonus | Data: {"amount":100}
|
||||
[2025-03-20 21:52:30] STEP 3.1: Bonus calculation input | Data: {"amount":100}
|
||||
[2025-03-20 21:52:30] STEP 3.2: Bonus calculation result | Data: {"input":100,"output":100}
|
||||
[2025-03-20 21:52:30] STEP 3: Bonus calculated | Data: {"original_amount":100,"final_amount":100}
|
||||
[2025-03-20 21:52:30] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:52:30] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 21:52:30] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":100}
|
||||
[2025-03-20 21:52:30] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 21:52:30] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":100,"paymentMethod":"unknown"}
|
||||
[2025-03-20 21:52:30] STEP 4: tokenSefer generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 21:52:30] STEP 6: Failed to add balance to Sefer wallet | Data: {"status":"failure","message":"Invalid or already used token"}
|
||||
[2025-03-20 22:09:36] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:09:36] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:09:36] STEP 1: Payment found | Data: {"payment_id":"22","status":"1","amount":200}
|
||||
[2025-03-20 22:09:36] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:09:36] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:09:36] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:09:36] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:09:36] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:09:36] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:09:36] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:09:36] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:09:36] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:09:36] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":null}
|
||||
[2025-03-20 22:09:36] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":64}
|
||||
[2025-03-20 22:09:36] STEP 6: Failed to add balance to Sefer wallet | Data: {"status":"failure","message":"Invalid or already used token"}
|
||||
[2025-03-20 22:19:03] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:19:03] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:19:03] STEP 1: Payment found | Data: {"payment_id":"23","status":"1","amount":200}
|
||||
[2025-03-20 22:19:03] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:19:03] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:19:03] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:19:03] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:19:03] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:19:03] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:19:03] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:19:03] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:19:03] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:19:03] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":null}
|
||||
[2025-03-20 22:19:03] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"e8131e30ba2ccef8c2f15cd03fa15d6151ca6e3fbc60778b9ad6fb5e105f383d"}
|
||||
[2025-03-20 22:19:03] STEP 6.2: HTTP error in Sefer wallet update | Data: {"http_code":401,"response":"{\"error\":\"Authorization token required\"}"}
|
||||
[2025-03-20 22:19:03] STEP 6: Failed to add balance to Sefer wallet
|
||||
[2025-03-20 22:24:40] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:24:40] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:24:40] STEP 1: Payment found | Data: {"payment_id":"24","status":"1","amount":200}
|
||||
[2025-03-20 22:24:40] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:24:40] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:24:40] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:24:40] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:24:40] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:24:40] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:24:40] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:24:40] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:24:40] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:24:40] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 22:24:40] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"9d924a59964a75c672502e0a961e79bcdb23d62f6fadfe2aa6b5cac145022015"}
|
||||
[2025-03-20 22:24:40] STEP 6: Failed to add balance to Sefer wallet | Data: {"status":"failure","message":"Invalid or already used token"}
|
||||
[2025-03-20 22:38:27] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:38:27] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:38:27] STEP 1: Payment found | Data: {"payment_id":"25","status":"1","amount":200}
|
||||
[2025-03-20 22:38:27] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:38:27] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:38:27] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:38:27] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:38:27] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:38:27] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:38:27] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:38:27] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:38:27] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:38:27] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 22:38:27] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"d0b8b5d6e25d74038ff96d9bb61533213536049fc99484df751cbff86f354058"}
|
||||
[2025-03-20 22:38:27] STEP 6: Failed to add balance to Sefer wallet | Data: {"status":"failure","message":"Invalid or already used token"}
|
||||
[2025-03-20 22:45:51] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:45:51] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:45:51] STEP 1: Payment found | Data: {"payment_id":"26","status":"1","amount":200}
|
||||
[2025-03-20 22:45:51] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:45:51] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:45:51] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:45:51] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:45:51] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:45:51] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:45:51] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:45:51] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:45:51] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:45:51] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 22:45:51] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"698f6808c38e9075e74513a21a2b8255c9b04c1473be5fb9bc559488e3a29c1f"}
|
||||
[2025-03-20 22:45:51] STEP 6: Failed to add balance to Sefer wallet | Data: {"status":"failure","message":"Invalid or already used token"}
|
||||
[2025-03-20 22:48:56] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:48:56] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:48:56] STEP 1: Payment found | Data: {"payment_id":"27","status":"1","amount":200}
|
||||
[2025-03-20 22:48:56] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:48:56] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:48:56] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:48:56] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:48:56] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:48:56] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:48:56] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:48:56] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:48:56] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:48:56] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 22:48:56] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"86128c316f4f275e543fc07b7a171c39a1c92b81fcadd1548f6c150a1651d1f4"}
|
||||
[2025-03-20 22:48:56] STEP 6.2: HTTP error in Sefer wallet update | Data: {"http_code":500,"response":""}
|
||||
[2025-03-20 22:48:56] STEP 6: Failed to add balance to Sefer wallet
|
||||
[2025-03-20 22:51:43] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:51:43] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:51:43] STEP 1: Payment found | Data: {"payment_id":"28","status":"1","amount":200}
|
||||
[2025-03-20 22:51:43] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:51:43] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:51:43] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:51:43] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:51:43] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:51:43] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:51:43] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:51:43] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:51:43] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:51:43] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 22:51:43] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"9a7626a1c58f54e0181a059a9ce4758af2c75998941cc6c00947377b4fc5bacf"}
|
||||
[2025-03-20 22:51:43] STEP 6.2: HTTP error in Sefer wallet update | Data: {"http_code":500,"response":""}
|
||||
[2025-03-20 22:51:43] STEP 6: Failed to add balance to Sefer wallet
|
||||
[2025-03-20 22:54:12] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 22:54:12] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 22:54:12] STEP 1: Payment found | Data: {"payment_id":"29","status":"1","amount":200}
|
||||
[2025-03-20 22:54:12] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 22:54:12] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 22:54:12] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 22:54:12] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 22:54:12] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 22:54:12] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:54:12] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 22:54:12] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 22:54:12] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 22:54:12] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 22:54:12] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"7f955f629d5da0ec127b6c0b32de0fa44aeaad9c9ec8231418905c8031c94316"}
|
||||
[2025-03-20 22:54:12] STEP 6: Balance added to Sefer wallet | Data: {"status":"success","message":"Wallet data saved successfully"}
|
||||
[2025-03-20 22:54:12] STEP 7: Process completed successfully | Data: {"payment_id":"29","amount":215,"passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:00:11] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:00:11] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 23:00:11] STEP 1: Payment found | Data: {"payment_id":"30","status":"1","amount":200}
|
||||
[2025-03-20 23:00:11] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 23:00:11] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 23:00:11] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 23:00:11] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 23:00:11] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 23:00:11] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:00:11] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:00:11] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:00:11] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 23:00:11] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 23:00:11] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:00:11] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"5c6d19041cfab3851040212ccf045f21be41c84c5d736dfc58b2da7eb3c8854a"}
|
||||
[2025-03-20 23:00:11] STEP 6: Balance added to Sefer wallet | Data: {"status":"success","message":"Wallet data saved successfully"}
|
||||
[2025-03-20 23:00:11] STEP 7: Process completed successfully | Data: {"payment_id":"30","amount":215,"passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:07:14] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:07:14] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 23:07:14] STEP 1: Payment found | Data: {"payment_id":"31","status":"1","amount":200}
|
||||
[2025-03-20 23:07:14] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 23:07:14] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 23:07:14] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 23:07:14] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 23:07:14] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 23:07:14] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:07:14] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:07:14] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:07:14] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 23:07:14] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 23:07:14] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:07:14] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"b912396d32c1b398d65e4459ac945079025840776db6feb34a9cc4f06b60191a"}
|
||||
[2025-03-20 23:07:14] STEP 6: Balance added to Sefer wallet | Data: {"status":"success","message":"Wallet data saved successfully"}
|
||||
[2025-03-20 23:07:14] STEP 7: Process completed successfully | Data: {"payment_id":"31","amount":215,"passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:13:05] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 23:13:05] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 23:13:05] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"3b68024312f568ea264d279280d9a6164a4a272531b21678d6a5e556816a7592"}
|
||||
[2025-03-20 23:28:20] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:28:20] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 23:28:20] STEP 1: Payment found | Data: {"payment_id":"36","status":"1","amount":200}
|
||||
[2025-03-20 23:28:20] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 23:28:20] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 23:28:20] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 23:28:20] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 23:28:20] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 23:28:20] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:28:20] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:28:20] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:28:20] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 23:28:20] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 23:28:20] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:28:20] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"b0f64da4cfca1bf153c523a03cd692b8f1a44c09674683df5406dcd6c874f00d"}
|
||||
[2025-03-20 23:28:20] STEP 6: Balance added to Sefer wallet | Data: {"status":"success","message":"Wallet data saved successfully"}
|
||||
[2025-03-20 23:28:20] STEP 7: Process completed successfully | Data: {"payment_id":"36","amount":215,"passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:31:52] STEP 0: Request received | Data: {"user_id":"+201010101010","passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:31:52] STEP 1: Querying latest payment | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-20 23:31:52] STEP 1: Payment found | Data: {"payment_id":"37","status":"1","amount":200}
|
||||
[2025-03-20 23:31:52] STEP 2: Payment status verified | Data: {"status":"1"}
|
||||
[2025-03-20 23:31:52] STEP 3: Calculating bonus | Data: {"amount":200}
|
||||
[2025-03-20 23:31:52] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 23:31:52] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 23:31:52] STEP 3: Bonus calculated | Data: {"original_amount":200,"final_amount":215}
|
||||
[2025-03-20 23:31:52] STEP 4: Generating payment token | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:31:52] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:31:52] STEP 5: Adding balance to passenger wallet | Data: {"passengerId":"113172279072358305645","amount":215}
|
||||
[2025-03-20 23:31:52] STEP 5: Balance added to passenger wallet | Data: {"status":"success","message":"Wallet record created successfully"}
|
||||
[2025-03-20 23:31:52] STEP 6: Adding balance to Sefer wallet | Data: {"passengerId":"113172279072358305645","amount":215,"paymentMethod":"visa-in"}
|
||||
[2025-03-20 23:31:52] STEP 4: Token generated successfully | Data: {"token_length":64}
|
||||
[2025-03-20 23:31:52] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"dc156df7310f9ce998bf0fae3a325a716ec7806ff037021c4b12b3b800f37bf2"}
|
||||
[2025-03-20 23:31:52] STEP 6: Balance added to Sefer wallet | Data: {"status":"success","message":"Wallet data saved successfully"}
|
||||
[2025-03-20 23:31:52] STEP 7: Process completed successfully | Data: {"payment_id":"37","amount":215,"passengerId":"113172279072358305645"}
|
||||
[2025-03-20 23:49:27] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-20 23:49:27] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-20 23:49:27] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"172ea88c6fc36188b435508f8f434736cc58f2b75feb54e6b8fa1674d4a9910a"}
|
||||
[2025-03-21 09:32:00] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 09:32:00] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 09:32:00] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"6ad135e7b01bf9c1ab99f68d0dead8f91bc93588c173d837a8f3ce77e96c6eee"}
|
||||
[2025-03-21 09:33:06] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 09:33:06] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 09:33:06] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"4ebb300836e9cb522a0afd422e818c2603fda11ef52e050a78624f728b994f01"}
|
||||
[2025-03-21 09:41:54] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 09:45:44] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 09:48:54] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 11:30:48] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 11:37:18] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 12:19:24] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 12:20:48] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 12:22:09] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 12:22:09] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 12:22:09] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"a5589a7714ea56acd72341a0c14079d3b8d548dbef885a2f71ea19cd20325c91"}
|
||||
[2025-03-21 12:37:16] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 12:37:16] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 12:37:17] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"d6f2e4bc82d052bcba3d287e5c4f3465ad8f3707ee739692e2832a5b9dc131c6"}
|
||||
[2025-03-21 12:49:11] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 12:51:03] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 12:51:03] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 12:51:04] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"3081636c569695289e5484b738d6cf63bd015505490b3c94841538767ff2f058"}
|
||||
[2025-03-21 14:04:09] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 14:04:09] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 14:04:10] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"67e48b2025ea10823d2c37eb9f821963efff9fa26b5e41d5b1d391376a31b59a"}
|
||||
[2025-03-21 14:07:48] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 14:17:03] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 14:17:03] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 14:17:03] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"e952b7b4417a71eaff2b348e8241c4a63d97b12d4ad1d79acfb5cce1992a2acd"}
|
||||
[2025-03-21 14:24:19] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 14:28:35] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 14:32:45] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 14:37:37] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 14:38:56] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 14:38:56] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 14:38:56] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"a8aad013fb6332aef78521c6cccff74485c158bbdb3242e51e66ab7f1059e4c9"}
|
||||
[2025-03-21 14:42:15] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 14:42:15] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 14:42:15] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"2803a235094afa54c82ad250292f15a121f524bf4c109df32342068a03c9c212"}
|
||||
[2025-03-21 14:45:52] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 14:45:52] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 14:45:52] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"1e6a84b59f5580fb4fe52248222620c7cb3c44f8edfeb0db0003192a90403aa3"}
|
||||
[2025-03-21 14:54:41] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 14:59:31] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 14:59:31] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 14:59:31] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"7dee4184aa286693ef8e3a2c4fe03b103d6ff8348198f5faa6bfc91c4ed6ae21"}
|
||||
[2025-03-21 15:19:15] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:19:15] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:19:15] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"0ebad59f5b4b439fae5e5e8f6fa65e816ac5943e724ef1758dc714bdea39bdb8"}
|
||||
[2025-03-21 15:21:45] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:21:45] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:21:45] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"abfb981f8fbfba8cf3591c502d27a9b03066d909c95f44b3adfee6b01523e4df"}
|
||||
[2025-03-21 15:23:37] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:23:37] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:23:37] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"c0775be365dbad9fc99ee84786b7101d4bbd51bf4d8b29475e7407b350a5873f"}
|
||||
[2025-03-21 15:28:30] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:28:30] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:28:31] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"51181d3015c2756d256569e96ec7221b34aba737483a3f8e92858840c50441ae"}
|
||||
[2025-03-21 15:28:55] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:28:55] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:28:55] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"6a3c946d98dbc3ed66e8e30b80c56fc8925073fce70105260c64bc86c1e5cd6c"}
|
||||
[2025-03-21 15:35:16] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:35:16] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:35:16] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"b4f3b175044981388b0ecd6cf9f7f9713f591f20c58e55a977c9be9029a45fb4"}
|
||||
[2025-03-21 15:38:43] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:38:43] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:38:43] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"de17e4d8db68e3e0649d6515937fa1ef8464a47bef52a8178a751e54d1fde4e3"}
|
||||
[2025-03-21 15:39:48] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:39:48] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:39:48] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"cf0b6242a0c25023b69dfdfa17ee4ff5c4e265e0b1ae43276891347f08f6d648"}
|
||||
[2025-03-21 15:43:53] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
[2025-03-21 15:44:58] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:44:58] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:44:59] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"fc66691cf53e4f559b3ff957a13384a84052ca52b191de3c5a76ed5572827e2e"}
|
||||
[2025-03-21 15:47:30] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:47:30] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:47:30] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"c16c271306018e5791ba0e0ca8012ba4c3674837bec30164c39a61e0715f7124"}
|
||||
[2025-03-21 15:49:41] STEP 3.1: Bonus calculation input | Data: {"amount":200}
|
||||
[2025-03-21 15:49:41] STEP 3.2: Bonus calculation result | Data: {"input":200,"output":215}
|
||||
[2025-03-21 15:49:41] STEP 6.0.2: Generated new Sefer token | Data: {"token_length":"2d2024c3b3954388a45dc40ec0ac8a62af917975def467636a26ee14ca97c8b9"}
|
||||
[2025-03-21 16:36:27] STEP 1: No payment found | Data: {"user_id":"+201010101010"}
|
||||
125
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/confirm_payment.php
Executable file
125
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/confirm_payment.php
Executable file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
// /v1/main/ride/mtn/driver/confirm_payment.php
|
||||
include "../../../connect.php";
|
||||
|
||||
// It's better to use __DIR__ for reliable file path resolution.
|
||||
// Assuming your private_key.pem is in the same directory as this script.
|
||||
$privateKeyPath = __DIR__ . "/private_key.pem";
|
||||
|
||||
$baseUrl = rtrim(getenv('MTN_API_BASE_URL'), '/');
|
||||
$terminalId = getenv('MTN_TERMINAL_ID');
|
||||
$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyPath));
|
||||
|
||||
$invoice = filterRequest('invoiceNumber');
|
||||
$phone = filterRequest('phone');
|
||||
$guid = filterRequest('guid');
|
||||
$operationNumber = filterRequest('operationNumber');
|
||||
$code = filterRequest('otp'); // The OTP
|
||||
|
||||
error_log("MTN Confirm (Driver): Start request for invoice={$invoice}, phone={$phone}, guid={$guid}, opNum={$operationNumber}");
|
||||
|
||||
if (!$invoice || !$phone || !$guid || !$operationNumber || !$code) {
|
||||
error_log("MTN Confirm (Driver): Missing parameters");
|
||||
printFailure("Missing parameters.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Encrypt the code
|
||||
$hashBin = hash('sha256', $code, true);
|
||||
$codeB64 = base64_encode($hashBin);
|
||||
|
||||
$body = [
|
||||
'Invoice' => intval($invoice),
|
||||
'Phone' => $phone,
|
||||
'Guid' => $guid,
|
||||
'OperationNumber' => intval($operationNumber),
|
||||
'Code' => $codeB64
|
||||
];
|
||||
$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
error_log("MTN Confirm (Driver): Prepared body JSON: " . $bodyJson);
|
||||
|
||||
// Generate signature
|
||||
$signResult = openssl_sign($bodyJson, $sig, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
if (!$signResult) {
|
||||
error_log("MTN Confirm (Driver): Failed to generate signature");
|
||||
printFailure("Signature error.");
|
||||
exit;
|
||||
}
|
||||
$xSignature = base64_encode($sig);
|
||||
error_log("MTN Confirm (Driver): Generated signature");
|
||||
|
||||
// Send the request
|
||||
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/confirm");
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $bodyJson,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json",
|
||||
"Request-Name: pos_web/payment_phone/confirm",
|
||||
"Subject: {$terminalId}",
|
||||
"X-Signature: {$xSignature}"
|
||||
]
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
error_log("MTN Confirm (Driver): HTTP $httpCode - Response: $response");
|
||||
if ($curlError) {
|
||||
error_log("MTN Confirm (Driver): cURL error - $curlError");
|
||||
}
|
||||
|
||||
// --- SOLUTION IMPLEMENTED HERE ---
|
||||
// 1. Decode the response from MTN to check its contents.
|
||||
$responseData = json_decode($response, true) ?: [];
|
||||
|
||||
// 2. First, check for network/gateway level failure.
|
||||
if ($httpCode !== 200) {
|
||||
error_log("MTN Confirm (Driver): HTTP failure for invoice {$invoice}. Code: {$httpCode}");
|
||||
// Use printFailure to send a structured error to Flutter
|
||||
printFailure(['message' => 'MTN Gateway Error', 'http' => $httpCode, 'details' => $responseData]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 3. Now, check for business-logic failure (like "Balance not enough").
|
||||
$errno = $responseData['Errno'] ?? -1; // Default to an error state if Errno is missing
|
||||
if ($errno !== 0) {
|
||||
$apiError = $responseData['Error'] ?? 'Unknown MTN API Error';
|
||||
error_log("MTN Confirm (Driver): Business failure for invoice {$invoice}. Errno: {$errno}, Reason: {$apiError}");
|
||||
// This now sends the specific error message in the format Flutter expects!
|
||||
printFailure(['message' => $apiError, 'errno' => $errno, 'details' => $responseData]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// --- ONLY PROCEED TO DATABASE ON FULL SUCCESS (HTTP 200 AND Errno 0) ---
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `paymentsLogSyriaDriver` SET status = 1, updated_at = NOW()
|
||||
WHERE order_ref = :inv"
|
||||
);
|
||||
$stmt->execute([':inv' => $invoice]);
|
||||
error_log("MTN Confirm (Driver): Payment updated successfully in DB for invoice={$invoice}");
|
||||
|
||||
// The file path correction from before remains important.
|
||||
include_once __DIR__ . '/finalize_wallet_payment.php';
|
||||
|
||||
// Call the wallet finalization logic
|
||||
if (function_exists('finalizeWalletPayment')) {
|
||||
$_GET['orderRef'] = $invoice;
|
||||
finalizeWalletPayment($con);
|
||||
} else {
|
||||
error_log("MTN Confirm (Driver): FATAL - finalizeWalletPayment() function does not exist after include.");
|
||||
}
|
||||
|
||||
// On success, send a success response to Flutter
|
||||
printSuccess(['message' => 'Payment confirmed successfully', 'details' => $responseData]);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log("MTN Confirm (Driver): DB update error - " . $e->getMessage());
|
||||
printFailure("Database processing error.");
|
||||
}
|
||||
|
||||
103
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/finalize_wallet_payment.php
Executable file
103
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/finalize_wallet_payment.php
Executable file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// wallet/finalize_wallet_payment.php
|
||||
include_once "../../../jwtconnect.php";
|
||||
|
||||
define("LOG_FILE", "../logs/payment_verification.log");
|
||||
|
||||
function logError($step, $message, $data = null) {
|
||||
$logDir = dirname(LOG_FILE);
|
||||
if (!is_dir($logDir)) { mkdir($logDir, 0755, true); }
|
||||
$logEntry = "[" . date('Y-m-d H:i:s') . "] STEP {$step}: {$message}";
|
||||
if ($data !== null) { $logEntry .= " | Data: " . json_encode($data, JSON_UNESCAPED_UNICODE); }
|
||||
file_put_contents(LOG_FILE, $logEntry . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
function generateToken($con, $driverId, $amount): ?string {
|
||||
global $secretKey;
|
||||
$data = $driverId . $amount . time() . ($secretKey ?? 'default_secret');
|
||||
$hash = hash('sha256', $data);
|
||||
$randomBytes = bin2hex(random_bytes(16));
|
||||
$token = substr($hash . $randomBytes, 0, 64);
|
||||
|
||||
$stmt = $con->prepare("INSERT INTO payment_tokens (token, driverID, dateCreated, amount) VALUES (:token, :driverID, NOW(), :amount)");
|
||||
$stmt->execute([':token' => $token, ':driverID' => $driverId, ':amount' => $amount]);
|
||||
return $stmt->rowCount() > 0 ? $token : null;
|
||||
}
|
||||
|
||||
function generatePaymentID($con, $driverId, $amount, $method): ?string {
|
||||
$stmt = $con->prepare("INSERT INTO paymentsDriverPoints (`amount`, `payment_method`, `driverID`) VALUES (:amount, :method, :driverID)");
|
||||
$stmt->execute([':driverID' => $driverId, ':amount' => $amount, ':method' => $method]);
|
||||
return $stmt->rowCount() > 0 ? $con->lastInsertId() : null;
|
||||
}
|
||||
|
||||
function finalizeWalletPayment($con) {
|
||||
$orderRef = $_GET['orderRef'] ?? null;
|
||||
if (empty($orderRef)) {
|
||||
logError("FINALIZE", "Missing orderRef");
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. تحقق من الدفع
|
||||
$stmt = $con->prepare("SELECT * FROM `paymentsLogSyriaDriver` WHERE order_ref = :order_ref AND status = 1 LIMIT 1");
|
||||
$stmt->execute([':order_ref' => $orderRef]);
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$payment) {
|
||||
logError("FINALIZE", "Payment not found or not completed", ['orderRef' => $orderRef]);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$driverId = $payment['user_id'];
|
||||
$originalAmount = floatval($payment['amount']);
|
||||
$paymentMethod = $payment['payment_method'] ?? 'ecash';
|
||||
|
||||
// حساب المكافأة
|
||||
$bonusAmount = match ((int)$originalAmount) {
|
||||
10000 => 10000.0,
|
||||
20000 => 21000.0,
|
||||
40000 => 45000.0,
|
||||
100000 => 110000.0,
|
||||
default => $originalAmount,
|
||||
};
|
||||
|
||||
// إنشاء التوكنات
|
||||
$tokenDriver = generateToken($con, $driverId, $bonusAmount);
|
||||
if (!$tokenDriver) throw new Exception('Failed to generate driver token');
|
||||
|
||||
$tokenSefer = generateToken($con, $driverId, $originalAmount);
|
||||
if (!$tokenSefer) throw new Exception('Failed to generate sefer token');
|
||||
|
||||
$paymentID = generatePaymentID($con, $driverId, $bonusAmount, $paymentMethod);
|
||||
if (!$paymentID) throw new Exception('Failed to generate payment ID');
|
||||
|
||||
// driverWallet
|
||||
$insertDriver = $con->prepare("INSERT INTO driverWallet (driverID, paymentID, amount, paymentMethod) VALUES (:driverID, :paymentID, :amount, :paymentMethod)");
|
||||
$insertDriver->execute([
|
||||
':driverID' => $driverId,
|
||||
':paymentID' => $paymentID,
|
||||
':amount' => $bonusAmount,
|
||||
':paymentMethod' => $paymentMethod
|
||||
]);
|
||||
if ($insertDriver->rowCount() === 0) throw new Exception('Insert to driverWallet failed');
|
||||
|
||||
$con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token")->execute([':token' => $tokenDriver]);
|
||||
|
||||
// seferWallet
|
||||
$insertSefer = $con->prepare("INSERT INTO seferWallet (driverId, passengerId, amount, paymentMethod, token, createdAt)
|
||||
VALUES (:driverId, :passengerId, :amount, :paymentMethod, :token, CURRENT_TIMESTAMP)");
|
||||
$insertSefer->execute([
|
||||
':driverId' => $driverId,
|
||||
':passengerId' => 'driver',
|
||||
':amount' => $originalAmount,
|
||||
':paymentMethod' => $paymentMethod,
|
||||
':token' => $tokenSefer
|
||||
]);
|
||||
$con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token")->execute([':token' => $tokenSefer]);
|
||||
|
||||
logError("FINALIZE", "Wallets updated successfully", ['orderRef' => $orderRef]);
|
||||
printSuccess("FINALIZE", "Wallets updated successfully");
|
||||
} catch (Throwable $e) {
|
||||
logError("FINALIZE", "Exception during finalization: " . $e->getMessage(), ['orderRef' => $orderRef]);
|
||||
}
|
||||
}
|
||||
47
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/generate_keys.php
Executable file
47
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/generate_keys.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// File: generate_keys.php
|
||||
// الوظيفة: إنشاء زوج المفاتيح (العام والخاص) لمرة واحدة فقط
|
||||
|
||||
// إعدادات لتوليد المفتاح
|
||||
$config = [
|
||||
"digest_alg" => "sha256",
|
||||
"private_key_bits" => 1024,
|
||||
"private_key_type" => OPENSSL_KEYTYPE_RSA,
|
||||
];
|
||||
|
||||
// إنشاء زوج المفاتيح
|
||||
$res = openssl_pkey_new($config);
|
||||
|
||||
if (!$res) {
|
||||
die('Failed to generate new private key. Error: ' . openssl_error_string());
|
||||
}
|
||||
|
||||
// استخراج المفتاح الخاص
|
||||
openssl_pkey_export($res, $private_key);
|
||||
|
||||
// استخراج المفتاح العام
|
||||
$public_key_details = openssl_pkey_get_details($res);
|
||||
$public_key = $public_key_details["key"];
|
||||
|
||||
// حفظ المفاتيح في ملفات
|
||||
file_put_contents('private_key.pem', $private_key);
|
||||
file_put_contents('public_key.pem', $public_key);
|
||||
|
||||
echo "<h1>Keys Generated Successfully!</h1>";
|
||||
echo "<h2>Private Key (saved to private_key.pem):</h2>";
|
||||
echo "<pre>" . htmlspecialchars($private_key) . "</pre>";
|
||||
echo "<h2>Public Key (saved to public_key.pem):</h2>";
|
||||
echo "<pre>" . htmlspecialchars($public_key) . "</pre>";
|
||||
|
||||
// --- تحضير المفتاح العام لعملية التفعيل ---
|
||||
// إزالة الهيدر والفوتر والأسطر الجديدة كما هو مطلوب
|
||||
$formatted_public_key = str_replace("-----BEGIN PUBLIC KEY-----", "", $public_key);
|
||||
$formatted_public_key = str_replace("-----END PUBLIC KEY-----", "", $formatted_public_key);
|
||||
$formatted_public_key = preg_replace("/\s+/", "", $formatted_public_key);
|
||||
|
||||
|
||||
echo "<h2>Formatted Public Key (for Terminal Activation):</h2>";
|
||||
echo "<p><strong>انسخ هذا المفتاح لاستخدامه في خطوة تفعيل الجهاز (activate_terminal.php)</strong></p>";
|
||||
echo "<textarea rows='5' cols='80' readonly>" . htmlspecialchars($formatted_public_key) . "</textarea>";
|
||||
|
||||
?>
|
||||
54
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/initiate_payment.php
Executable file
54
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/initiate_payment.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// /v1/main/ride/mtn/passenger/initiate_payment.php
|
||||
include "../../../connect.php";
|
||||
|
||||
$baseUrl = rtrim(getenv('MTN_API_BASE_URL'), '/');
|
||||
$terminalId = getenv('MTN_TERMINAL_ID');
|
||||
$privateKeyPem = getenv('MTN_PRIVATE_KEY');
|
||||
|
||||
$invoice = filterRequest('invoice'); // رقم الفاتورة
|
||||
$phone = filterRequest('phone'); // رقم الزبون
|
||||
$guid = uniqid('mtn_');
|
||||
|
||||
if (!$invoice || !$phone) {
|
||||
printFailure("Missing invoice or phone.");
|
||||
exit;
|
||||
}
|
||||
|
||||
$body = json_encode([
|
||||
'Invoice' => intval($invoice),
|
||||
'Phone' => $phone,
|
||||
'Guid' => $guid
|
||||
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$hash = hash('sha256', $body, true);
|
||||
openssl_sign($hash, $sig, $privateKeyPem, OPENSSL_ALGO_SHA256);
|
||||
$xSignature = base64_encode($sig);
|
||||
|
||||
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $body,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json",
|
||||
"Request-Name: pos_web/payment_phone/initiate",
|
||||
"Subject: {$terminalId}",
|
||||
"X-Signature: {$xSignature}"
|
||||
]
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
// سجل المحاولة مع Guid
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `mtn_payments`
|
||||
SET guid = :guid, status = 3, updated_at = NOW()
|
||||
WHERE invoice = :inv"
|
||||
);
|
||||
$stmt->execute([':guid'=>$guid, ':inv'=>$invoice]);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
http_response_code($httpCode);
|
||||
echo $response;
|
||||
56
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/key.php
Executable file
56
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/key.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// بيانات التفعيل
|
||||
$terminalId = "9001000000060863";
|
||||
$activationCode = "26164711";
|
||||
$serialNumber = "INTALEQ-001"; // يمكنك تغييره
|
||||
|
||||
// المفتاح العام على سطر واحد — بدون BEGIN/END وبدون أسطر جديدة
|
||||
//$publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDNxFbepx2OrpyrNG4+/aAaH3Rjc8dGw6B6vMAfsZzzm4wzoSkrtsr6jfuaMTZRLwxS5h8k1ztLG1HrOmL/NDsiE/7yxaKLAIZyWB/rR9byvPeOCC8QnCd/08kmxNl/l7Akn6qlPwsVpKUUNsr0SkU9lShMAw4OBgQq399jsbkFSwIDAQAB";
|
||||
$publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOhVAdUyxFpVNSyjRndMWEPAN9vJEetMzLbjF9DTn2lPVuRj/Mkwq9wCNhy+tdeX2lIn4K3EkONBvYJubBhxnYOoQuMchPW5vG7VnmpLjZ7TkpM2n9fcMu8u1GkLatLblDI4LTfvn3851+nhpnYlUVkjw5GAhH4XnEpveIjqDhzQIDAQAB";
|
||||
// جسم الطلب
|
||||
$body = [
|
||||
"Key" => $publicKey,
|
||||
"Secret" => $activationCode,
|
||||
"Serial" => $serialNumber
|
||||
];
|
||||
//$bodyJson = json_encode($body, JSON_UNESCAPED_SLASHES);
|
||||
$bodyJson = trim(stripslashes(json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS)),'"');
|
||||
//$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
// 1. توليد هاش SHA256 للـ JSON
|
||||
//$bodyHash = hash('sha256', $bodyJson, true);
|
||||
|
||||
// 2. تحميل المفتاح الخاص للتوقيع
|
||||
$privateKey = openssl_pkey_get_private(file_get_contents("private_key.pem")); // تأكد من وجود هذا الملف بجانب السكربت
|
||||
|
||||
// 3. توقيع الهاش
|
||||
openssl_sign($bodyJson, $signature, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
|
||||
// 4. تحويل التوقيع إلى Base64
|
||||
$xSignature = base64_encode($signature);
|
||||
|
||||
// 5. إرسال الطلب
|
||||
$headers = [
|
||||
"Content-Type: application/json",
|
||||
"Accept-Language: en",
|
||||
"Request-Name: pos_web/pos/activate",
|
||||
"Subject: $terminalId",
|
||||
"X-Signature: $xSignature"
|
||||
];
|
||||
|
||||
$ch = curl_init("https://cashmobile.mtnsyr.com:9000");
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyJson);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
// ✅ النتيجة
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
"httpCode" => $httpCode,
|
||||
"response" => json_decode($response, true),
|
||||
"sentBody" => $body,
|
||||
]);
|
||||
129
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/mtn_start.php
Executable file
129
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver/mtn_start.php
Executable file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
include "../../../connect.php";
|
||||
date_default_timezone_set("Asia/Damascus");
|
||||
|
||||
// ========== إعدادات MTN ==========
|
||||
$terminalId = "9001000000060863";
|
||||
$currencyCode = 760;
|
||||
$sessionNumber = 0;
|
||||
$ttl = 15;
|
||||
|
||||
// ====== استقبال البيانات من فلاتر ======
|
||||
$amount = filterRequest("amount");
|
||||
$passengerId = filterRequest("passengerId");
|
||||
$phone = filterRequest("phone");
|
||||
|
||||
// ✅ Log مبدئي
|
||||
error_log("🚦 START | passengerId: $passengerId | phone: $phone | amount: $amount");
|
||||
|
||||
// تحقق من المدخلات
|
||||
if (empty($amount) || empty($passengerId) || empty($phone) || $amount <= 0) {
|
||||
error_log("❌ Invalid input: amount=$amount, passengerId=$passengerId, phone=$phone");
|
||||
printFailure("بيانات الدفع غير كاملة أو غير صالحة.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ====== توليد invoiceNumber و GUID ======
|
||||
$invoiceNumber = mt_rand(10000000000, 99999999999);
|
||||
//$invoiceNumber = "MTN_" . $passengerId . "_" . time();
|
||||
$guid = uniqid("mtn_");
|
||||
error_log("🧾 Generated Invoice: $invoiceNumber");
|
||||
error_log("🧭 Generated GUID: $guid");
|
||||
|
||||
// ====== 1. إنشاء الفاتورة ======
|
||||
$createInvoiceBody = [
|
||||
"Amount" => intval($amount * 100),
|
||||
"Invoice" => $invoiceNumber,
|
||||
"Session" => $sessionNumber,
|
||||
"TTL" => $ttl
|
||||
];
|
||||
error_log("📦 Create Invoice Body: " . json_encode($createInvoiceBody, JSON_UNESCAPED_UNICODE));
|
||||
$invoiceResponse = sendMtnApiRequest("pos_web/invoice/create", $terminalId, $createInvoiceBody);
|
||||
error_log("📥 Create Invoice Response: " . json_encode($invoiceResponse, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (!$invoiceResponse || isset($invoiceResponse['Errno']) && $invoiceResponse['Errno'] != 0) {
|
||||
error_log("❌ Failed to create invoice. Error: " . json_encode($invoiceResponse));
|
||||
printFailure("فشل إنشاء الفاتورة عبر MTN.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ====== 2. بدء الدفع ======
|
||||
$initiateBody = [
|
||||
"Invoice" => $invoiceNumber,
|
||||
"Phone" => $phone,
|
||||
"Guid" => $guid
|
||||
];
|
||||
error_log("📤 body initiateBody: $initiateBody");
|
||||
error_log("📦 Initiate Payment Body: " . json_encode($initiateBody, JSON_UNESCAPED_UNICODE));
|
||||
$initiateResponse = sendMtnApiRequest("pos_web/payment_phone/initiate", $terminalId, $initiateBody);
|
||||
error_log("📥 Initiate Response: " . json_encode($initiateResponse, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (!$initiateResponse || !isset($initiateResponse['OperationNumber'])) {
|
||||
error_log("❌ Failed to initiate payment.");
|
||||
printFailure($initiateResponse);
|
||||
exit;
|
||||
}
|
||||
|
||||
$operationNumber = $initiateResponse['OperationNumber'];
|
||||
|
||||
// ====== 3. تسجيل العملية ======
|
||||
try {
|
||||
$stmt = $con->prepare("INSERT INTO `paymentsLogSyriaDriver`
|
||||
(`user_id`, `amount`, `status`, `order_ref`, `payment_method`, `created_at`)
|
||||
VALUES (?, ?, 2, ?, 'mtn', NOW())");
|
||||
$stmt->execute([$passengerId, $amount, $invoiceNumber]);
|
||||
error_log("✅ DB Log Inserted.");
|
||||
} catch (PDOException $e) {
|
||||
error_log("❌ DB ERROR: " . $e->getMessage());
|
||||
printFailure("فشل في تسجيل العملية.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ====== 4. نجاح
|
||||
error_log("✅ Payment initiation successful.");
|
||||
printSuccess([
|
||||
"invoiceNumber" => $invoiceNumber,
|
||||
"operationNumber" => $operationNumber,
|
||||
"guid" => $guid
|
||||
]);
|
||||
|
||||
|
||||
// ====== دالة إرسال الطلب =====================
|
||||
function sendMtnApiRequest($requestName, $terminalId, $body)
|
||||
{
|
||||
$apiUrl = "https://cashmobile.mtnsyr.com:9000";
|
||||
$privateKey = openssl_pkey_get_private(file_get_contents("private_key.pem"));
|
||||
|
||||
// ✅ تحويل الـ body إلى JSON بدون فراغات أو أسطر
|
||||
$bodyJson = trim(stripslashes(json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS)), '"');
|
||||
//$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
// ✅ توليد التوقيع
|
||||
// $bodyHash = hash('sha256', $bodyJson, true);
|
||||
error_log("📤 body before JSON: $bodyJson");
|
||||
openssl_sign($bodyJson, $signature, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
$xSignature = base64_encode($signature);
|
||||
error_log("📤 body xSignature: $xSignature");
|
||||
// ✅ رؤوس الطلب
|
||||
$headers = [
|
||||
"Content-Type: application/json",
|
||||
"Accept-Language: en",
|
||||
"Request-Name: $requestName",
|
||||
"Subject: $terminalId",
|
||||
"X-Signature: $xSignature"
|
||||
];
|
||||
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyJson);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// ✅ لوق داخلي
|
||||
error_log("🔐 Signature for $requestName: $xSignature");
|
||||
error_log("📤 Sent JSON: $bodyJson");
|
||||
|
||||
curl_close($ch);
|
||||
return json_decode($response, true);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXwIBAAKBgQDOhVAdUyxFpVNSyjRndMWEPAN9vJEetMzLbjF9DTn2lPVuRj/M
|
||||
kwq9wCNhy+tdeX2lIn4K3EkONBvYJubBhxnYOoQuMchPW5vG7VnmpLjZ7TkpM2n9
|
||||
fcMu8u1GkLatLblDI4LTfvn3851+nhpnYlUVkjw5GAhH4XnEpveIjqDhzQIDAQAB
|
||||
AoGBALRcAvqJT8nHN7y+8QNFHNZ+XwIpc4egmJY1Ny0iJvPtZWaYHVG5PRE4Qu4+
|
||||
29+3oX5dYDx146tu4L5mQvLS3ULBsvxaUZt2lT/vxkQzI9pNfXw584WvIrbtxQod
|
||||
ILvBcnamwQa9hEOIFZVyZ/hzkzUcMO6cAXqvsfqqPgJhm7PBAkEA+xgE9CUOLDFl
|
||||
vLePQKGcHIUOsPLr16qNEgGhTW7Km3OMMqoB2f7t67xOHGqK6tnANRM4Sk6IModI
|
||||
wbZuVh4jMQJBANKOVmIdDLNffZVHp90SDRG7/YdK2R5ob361CIkcUzjh927Wfs5W
|
||||
A/WroB7eJ7pWiq2BMaj/xq65nYaCOldvaV0CQQDm12c+eY61DFjnDa6ykaEvCxi9
|
||||
jydJp+93vW3o/VFhZvJeZbO8EcX0MrNxJnY+gSBW6yuWDOrj4UH/bVO08pIRAkEA
|
||||
lH3TiBAqo9nlTEEjrnILi4VD0IVFx/8pGnf71A6I1qXuBVn6RfQ9iKWIIBzWccCU
|
||||
vrZNWn1AFntLD9CJ6p3k9QJBAMbSQ9CoXWlOLJRduV15ER1ZyE/inVd4jIvtjAgz
|
||||
b7QaM62Ecxl3D8EI/LTSZV9Oa8D/62cJeMsflVa7gpavL70=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDqBQZEJXWCQwPsPzBM70M3TjyU
|
||||
5vwCZWoEtUomR9Qu+dEQaa0Hniz6JY8+goCxfMYuZQw6+kimctA2KqzT2pCsJufN
|
||||
b92pSAMZgb0RSTl2y62oJkJd2WY7dj36AvPEyw6DxCFItvFOu7HGl3LlHQBriiw3
|
||||
jwtuS6DO7gbmAJPU8wIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
115
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver_payout_syria.php
Executable file
115
walletintaleq.intaleq.xyz/v2/main/ride/mtn/driver_payout_syria.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
include "../../connect.php";
|
||||
|
||||
// --- 2. استقبال البيانات من الطلب ---
|
||||
$driver_id = filterRequest("driver_id");
|
||||
$driver_name = filterRequest("driver_name");
|
||||
$amount = filterRequest("amount");
|
||||
$wallet_type = filterRequest("wallet_type");
|
||||
$wallet_number = filterRequest("wallet_number");
|
||||
|
||||
// التحقق من أن البيانات الأساسية موجودة
|
||||
if (empty($driver_id) || empty($driver_name) || empty($amount) || empty($wallet_type) || empty($wallet_number)) {
|
||||
printFailure('Missing required fields.');
|
||||
exit();
|
||||
}
|
||||
|
||||
// --- 3. إدراج الطلب في قاعدة البيانات ---
|
||||
try {
|
||||
$sql = "INSERT INTO driver_withdrawal_requests (driver_id, driver_name, amount, wallet_type, wallet_number) VALUES (?, ?, ?, ?, ?)";
|
||||
$stmt = $con->prepare($sql);
|
||||
|
||||
// تنفيذ الاستعلام مع تمرير البيانات
|
||||
$success = $stmt->execute([
|
||||
$driver_id,
|
||||
$driver_name,
|
||||
$amount,
|
||||
$wallet_type,
|
||||
$wallet_number
|
||||
]);
|
||||
|
||||
if ($success) {
|
||||
// --- 4. الحصول على رقم الطلب وإرسال إشعار واتساب ---
|
||||
$transaction_id = $con->lastInsertId(); // الحصول على رقم التعريف الخاص بالطلب الجديد
|
||||
sendWhatsAppNotification($transaction_id, $driver_name, $amount, $wallet_type, $wallet_number);
|
||||
|
||||
// إرسال استجابة نجاح إلى التطبيق
|
||||
printSuccess("Withdrawal request saved and notification sent.");
|
||||
|
||||
} else {
|
||||
printFailure('Failed to save withdrawal request.');
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// التعامل مع أخطاء قاعدة البيانات
|
||||
error_log("Database Error in request_withdrawal.php: " . $e->getMessage());
|
||||
printFailure('A database error occurred.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* دالة لإرسال إشعار إلى خدمة العملاء عبر RaseelPlus API
|
||||
*/
|
||||
function sendWhatsAppNotification($transaction_id, $driver_name, $amount, $wallet_type, $wallet_number) {
|
||||
|
||||
// استخدام متغيرات البيئة (Environment Variables) هو الطريقة الأكثر أماناً لإدارة المعلومات الحساسة
|
||||
// بدلاً من كتابتها مباشرة في الكود.
|
||||
$customer_service_number = getenv('CUSTOMER_SERVICE_WHATSAPP');
|
||||
// $customer_service_number = "9639XXXXXXXX"; // كرقم احتياطي مؤقت
|
||||
|
||||
// نص الرسالة مع إضافة رقم الطلب
|
||||
$messageBody = "طلب سحب جديد (رقم الطلب: #$transaction_id):\n\n" .
|
||||
"اسم السائق: " . $driver_name . "\n" .
|
||||
"المبلغ: " . $amount . " ل.س\n" .
|
||||
"نوع المحفظة: " . $wallet_type . "\n" .
|
||||
"رقم المحفظة: " . $wallet_number;
|
||||
|
||||
// بيانات الطلب (Payload) للـ API
|
||||
$payload = [
|
||||
"number" => $customer_service_number,
|
||||
"type" => "text",
|
||||
"message" => $messageBody,
|
||||
"instance_id" => getenv('instance_idWhatsApp');
|
||||
"access_token" => getenv('access_tokenWhatsApp');
|
||||
];
|
||||
|
||||
// استدعاء الـ API
|
||||
// ملاحظة: لا نتحقق من استجابة الـ API هنا لأن العملية الرئيسية (حفظ الطلب) قد نجحت بالفعل.
|
||||
// يمكن إضافة تسجيل للأخطاء إذا لزم الأمر.
|
||||
callAPI_Withdrawal("POST", "https://raseelplus.com/api/send", json_encode($payload));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* دالة لإجراء استدعاءات API باستخدام cURL
|
||||
*/
|
||||
function callAPI_Withdrawal($method, $url, $data) {
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json"
|
||||
],
|
||||
]);
|
||||
$response = curl_exec($curl);
|
||||
$err = curl_error($curl);
|
||||
curl_close($curl);
|
||||
|
||||
if ($err) {
|
||||
// تسجيل الخطأ في سجلات الخادم للمراجعة لاحقًا
|
||||
error_log("[callAPI_Withdrawal] cURL Error #: " . $err);
|
||||
return null;
|
||||
} else {
|
||||
return json_decode($response);
|
||||
}
|
||||
}
|
||||
?>
|
||||
169
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/confirm_payment.php
Executable file
169
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/confirm_payment.php
Executable file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
// /v1/main/ride/mtn/passenger/confirm_payment.php
|
||||
include "../../../connect.php";
|
||||
|
||||
$baseUrl = rtrim(getenv('MTN_API_BASE_URL'), '/');
|
||||
$terminalId = getenv('MTN_TERMINAL_ID');
|
||||
$privateKeyPem = getenv('MTN_PRIVATE_KEY');
|
||||
$privateKey = openssl_pkey_get_private(file_get_contents("private_key.pem"));
|
||||
$invoice = filterRequest('invoiceNumber');
|
||||
$phone = filterRequest('phone');
|
||||
$guid = filterRequest('guid');
|
||||
$operationNumber = filterRequest('operationNumber');
|
||||
$code = filterRequest('otp'); // الـ OTP
|
||||
|
||||
error_log("MTN Confirm: Start request for invoice={$invoice}, phone={$phone}, guid={$guid}, opNum={$operationNumber}");
|
||||
|
||||
if (!$invoice || !$phone || !$guid || !$operationNumber || !$code) {
|
||||
error_log("MTN Confirm: Missing parameters");
|
||||
printFailure("Missing parameters.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// تشفير الكود
|
||||
$hashBin = hash('sha256', $code, true);
|
||||
$codeB64 = base64_encode($hashBin);
|
||||
|
||||
$body = [
|
||||
'Invoice' => intval($invoice),
|
||||
'Phone' => $phone,
|
||||
'Guid' => $guid,
|
||||
'OperationNumber' => intval($operationNumber),
|
||||
'Code' => $codeB64
|
||||
];
|
||||
$bodyJson = trim(stripslashes(json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS)), '"');
|
||||
|
||||
error_log("MTN Confirm: Prepared body JSON: " . $bodyJson);
|
||||
|
||||
// توليد التوقيع
|
||||
$signResult = openssl_sign($bodyJson, $sig, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
if (!$signResult) {
|
||||
error_log("MTN Confirm: Failed to generate signature");
|
||||
printFailure("Signature error.");
|
||||
exit;
|
||||
}
|
||||
$xSignature = base64_encode($sig);
|
||||
error_log("MTN Confirm: Generated signature");
|
||||
|
||||
// إرسال الطلب
|
||||
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/confirm");
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $bodyJson,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json",
|
||||
"Request-Name: pos_web/payment_phone/confirm",
|
||||
"Subject: {$terminalId}",
|
||||
"X-Signature: {$xSignature}"
|
||||
]
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
error_log("MTN Confirm: HTTP $httpCode - Response: $response");
|
||||
if ($curlError) {
|
||||
error_log("MTN Confirm: cURL error - $curlError");
|
||||
}
|
||||
|
||||
// تحديث قاعدة البيانات في حال نجاح
|
||||
if ($httpCode === 200) {
|
||||
try {
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `paymentsLogSyria` SET status = 1, updated_at = NOW()
|
||||
WHERE order_ref = :inv"
|
||||
);
|
||||
$stmt->execute([':inv' => $invoice]);
|
||||
error_log("MTN Confirm: Payment updated successfully in DB for invoice={$invoice}");
|
||||
|
||||
$stmt = $con->prepare("SELECT * FROM paymentsLogSyria WHERE order_ref = :order_ref LIMIT 1");
|
||||
$stmt->execute([':order_ref' => $invoice]);
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($payment) {
|
||||
$userId = $payment['user_id'];
|
||||
$amount = $payment['amount'];
|
||||
$paymentMethod = $payment['payment_method'] ?? 'mtn';
|
||||
|
||||
$finalAmount = calculateBonus($amount);
|
||||
$token = generatePaymentToken($userId, $finalAmount);
|
||||
$walletResult = addToPassengerWallet($userId, $finalAmount, $token);
|
||||
|
||||
$seferToken = generatePaymentToken($userId, $amount);
|
||||
$seferWalletResult = addToSeferWallet($userId, $amount, $paymentMethod, $seferToken);
|
||||
|
||||
printSuccess('MTN Confirm');
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
} catch (PDOException $e) {
|
||||
error_log("MTN Confirm: DB update error - " . $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
error_log("MTN Confirm: Payment failed with HTTP code $httpCode");
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
http_response_code($httpCode);
|
||||
echo $response;
|
||||
|
||||
function calculateBonus($amount) {
|
||||
if ($amount == 200000) return 205000;
|
||||
if ($amount == 400000) return 425000;
|
||||
if ($amount == 1000000) return 1040000;
|
||||
return $amount;
|
||||
}
|
||||
|
||||
function generatePaymentToken($passengerId, $amount) {
|
||||
$url = BASE_URL . "/passengerWallet/addPaymentTokenPassenger.php";
|
||||
$postData = ['passengerId' => $passengerId, 'amount' => $amount];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200) return null;
|
||||
$data = json_decode($response, true);
|
||||
return $data['message'] ?? null;
|
||||
}
|
||||
function addToPassengerWallet($passengerId, $amount, $token) {
|
||||
$url = BASE_URL . "/passengerWallet/add.php";
|
||||
$postData = ['passenger_id' => $passengerId, 'balance' => $amount, 'token' => $token];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200) return null;
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
function addToSeferWallet($passengerId, $amount, $paymentMethod, $token) {
|
||||
$url = BASE_URL . "/seferWallet/add.php";
|
||||
$postData = [
|
||||
'amount' => $amount,
|
||||
'paymentMethod' => $paymentMethod,
|
||||
'passengerId' => $passengerId,
|
||||
'token' => $token,
|
||||
'driverId' => 'passenger'
|
||||
];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200) return null;
|
||||
return json_decode($response, true);
|
||||
}
|
||||
?>
|
||||
103
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/finalize_wallet_payment.php
Executable file
103
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/finalize_wallet_payment.php
Executable file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
// wallet/finalize_wallet_payment.php
|
||||
include_once "../../../jwtconnect.php";
|
||||
|
||||
define("LOG_FILE", "../logs/payment_verification.log");
|
||||
|
||||
function logError($step, $message, $data = null) {
|
||||
$logDir = dirname(LOG_FILE);
|
||||
if (!is_dir($logDir)) { mkdir($logDir, 0755, true); }
|
||||
$logEntry = "[" . date('Y-m-d H:i:s') . "] STEP {$step}: {$message}";
|
||||
if ($data !== null) { $logEntry .= " | Data: " . json_encode($data, JSON_UNESCAPED_UNICODE); }
|
||||
file_put_contents(LOG_FILE, $logEntry . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
|
||||
function generateToken($con, $driverId, $amount): ?string {
|
||||
global $secretKey;
|
||||
$data = $driverId . $amount . time() . ($secretKey ?? 'default_secret');
|
||||
$hash = hash('sha256', $data);
|
||||
$randomBytes = bin2hex(random_bytes(16));
|
||||
$token = substr($hash . $randomBytes, 0, 64);
|
||||
|
||||
$stmt = $con->prepare("INSERT INTO payment_tokens (token, driverID, dateCreated, amount) VALUES (:token, :driverID, NOW(), :amount)");
|
||||
$stmt->execute([':token' => $token, ':driverID' => $driverId, ':amount' => $amount]);
|
||||
return $stmt->rowCount() > 0 ? $token : null;
|
||||
}
|
||||
|
||||
function generatePaymentID($con, $driverId, $amount, $method): ?string {
|
||||
$stmt = $con->prepare("INSERT INTO paymentsDriverPoints (`amount`, `payment_method`, `driverID`) VALUES (:amount, :method, :driverID)");
|
||||
$stmt->execute([':driverID' => $driverId, ':amount' => $amount, ':method' => $method]);
|
||||
return $stmt->rowCount() > 0 ? $con->lastInsertId() : null;
|
||||
}
|
||||
|
||||
function finalizeWalletPayment($con) {
|
||||
$orderRef = $_GET['orderRef'] ?? null;
|
||||
if (empty($orderRef)) {
|
||||
logError("FINALIZE", "Missing orderRef");
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. تحقق من الدفع
|
||||
$stmt = $con->prepare("SELECT * FROM `paymentsLogSyriaDriver` WHERE order_ref = :order_ref AND status = 1 LIMIT 1");
|
||||
$stmt->execute([':order_ref' => $orderRef]);
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$payment) {
|
||||
logError("FINALIZE", "Payment not found or not completed", ['orderRef' => $orderRef]);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$driverId = $payment['user_id'];
|
||||
$originalAmount = floatval($payment['amount']);
|
||||
$paymentMethod = $payment['payment_method'] ?? 'ecash';
|
||||
|
||||
// حساب المكافأة
|
||||
$bonusAmount = match ((int)$originalAmount) {
|
||||
10000 => 10000.0,
|
||||
20000 => 21000.0,
|
||||
40000 => 45000.0,
|
||||
100000 => 110000.0,
|
||||
default => $originalAmount,
|
||||
};
|
||||
|
||||
// إنشاء التوكنات
|
||||
$tokenDriver = generateToken($con, $driverId, $bonusAmount);
|
||||
if (!$tokenDriver) throw new Exception('Failed to generate driver token');
|
||||
|
||||
$tokenSefer = generateToken($con, $driverId, $originalAmount);
|
||||
if (!$tokenSefer) throw new Exception('Failed to generate sefer token');
|
||||
|
||||
$paymentID = generatePaymentID($con, $driverId, $bonusAmount, $paymentMethod);
|
||||
if (!$paymentID) throw new Exception('Failed to generate payment ID');
|
||||
|
||||
// driverWallet
|
||||
$insertDriver = $con->prepare("INSERT INTO driverWallet (driverID, paymentID, amount, paymentMethod) VALUES (:driverID, :paymentID, :amount, :paymentMethod)");
|
||||
$insertDriver->execute([
|
||||
':driverID' => $driverId,
|
||||
':paymentID' => $paymentID,
|
||||
':amount' => $bonusAmount,
|
||||
':paymentMethod' => $paymentMethod
|
||||
]);
|
||||
if ($insertDriver->rowCount() === 0) throw new Exception('Insert to driverWallet failed');
|
||||
|
||||
$con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token")->execute([':token' => $tokenDriver]);
|
||||
|
||||
// seferWallet
|
||||
$insertSefer = $con->prepare("INSERT INTO seferWallet (driverId, passengerId, amount, paymentMethod, token, createdAt)
|
||||
VALUES (:driverId, :passengerId, :amount, :paymentMethod, :token, CURRENT_TIMESTAMP)");
|
||||
$insertSefer->execute([
|
||||
':driverId' => $driverId,
|
||||
':passengerId' => 'driver',
|
||||
':amount' => $originalAmount,
|
||||
':paymentMethod' => $paymentMethod,
|
||||
':token' => $tokenSefer
|
||||
]);
|
||||
$con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token")->execute([':token' => $tokenSefer]);
|
||||
|
||||
logError("FINALIZE", "Wallets updated successfully", ['orderRef' => $orderRef]);
|
||||
printSuccess("FINALIZE", "Wallets updated successfully");
|
||||
} catch (Throwable $e) {
|
||||
logError("FINALIZE", "Exception during finalization: " . $e->getMessage(), ['orderRef' => $orderRef]);
|
||||
}
|
||||
}
|
||||
47
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/generate_keys.php
Executable file
47
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/generate_keys.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// File: generate_keys.php
|
||||
// الوظيفة: إنشاء زوج المفاتيح (العام والخاص) لمرة واحدة فقط
|
||||
|
||||
// إعدادات لتوليد المفتاح
|
||||
$config = [
|
||||
"digest_alg" => "sha256",
|
||||
"private_key_bits" => 1024,
|
||||
"private_key_type" => OPENSSL_KEYTYPE_RSA,
|
||||
];
|
||||
|
||||
// إنشاء زوج المفاتيح
|
||||
$res = openssl_pkey_new($config);
|
||||
|
||||
if (!$res) {
|
||||
die('Failed to generate new private key. Error: ' . openssl_error_string());
|
||||
}
|
||||
|
||||
// استخراج المفتاح الخاص
|
||||
openssl_pkey_export($res, $private_key);
|
||||
|
||||
// استخراج المفتاح العام
|
||||
$public_key_details = openssl_pkey_get_details($res);
|
||||
$public_key = $public_key_details["key"];
|
||||
|
||||
// حفظ المفاتيح في ملفات
|
||||
file_put_contents('private_key.pem', $private_key);
|
||||
file_put_contents('public_key.pem', $public_key);
|
||||
|
||||
echo "<h1>Keys Generated Successfully!</h1>";
|
||||
echo "<h2>Private Key (saved to private_key.pem):</h2>";
|
||||
echo "<pre>" . htmlspecialchars($private_key) . "</pre>";
|
||||
echo "<h2>Public Key (saved to public_key.pem):</h2>";
|
||||
echo "<pre>" . htmlspecialchars($public_key) . "</pre>";
|
||||
|
||||
// --- تحضير المفتاح العام لعملية التفعيل ---
|
||||
// إزالة الهيدر والفوتر والأسطر الجديدة كما هو مطلوب
|
||||
$formatted_public_key = str_replace("-----BEGIN PUBLIC KEY-----", "", $public_key);
|
||||
$formatted_public_key = str_replace("-----END PUBLIC KEY-----", "", $formatted_public_key);
|
||||
$formatted_public_key = preg_replace("/\s+/", "", $formatted_public_key);
|
||||
|
||||
|
||||
echo "<h2>Formatted Public Key (for Terminal Activation):</h2>";
|
||||
echo "<p><strong>انسخ هذا المفتاح لاستخدامه في خطوة تفعيل الجهاز (activate_terminal.php)</strong></p>";
|
||||
echo "<textarea rows='5' cols='80' readonly>" . htmlspecialchars($formatted_public_key) . "</textarea>";
|
||||
|
||||
?>
|
||||
54
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/initiate_payment.php
Executable file
54
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/initiate_payment.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
// /v1/main/ride/mtn/passenger/initiate_payment.php
|
||||
include "../../../connect.php";
|
||||
|
||||
$baseUrl = rtrim(getenv('MTN_API_BASE_URL'), '/');
|
||||
$terminalId = getenv('MTN_TERMINAL_ID');
|
||||
$privateKeyPem = getenv('MTN_PRIVATE_KEY');
|
||||
|
||||
$invoice = filterRequest('invoice'); // رقم الفاتورة
|
||||
$phone = filterRequest('phone'); // رقم الزبون
|
||||
$guid = uniqid('mtn_');
|
||||
|
||||
if (!$invoice || !$phone) {
|
||||
printFailure("Missing invoice or phone.");
|
||||
exit;
|
||||
}
|
||||
|
||||
$body = json_encode([
|
||||
'Invoice' => intval($invoice),
|
||||
'Phone' => $phone,
|
||||
'Guid' => $guid
|
||||
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$hash = hash('sha256', $body, true);
|
||||
openssl_sign($hash, $sig, $privateKeyPem, OPENSSL_ALGO_SHA256);
|
||||
$xSignature = base64_encode($sig);
|
||||
|
||||
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $body,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json",
|
||||
"Request-Name: pos_web/payment_phone/initiate",
|
||||
"Subject: {$terminalId}",
|
||||
"X-Signature: {$xSignature}"
|
||||
]
|
||||
]);
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
// سجل المحاولة مع Guid
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `mtn_payments`
|
||||
SET guid = :guid, status = 3, updated_at = NOW()
|
||||
WHERE invoice = :inv"
|
||||
);
|
||||
$stmt->execute([':guid'=>$guid, ':inv'=>$invoice]);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
http_response_code($httpCode);
|
||||
echo $response;
|
||||
56
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/key.php
Executable file
56
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/key.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// بيانات التفعيل
|
||||
$terminalId = "9001000000060863";
|
||||
$activationCode = "26164711";
|
||||
$serialNumber = "INTALEQ-001"; // يمكنك تغييره
|
||||
|
||||
// المفتاح العام على سطر واحد — بدون BEGIN/END وبدون أسطر جديدة
|
||||
//$publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDNxFbepx2OrpyrNG4+/aAaH3Rjc8dGw6B6vMAfsZzzm4wzoSkrtsr6jfuaMTZRLwxS5h8k1ztLG1HrOmL/NDsiE/7yxaKLAIZyWB/rR9byvPeOCC8QnCd/08kmxNl/l7Akn6qlPwsVpKUUNsr0SkU9lShMAw4OBgQq399jsbkFSwIDAQAB";
|
||||
$publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOhVAdUyxFpVNSyjRndMWEPAN9vJEetMzLbjF9DTn2lPVuRj/Mkwq9wCNhy+tdeX2lIn4K3EkONBvYJubBhxnYOoQuMchPW5vG7VnmpLjZ7TkpM2n9fcMu8u1GkLatLblDI4LTfvn3851+nhpnYlUVkjw5GAhH4XnEpveIjqDhzQIDAQAB";
|
||||
// جسم الطلب
|
||||
$body = [
|
||||
"Key" => $publicKey,
|
||||
"Secret" => $activationCode,
|
||||
"Serial" => $serialNumber
|
||||
];
|
||||
//$bodyJson = json_encode($body, JSON_UNESCAPED_SLASHES);
|
||||
$bodyJson = trim(stripslashes(json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS)),'"');
|
||||
//$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
// 1. توليد هاش SHA256 للـ JSON
|
||||
//$bodyHash = hash('sha256', $bodyJson, true);
|
||||
|
||||
// 2. تحميل المفتاح الخاص للتوقيع
|
||||
$privateKey = openssl_pkey_get_private(file_get_contents("private_key.pem")); // تأكد من وجود هذا الملف بجانب السكربت
|
||||
|
||||
// 3. توقيع الهاش
|
||||
openssl_sign($bodyJson, $signature, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
|
||||
// 4. تحويل التوقيع إلى Base64
|
||||
$xSignature = base64_encode($signature);
|
||||
|
||||
// 5. إرسال الطلب
|
||||
$headers = [
|
||||
"Content-Type: application/json",
|
||||
"Accept-Language: en",
|
||||
"Request-Name: pos_web/pos/activate",
|
||||
"Subject: $terminalId",
|
||||
"X-Signature: $xSignature"
|
||||
];
|
||||
|
||||
$ch = curl_init("https://cashmobile.mtnsyr.com:9000");
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyJson);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
// ✅ النتيجة
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
"httpCode" => $httpCode,
|
||||
"response" => json_decode($response, true),
|
||||
"sentBody" => $body,
|
||||
]);
|
||||
247
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/mtn_confirm.php
Executable file
247
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/mtn_confirm.php
Executable file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
// /v1/main/ride/mtn/passenger/confirm_payment.php
|
||||
include "../../../connect.php";
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
function mlog(string $msg) { error_log($msg); } // timestamp يضاف تلقائياً من PHP
|
||||
|
||||
// قاعدة URL للتطبيق (لمعالجة BASE_URL غير المعروفة)
|
||||
if (!defined('BASE_URL')) {
|
||||
$APP_BASE_URL = rtrim(getenv('APP_BASE_URL') ?: '', '/');
|
||||
if ($APP_BASE_URL === '') {
|
||||
$scheme = isset($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : 'https';
|
||||
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost';
|
||||
define('BASE_URL', $scheme . '://' . $host);
|
||||
} else {
|
||||
define('BASE_URL', $APP_BASE_URL);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$baseUrl = rtrim(getenv('MTN_API_BASE_URL'), '/');
|
||||
$terminalId = getenv('MTN_TERMINAL_ID');
|
||||
$privateKeyPem = getenv('MTN_PRIVATE_KEY');
|
||||
$privateKey = openssl_pkey_get_private(file_get_contents("private_key.pem"));
|
||||
$invoice = filterRequest('invoiceNumber');
|
||||
$phone = filterRequest('phone');
|
||||
$guid = filterRequest('guid');
|
||||
$operationNumber = filterRequest('operationNumber');
|
||||
$code = filterRequest('otp'); // الـ OTP
|
||||
$lang = filterRequest("lang");
|
||||
|
||||
mlog("MTN Confirm: Start request for invoice={$invoice}, phone={$phone}, guid={$guid}, opNum={$operationNumber}");
|
||||
|
||||
if (!$invoice || !$phone || !$guid || !$operationNumber || !$code) {
|
||||
mlog("MTN Confirm: Missing parameters");
|
||||
printFailure("Missing parameters.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// تشفير الكود (SHA256 ثم Base64)
|
||||
$hashBin = hash('sha256', $code, true);
|
||||
$codeB64 = base64_encode($hashBin);
|
||||
|
||||
// جسم الطلب نحو MTN
|
||||
$body = [
|
||||
'Invoice' => (int)$invoice,
|
||||
'Phone' => $phone,
|
||||
'Guid' => $guid,
|
||||
'OperationNumber' => (int)$operationNumber,
|
||||
'Code' => $codeB64,
|
||||
'Accept-Language' => $lang
|
||||
];
|
||||
$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE);
|
||||
mlog("MTN Confirm: Prepared body JSON: " . $bodyJson);
|
||||
|
||||
// توقيع الجسم
|
||||
$sig = null;
|
||||
$signResult = openssl_sign($bodyJson, $sig, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
if (!$signResult || !$sig) {
|
||||
mlog("MTN Confirm: Failed to generate signature");
|
||||
printFailure("Signature error.");
|
||||
exit;
|
||||
}
|
||||
$xSignature = base64_encode($sig);
|
||||
mlog("MTN Confirm: Generated signature");
|
||||
|
||||
// إرسال الطلب إلى MTN
|
||||
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/confirm");
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => $bodyJson,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Content-Type: application/json",
|
||||
"Request-Name: pos_web/payment_phone/confirm",
|
||||
"Subject: {$terminalId}",
|
||||
"X-Signature: {$xSignature}"
|
||||
],
|
||||
CURLOPT_TIMEOUT => 25,
|
||||
]);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
mlog("MTN Confirm: HTTP {$httpCode} - Response: " . ($response ?? ''));
|
||||
if ($curlError) {
|
||||
mlog("MTN Confirm: cURL error - {$curlError}");
|
||||
}
|
||||
|
||||
// فك JSON لرد MTN (حتى لو خطأ) لعرض سبب واضح
|
||||
$mtn = json_decode($response ?: '{}', true);
|
||||
if (!is_array($mtn)) {
|
||||
$mtn = [];
|
||||
}
|
||||
|
||||
// 🧠 سياسة القرار:
|
||||
// - إذا HTTP≠200 → فشل شبكة/بوابة
|
||||
// - إذا HTTP=200 لكن Errno≠0 → خطأ من MTN (مثل Incorrect sms code)
|
||||
// - فقط إذا HTTP=200 && Errno=0 → نجاح، نحدّث DB ونضيف للمحافظ
|
||||
if ($httpCode !== 200) {
|
||||
// لا تحدّث DB
|
||||
printFailure([
|
||||
'message' => 'MTN confirm HTTP failure',
|
||||
'http' => $httpCode,
|
||||
'mtn' => $mtn
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// HTTP 200 — افحص Errno
|
||||
$errno = isset($mtn['Errno']) ? (int)$mtn['Errno'] : null;
|
||||
if ($errno !== 0) {
|
||||
// لا تحدّث DB في هذه الحالة
|
||||
$errText = isset($mtn['Error']) ? $mtn['Error'] : 'Unknown MTN error';
|
||||
// اطبع لوج مشابه للمثال المطلوب
|
||||
// مثال: {"Errno":662,"Error":"Incorrect sms code","Abuse":2,"Transaction":""}
|
||||
mlog("MTN Confirm: Business failure from MTN - Errno={$errno}, Error=" . json_encode($mtn, JSON_UNESCAPED_UNICODE));
|
||||
printFailure([
|
||||
'message' => $errText,
|
||||
'errno' => $errno,
|
||||
'mtn' => $mtn
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// ✅ نجاح كامل من MTN — تحديث DB ثم المحافظ
|
||||
try {
|
||||
global $con;
|
||||
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `paymentsLogSyria` SET status = 1, updated_at = NOW()
|
||||
WHERE order_ref = :inv"
|
||||
);
|
||||
$stmt->execute([':inv' => $invoice]);
|
||||
mlog("MTN Confirm: Payment updated successfully in DB for invoice={$invoice}");
|
||||
|
||||
$stmt = $con->prepare("SELECT * FROM paymentsLogSyria WHERE order_ref = :order_ref LIMIT 1");
|
||||
$stmt->execute([':order_ref' => $invoice]);
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$payment) {
|
||||
mlog("MTN Confirm: Payment row not found after update");
|
||||
printFailure("Payment row not found");
|
||||
exit;
|
||||
}
|
||||
|
||||
$userId = $payment['user_id'];
|
||||
$amount = $payment['amount'];
|
||||
$paymentMethod = $payment['payment_method'] ?? 'mtn';
|
||||
|
||||
$finalAmount = calculateBonus($amount);
|
||||
|
||||
$token = generatePaymentToken($userId, $finalAmount);
|
||||
$walletResult = addToPassengerWallet($userId, $finalAmount, $token);
|
||||
|
||||
$seferToken = generatePaymentToken($userId, $amount);
|
||||
$seferWalletResult = addToSeferWallet($userId, $amount, $paymentMethod, $seferToken);
|
||||
|
||||
// رجّع رد موحّد + ضمّن رد MTN
|
||||
printSuccess([
|
||||
'message' => 'MTN Confirm',
|
||||
'data' => [
|
||||
'invoice' => $invoice,
|
||||
'finalAmount' => $finalAmount,
|
||||
'wallet' => $walletResult,
|
||||
'seferWallet' => $seferWalletResult,
|
||||
'mtn' => $mtn
|
||||
]
|
||||
]);
|
||||
exit;
|
||||
|
||||
} catch (PDOException $e) {
|
||||
mlog("MTN Confirm: DB update error - " . $e->getMessage());
|
||||
printFailure("DB error");
|
||||
exit;
|
||||
}
|
||||
|
||||
} catch (Throwable $e) {
|
||||
mlog("MTN Confirm: Exception - " . $e->getMessage());
|
||||
printFailure("Server error");
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* نفس دوال المساعدة، لكن باستعمال BASE_URL المؤمّنة أعلاه
|
||||
*/
|
||||
function calculateBonus($amount) {
|
||||
if ($amount == 20000) return 20500;
|
||||
if ($amount == 40000) return 42500;
|
||||
if ($amount == 100000) return 104000;
|
||||
return $amount;
|
||||
}
|
||||
|
||||
function generatePaymentToken($passengerId, $amount) {
|
||||
$url = rtrim(BASE_URL, '/') . "/passengerWallet/addPaymentTokenPassenger.php";
|
||||
$postData = ['passengerId' => $passengerId, 'amount' => $amount];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200 || !$response) return null;
|
||||
$data = json_decode($response, true);
|
||||
return $data['message'] ?? null;
|
||||
}
|
||||
|
||||
function addToPassengerWallet($passengerId, $amount, $token) {
|
||||
$url = rtrim(BASE_URL, '/') . "/passengerWallet/add.php";
|
||||
$postData = ['passenger_id' => $passengerId, 'balance' => $amount, 'token' => $token];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200 || !$response) return null;
|
||||
return json_decode($response, true);
|
||||
}
|
||||
|
||||
function addToSeferWallet($passengerId, $amount, $paymentMethod, $token) {
|
||||
$url = rtrim(BASE_URL, '/') . "/seferWallet/add.php";
|
||||
$postData = [
|
||||
'amount' => $amount,
|
||||
'paymentMethod' => $paymentMethod,
|
||||
'passengerId' => $passengerId,
|
||||
'token' => $token,
|
||||
'driverId' => 'passenger'
|
||||
];
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
if ($httpCode != 200 || !$response) return null;
|
||||
return json_decode($response, true);
|
||||
}
|
||||
130
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/mtn_start.php
Executable file
130
walletintaleq.intaleq.xyz/v2/main/ride/mtn/passenger/mtn_start.php
Executable file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
include "../../../connect.php";
|
||||
date_default_timezone_set("Asia/Damascus");
|
||||
|
||||
// ========== إعدادات MTN ==========
|
||||
$terminalId = "9001000000060863";
|
||||
$currencyCode = 760;
|
||||
$sessionNumber = 0;
|
||||
$ttl = 15;
|
||||
|
||||
// ====== استقبال البيانات من فلاتر ======
|
||||
$amount = filterRequest("amount");
|
||||
$passengerId = filterRequest("passengerId");
|
||||
$phone = filterRequest("phone");
|
||||
$lang = filterRequest("lang");
|
||||
|
||||
// ✅ Log مبدئي
|
||||
error_log("🚦 START | passengerId: $passengerId | phone: $phone | amount: $amount");
|
||||
|
||||
// تحقق من المدخلات
|
||||
if (empty($amount) || empty($passengerId) || empty($phone) || $amount <= 0) {
|
||||
error_log("❌ Invalid input: amount=$amount, passengerId=$passengerId, phone=$phone");
|
||||
printFailure("بيانات الدفع غير كاملة أو غير صالحة.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ====== توليد invoiceNumber و GUID ======
|
||||
$invoiceNumber = mt_rand(10000000000, 99999999999);
|
||||
//$invoiceNumber = "MTN_" . $passengerId . "_" . time();
|
||||
$guid = uniqid("mtn_");
|
||||
error_log("🧾 Generated Invoice: $invoiceNumber");
|
||||
error_log("🧭 Generated GUID: $guid");
|
||||
|
||||
// ====== 1. إنشاء الفاتورة ======
|
||||
$createInvoiceBody = [
|
||||
"Amount" => intval($amount * 100),
|
||||
"Invoice" => $invoiceNumber,
|
||||
"Session" => $sessionNumber,
|
||||
"TTL" => $ttl
|
||||
];
|
||||
error_log("📦 Create Invoice Body: " . json_encode($createInvoiceBody, JSON_UNESCAPED_UNICODE));
|
||||
$invoiceResponse = sendMtnApiRequest("pos_web/invoice/create", $terminalId, $createInvoiceBody);
|
||||
error_log("📥 Create Invoice Response: " . json_encode($invoiceResponse, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (!$invoiceResponse || isset($invoiceResponse['Errno']) && $invoiceResponse['Errno'] != 0) {
|
||||
error_log("❌ Failed to create invoice. Error: " . json_encode($invoiceResponse));
|
||||
printFailure("فشل إنشاء الفاتورة عبر MTN.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ====== 2. بدء الدفع ======
|
||||
$initiateBody = [
|
||||
"Invoice" => $invoiceNumber,
|
||||
"Phone" => $phone,
|
||||
"Guid" => $guid
|
||||
];
|
||||
error_log("📤 body initiateBody: $initiateBody");
|
||||
error_log("📦 Initiate Payment Body: " . json_encode($initiateBody, JSON_UNESCAPED_UNICODE));
|
||||
$initiateResponse = sendMtnApiRequest("pos_web/payment_phone/initiate", $terminalId, $initiateBody);
|
||||
error_log("📥 Initiate Response: " . json_encode($initiateResponse, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
if (!$initiateResponse || !isset($initiateResponse['OperationNumber'])) {
|
||||
error_log("❌ Failed to initiate payment.");
|
||||
printFailure($initiateResponse);
|
||||
exit;
|
||||
}
|
||||
|
||||
$operationNumber = $initiateResponse['OperationNumber'];
|
||||
|
||||
// ====== 3. تسجيل العملية ======
|
||||
try {
|
||||
$stmt = $con->prepare("INSERT INTO `paymentsLogSyria`
|
||||
(`user_id`, `amount`, `status`, `order_ref`, `payment_method`, `created_at`)
|
||||
VALUES (?, ?, 2, ?, 'mtn', NOW())");
|
||||
$stmt->execute([$passengerId, $amount, $invoiceNumber]);
|
||||
error_log("✅ DB Log Inserted.");
|
||||
} catch (PDOException $e) {
|
||||
error_log("❌ DB ERROR: " . $e->getMessage());
|
||||
printFailure("فشل في تسجيل العملية.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// ====== 4. نجاح
|
||||
error_log("✅ Payment initiation successful.");
|
||||
printSuccess([
|
||||
"invoiceNumber" => $invoiceNumber,
|
||||
"operationNumber" => $operationNumber,
|
||||
"guid" => $guid
|
||||
]);
|
||||
|
||||
|
||||
// ====== دالة إرسال الطلب =====================
|
||||
function sendMtnApiRequest($requestName, $terminalId, $body)
|
||||
{
|
||||
$apiUrl = "https://cashmobile.mtnsyr.com:9000";
|
||||
$privateKey = openssl_pkey_get_private(file_get_contents("private_key.pem"));
|
||||
|
||||
// ✅ تحويل الـ body إلى JSON بدون فراغات أو أسطر
|
||||
$bodyJson = trim(stripslashes(json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS)), '"');
|
||||
//$bodyJson = json_encode($body, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
// ✅ توليد التوقيع
|
||||
// $bodyHash = hash('sha256', $bodyJson, true);
|
||||
error_log("📤 body before JSON: $bodyJson");
|
||||
openssl_sign($bodyJson, $signature, $privateKey, OPENSSL_ALGO_SHA256);
|
||||
$xSignature = base64_encode($signature);
|
||||
error_log("📤 body xSignature: $xSignature");
|
||||
// ✅ رؤوس الطلب
|
||||
$headers = [
|
||||
"Content-Type: application/json",
|
||||
"Accept-Language: $lang",
|
||||
"Request-Name: $requestName",
|
||||
"Subject: $terminalId",
|
||||
"X-Signature: $xSignature"
|
||||
];
|
||||
|
||||
$ch = curl_init($apiUrl);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyJson);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// ✅ لوق داخلي
|
||||
error_log("🔐 Signature for $requestName: $xSignature");
|
||||
error_log("📤 Sent JSON: $bodyJson");
|
||||
|
||||
curl_close($ch);
|
||||
return json_decode($response, true);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXwIBAAKBgQDOhVAdUyxFpVNSyjRndMWEPAN9vJEetMzLbjF9DTn2lPVuRj/M
|
||||
kwq9wCNhy+tdeX2lIn4K3EkONBvYJubBhxnYOoQuMchPW5vG7VnmpLjZ7TkpM2n9
|
||||
fcMu8u1GkLatLblDI4LTfvn3851+nhpnYlUVkjw5GAhH4XnEpveIjqDhzQIDAQAB
|
||||
AoGBALRcAvqJT8nHN7y+8QNFHNZ+XwIpc4egmJY1Ny0iJvPtZWaYHVG5PRE4Qu4+
|
||||
29+3oX5dYDx146tu4L5mQvLS3ULBsvxaUZt2lT/vxkQzI9pNfXw584WvIrbtxQod
|
||||
ILvBcnamwQa9hEOIFZVyZ/hzkzUcMO6cAXqvsfqqPgJhm7PBAkEA+xgE9CUOLDFl
|
||||
vLePQKGcHIUOsPLr16qNEgGhTW7Km3OMMqoB2f7t67xOHGqK6tnANRM4Sk6IModI
|
||||
wbZuVh4jMQJBANKOVmIdDLNffZVHp90SDRG7/YdK2R5ob361CIkcUzjh927Wfs5W
|
||||
A/WroB7eJ7pWiq2BMaj/xq65nYaCOldvaV0CQQDm12c+eY61DFjnDa6ykaEvCxi9
|
||||
jydJp+93vW3o/VFhZvJeZbO8EcX0MrNxJnY+gSBW6yuWDOrj4UH/bVO08pIRAkEA
|
||||
lH3TiBAqo9nlTEEjrnILi4VD0IVFx/8pGnf71A6I1qXuBVn6RfQ9iKWIIBzWccCU
|
||||
vrZNWn1AFntLD9CJ6p3k9QJBAMbSQ9CoXWlOLJRduV15ER1ZyE/inVd4jIvtjAgz
|
||||
b7QaM62Ecxl3D8EI/LTSZV9Oa8D/62cJeMsflVa7gpavL70=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -0,0 +1,6 @@
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDqBQZEJXWCQwPsPzBM70M3TjyU
|
||||
5vwCZWoEtUomR9Qu+dEQaa0Hniz6JY8+goCxfMYuZQw6+kimctA2KqzT2pCsJufN
|
||||
b92pSAMZgb0RSTl2y62oJkJd2WY7dj36AvPEyw6DxCFItvFOu7HGl3LlHQBriiw3
|
||||
jwtuS6DO7gbmAJPU8wIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// --- check_status.php ---
|
||||
include "../../connect.php";
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$invoiceNumber = filterRequest("invoice_number");
|
||||
|
||||
if (empty($invoiceNumber)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice number is required."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $con->prepare("SELECT status FROM mtn_invoices WHERE invoice_number = :invoice_number LIMIT 1");
|
||||
$stmt->execute([':invoice_number' => $invoiceNumber]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($invoice) {
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"invoice_status" => $invoice['status']
|
||||
]);
|
||||
} else {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice not found."]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Error in check_status.php: " . $e->getMessage());
|
||||
echo json_encode(["status" => "error", "message" => "Server error."]);
|
||||
}
|
||||
?>
|
||||
100
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/create_mtn_invoice.php
Executable file
100
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/create_mtn_invoice.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// --- create_mtn_invoice.php ---
|
||||
// إذا كانت هناك فاتورة Pending لليوم نفسه لنفس المستخدم: نُحدّثها
|
||||
// غير ذلك: نُنشئ فاتورة جديدة
|
||||
|
||||
include "../../connect.php";
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$userId = filterRequest("user_id"); // driverID أو passengerID
|
||||
$userType = filterRequest("user_type"); // 'driver' أو 'passenger'
|
||||
$amount = filterRequest("amount");
|
||||
$mtnPhone = filterRequest("mtn_phone");
|
||||
|
||||
if (empty($userId) || empty($userType) || !is_numeric($amount) || $amount <= 0 || empty($mtnPhone)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invalid input provided."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// نضمن اتساق العمليات
|
||||
$con->beginTransaction();
|
||||
|
||||
// ابحث عن فاتورة PENDING لنفس المستخدم، منشأة "اليوم"
|
||||
// ملاحظة: يتطلب وجود عمود created_at (TIMESTAMP) في الجدول
|
||||
$sel = $con->prepare("
|
||||
SELECT id, invoice_number
|
||||
FROM mtn_invoices
|
||||
WHERE user_id = :uid
|
||||
AND user_type = :utype
|
||||
AND status = 'pending'
|
||||
AND DATE(created_at) = CURRENT_DATE
|
||||
ORDER BY id DESC
|
||||
LIMIT 1
|
||||
");
|
||||
$sel->execute([
|
||||
':uid' => $userId,
|
||||
':utype' => $userType,
|
||||
]);
|
||||
$existing = $sel->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($existing) {
|
||||
// يوجد سجل لليوم: نحدّث على نفس الفاتورة
|
||||
$upd = $con->prepare("
|
||||
UPDATE mtn_invoices
|
||||
SET amount = :amount,
|
||||
mtn_phone = :mtn_phone,
|
||||
updated_at = NOW()
|
||||
WHERE id = :id
|
||||
");
|
||||
$upd->execute([
|
||||
':amount' => $amount,
|
||||
':mtn_phone'=> $mtnPhone,
|
||||
':id' => $existing['id'],
|
||||
]);
|
||||
|
||||
$con->commit();
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Invoice updated (pending, same day).",
|
||||
"invoice_number" => $existing['invoice_number'],
|
||||
"mode" => "updated"
|
||||
]);
|
||||
} else {
|
||||
// لا يوجد سجل لليوم: ننشئ فاتورة جديدة
|
||||
$invoiceNumber = "MTN-" . time() . mt_rand(100, 999);
|
||||
|
||||
$ins = $con->prepare("
|
||||
INSERT INTO mtn_invoices
|
||||
(invoice_number, user_id, user_type, amount, mtn_phone, status, created_at, updated_at)
|
||||
VALUES
|
||||
(:invoice_number, :user_id, :user_type, :amount, :mtn_phone, 'pending', NOW(), NOW())
|
||||
");
|
||||
$ins->execute([
|
||||
':invoice_number' => $invoiceNumber,
|
||||
':user_id' => $userId,
|
||||
':user_type' => $userType,
|
||||
':amount' => $amount,
|
||||
':mtn_phone' => $mtnPhone
|
||||
]);
|
||||
|
||||
$con->commit();
|
||||
|
||||
// تحديد الرقم أو الاسم المستعار للدفع
|
||||
$mtnPaymentNumber = $_ENV['MTN_PAYMENT_NUMBER'] ?? getenv('MTN_PAYMENT_NUMBER') ?: '0930000000';
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Invoice created successfully.",
|
||||
"invoice_number" => $invoiceNumber,
|
||||
"mtn_payment_number" => $mtnPaymentNumber,
|
||||
"mode" => "inserted"
|
||||
]);
|
||||
}
|
||||
|
||||
} catch (Throwable $e) {
|
||||
if ($con && $con->inTransaction()) { $con->rollBack(); }
|
||||
error_log("Error in create_mtn_invoice.php: " . $e->getMessage());
|
||||
echo json_encode(["status" => "failure", "message" => "An internal server error occurred."]);
|
||||
}
|
||||
106
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/finalize_payment.php
Executable file
106
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/finalize_payment.php
Executable file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
// --- finalize_payment.php ---
|
||||
// يحتوي على الدوال المنطقية لإضافة الرصيد للمستخدمين بعد تأكيد الدفع
|
||||
|
||||
// ملاحظة: هذا الملف لا يتم استدعاؤه مباشرة، بل يتم تضمينه في mtn_webhook_handler.php
|
||||
|
||||
/**
|
||||
* دالة مركزية لإتمام الدفع بعد التحقق منه
|
||||
* @param PDO $con اتصال قاعدة البيانات
|
||||
* @param int $invoiceId معرّف الفاتورة في جدول mtn_invoices
|
||||
* @return array نتيجة العملية
|
||||
*/
|
||||
function finalizeMtnPayment(PDO $con, int $invoiceId): array
|
||||
{
|
||||
try {
|
||||
// جلب تفاصيل الفاتورة
|
||||
$stmt = $con->prepare("SELECT * FROM `mtn_invoices` WHERE id = :id AND status = 'completed' LIMIT 1");
|
||||
$stmt->execute([':id' => $invoiceId]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$invoice) {
|
||||
return ['success' => false, 'message' => 'Invoice not found or not completed.'];
|
||||
}
|
||||
|
||||
$userType = $invoice['user_type'];
|
||||
$userId = $invoice['user_id'];
|
||||
$amount = (float) $invoice['amount'];
|
||||
$paymentMethod = 'mtn_cash'; // تحديد طريقة الدفع
|
||||
|
||||
// تحديد ما إذا كان المستخدم سائقاً أم راكباً
|
||||
if ($userType === 'driver') {
|
||||
return finalizeForDriver($con, $userId, $amount, $paymentMethod);
|
||||
} elseif ($userType === 'passenger') {
|
||||
return finalizeForPassenger($con, $userId, $amount, $paymentMethod);
|
||||
} else {
|
||||
return ['success' => false, 'message' => 'Unknown user type.'];
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Finalization Exception: " . $e->getMessage());
|
||||
return ['success' => false, 'message' => $e->getMessage()];
|
||||
}
|
||||
}
|
||||
|
||||
// --- دوال مساعدة خاصة بالسائق ---
|
||||
function finalizeForDriver(PDO $con, int $driverId, float $amount, string $paymentMethod): array
|
||||
{
|
||||
// حساب قيمة البونص كما في الكود الأصلي
|
||||
$bonusAmount = match ((int)$amount) {
|
||||
10000 => 10000.0,
|
||||
20000 => 21000.0,
|
||||
40000 => 45000.0,
|
||||
100000 => 110000.0,
|
||||
default => $amount,
|
||||
};
|
||||
|
||||
// إنشاء سجل دفع جديد والحصول على ID
|
||||
$paymentID = generatePaymentID($con, $driverId, $bonusAmount, $paymentMethod);
|
||||
if (!$paymentID) throw new Exception('Failed to generate payment ID for driver.');
|
||||
|
||||
// إضافة الرصيد لمحفظة السائق
|
||||
$stmtDriver = $con->prepare("INSERT INTO driverWallet (driverID, paymentID, amount, paymentMethod) VALUES (:driverID, :paymentID, :amount, :paymentMethod)");
|
||||
$stmtDriver->execute([':driverID' => $driverId, ':paymentID' => $paymentID, ':amount' => $bonusAmount, ':paymentMethod' => $paymentMethod]);
|
||||
if ($stmtDriver->rowCount() === 0) throw new Exception('Insert to driverWallet failed.');
|
||||
|
||||
// إضافة سجل محاسبي لمحفظة سفر
|
||||
$stmtSefer = $con->prepare("INSERT INTO seferWallet (driverId, passengerId, amount, paymentMethod) VALUES (:driverId, 'driver', :amount, :paymentMethod)");
|
||||
$stmtSefer->execute([':driverId' => $driverId, ':amount' => $amount, ':paymentMethod' => $paymentMethod]);
|
||||
if ($stmtSefer->rowCount() === 0) throw new Exception('Insert to seferWallet failed.');
|
||||
|
||||
return ['success' => true, 'message' => 'Driver wallets updated.'];
|
||||
}
|
||||
|
||||
function generatePaymentID(PDO $con, string $driverId, float $amount, string $method): ?string {
|
||||
$stmt = $con->prepare("INSERT INTO paymentsDriverPoints (`amount`, `payment_method`, `driverID`) VALUES (:amount, :method, :driverID)");
|
||||
$stmt->execute([':driverID' => $driverId, ':amount' => $amount, ':method' => $method]);
|
||||
return $stmt->rowCount() > 0 ? $con->lastInsertId() : null;
|
||||
}
|
||||
|
||||
|
||||
// --- دوال مساعدة خاصة بالراكب ---
|
||||
function finalizeForPassenger(PDO $con, string $passengerId, float $amount, string $paymentMethod): array
|
||||
{
|
||||
// حساب البونص للراكب
|
||||
$finalAmount = calculatePassengerBonus($amount);
|
||||
|
||||
// إضافة الرصيد لمحفظة الراكب
|
||||
$stmtPassenger = $con->prepare("INSERT INTO passengerWallet (passenger_id, balance) VALUES (:id, :amount) ON DUPLICATE KEY UPDATE balance = balance + :amount");
|
||||
$stmtPassenger->execute([':id' => $passengerId, ':amount' => $finalAmount]);
|
||||
if ($stmtPassenger->rowCount() === 0) throw new Exception('Update passengerWallet failed.');
|
||||
|
||||
// إضافة سجل محاسبي لمحفظة سفر
|
||||
$stmtSefer = $con->prepare("INSERT INTO seferWallet (passengerId, driverId, amount, paymentMethod) VALUES (:passengerId, 'passenger', :amount, :paymentMethod)");
|
||||
$stmtSefer->execute([':passengerId' => $passengerId, ':amount' => $amount, ':paymentMethod' => $paymentMethod]);
|
||||
if ($stmtSefer->rowCount() === 0) throw new Exception('Insert to seferWallet for passenger failed.');
|
||||
|
||||
return ['success' => true, 'message' => 'Passenger wallets updated.'];
|
||||
}
|
||||
|
||||
function calculatePassengerBonus(float $amount): float {
|
||||
if ($amount == 20000) return 20500;
|
||||
if ($amount == 40000) return 42500;
|
||||
if ($amount == 100000) return 104000;
|
||||
return $amount;
|
||||
}
|
||||
?>
|
||||
86
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/mtn_webhook_handler.php
Executable file
86
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/mtn_webhook_handler.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
// --- mtn_webhook_handler.php ---
|
||||
// هذا هو الـ Webhook الرئيسي الذي يستقبل إشعار تأكيد الدفع من MTN
|
||||
|
||||
include "../../jwtconnect.php";
|
||||
include "./finalize_payment.php"; // تضمين ملف إتمام العملية
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// **مهم جداً: التحقق من مصدر الطلب**
|
||||
// يجب التحقق من أن هذا الطلب قادم فعلاً من MTN وليس من أي طرف آخر
|
||||
// المثال التالي يستخدم مفتاح سري مشترك (Shared Secret)
|
||||
$expectedToken = trim(file_get_contents('/home/intaleq-wallet/.mtnKey')); // يجب استبداله بتوكن حقيقي
|
||||
$receivedToken = $_SERVER['HTTP_X_AUTH_TOKEN'] ?? '';
|
||||
|
||||
if ($receivedToken !== $expectedToken) {
|
||||
http_response_code(401); // Unauthorized
|
||||
echo json_encode(["status" => "error", "message" => "Authentication failed."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// قراءة البيانات القادمة من MTN (عادة تكون بصيغة JSON في الـ body)
|
||||
$json_data = file_get_contents('php://input');
|
||||
$data = json_decode($json_data, true);
|
||||
|
||||
$invoiceNumber = $data['invoice_number'] ?? null;
|
||||
$transactionId = $data['transaction_id'] ?? null;
|
||||
$paymentStatus = $data['status'] ?? null;
|
||||
|
||||
if (empty($invoiceNumber) || empty($transactionId) || $paymentStatus !== 'success') {
|
||||
http_response_code(400); // Bad Request
|
||||
echo json_encode(["status" => "error", "message" => "Missing or invalid payment data."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$con->beginTransaction();
|
||||
|
||||
// 1. البحث عن الفاتورة وتحديث حالتها
|
||||
$stmt = $con->prepare(
|
||||
"UPDATE `mtn_invoices`
|
||||
SET `status` = 'completed', `mtn_transaction_id` = :transaction_id
|
||||
WHERE `invoice_number` = :invoice_number AND `status` = 'pending'"
|
||||
);
|
||||
$stmt->execute([
|
||||
':transaction_id' => $transactionId,
|
||||
':invoice_number' => $invoiceNumber
|
||||
]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// تم تحديث الفاتورة بنجاح، الآن نقوم بإتمام العملية
|
||||
$invoiceId = $con->lastInsertId(); // ملاحظة: هذا قد لا يعمل دائماً مع UPDATE، الأفضل جلب الـ ID
|
||||
|
||||
// جلب ID الفاتورة بعد التأكد من وجودها
|
||||
$idStmt = $con->prepare("SELECT id FROM `mtn_invoices` WHERE `invoice_number` = :invoice_number");
|
||||
$idStmt->execute([':invoice_number' => $invoiceNumber]);
|
||||
$invoiceRecord = $idStmt->fetch();
|
||||
$invoiceId = $invoiceRecord['id'];
|
||||
|
||||
$finalizationResult = finalizeMtnPayment($con, $invoiceId);
|
||||
|
||||
if ($finalizationResult['success']) {
|
||||
$con->commit();
|
||||
echo json_encode(["status" => "success", "message" => "Transaction finalized."]);
|
||||
} else {
|
||||
$con->rollBack();
|
||||
// يجب هنا التعامل مع الحالة التي فشل فيها الإيداع رغم نجاح الدفع
|
||||
error_log("CRITICAL: Payment received for invoice {$invoiceNumber} but finalization failed.");
|
||||
http_response_code(500);
|
||||
echo json_encode(["status" => "error", "message" => "Finalization failed."]);
|
||||
}
|
||||
} else {
|
||||
// لم يتم العثور على فاتورة معلقة بهذا الرقم (ربما تمت معالجتها سابقاً)
|
||||
$con->rollBack();
|
||||
http_response_code(404);
|
||||
echo json_encode(["status" => "error", "message" => "Invoice not found or already processed."]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$con->rollBack();
|
||||
error_log("Error in mtn_webhook_handler.php: " . $e->getMessage());
|
||||
http_response_code(500);
|
||||
echo json_encode(["status" => "error", "message" => "An internal server error occurred."]);
|
||||
}
|
||||
|
||||
?>
|
||||
64
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/query_mtn_invoice.php
Executable file
64
walletintaleq.intaleq.xyz/v2/main/ride/mtn_new/query_mtn_invoice.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// --- query_mtn_invoice.php ---
|
||||
// هذا السكربت هو نقطة الـ Webhook التي سيستدعيها نظام MTN
|
||||
// للاستعلام عن وجود فاتورة دفع معلقة للمستخدم قبل أن يدفع
|
||||
|
||||
include "../../jwtconnect.php"; // تأكد من أن هذا المسار صحيح
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// يمكن إضافة طبقة حماية هنا للتحقق من أن الطلب قادم من سيرفرات MTN
|
||||
// مثلاً عبر التحقق من IP أو من وجود Secret Key في الـ Headers
|
||||
// --- آلية الحماية ---
|
||||
$shared_secret_key = trim(file_get_contents('/home/intaleq-wallet/.mtnKey'));
|
||||
$receivedToken = $_SERVER['HTTP_X_AUTH_TOKEN'] ?? '';
|
||||
|
||||
if ($receivedToken !== $shared_secret_key) {
|
||||
http_response_code(401); // Unauthorized
|
||||
echo json_encode(['status' => 'error', 'message' => 'Authentication failed. Invalid or missing token.']);
|
||||
exit;
|
||||
}
|
||||
try {
|
||||
// يفترض أن MTN سترسل رقم هاتف المستخدم للاستعلام عنه
|
||||
//$mtnPhone = filterRequest("mtn_phone");
|
||||
$mtnPhone = $_GET['phone_number'] ?? null;
|
||||
|
||||
if (empty($mtnPhone)) {
|
||||
echo json_encode(["status" => "error", "message" => "Phone number is required."]);
|
||||
http_response_code(400);
|
||||
exit;
|
||||
}
|
||||
|
||||
// البحث عن فاتورة معلقة لهذا الرقم
|
||||
$stmt = $con->prepare(
|
||||
"SELECT invoice_number, amount, user_id, user_type
|
||||
FROM `mtn_invoices`
|
||||
WHERE `mtn_phone` = :mtn_phone AND `status` = 'pending'
|
||||
ORDER BY `created_at` DESC LIMIT 1"
|
||||
);
|
||||
$stmt->execute([':mtn_phone' => $mtnPhone]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($invoice) {
|
||||
// تم العثور على فاتورة، يتم إرجاع تفاصيلها لنظام MTN
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"statusInvoice" => "pending",
|
||||
"invoice_number" => $invoice['invoice_number'],
|
||||
"amount" => (float) $invoice['amount'],
|
||||
"description" => "شحن نقاط في تطبيق انطلق", // وصف يظهر للمستخدم في تطبيق MTN
|
||||
"biller_name" => "Intaleq App"
|
||||
|
||||
]);
|
||||
} else {
|
||||
// لا توجد فاتورة معلقة
|
||||
echo json_encode(["status" => "error", "message" => "No pending invoice found for this number."]);
|
||||
http_response_code(404);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Error in query_mtn_invoice.php: " . $e->getMessage());
|
||||
echo json_encode(["status" => "error", "message" => "Internal server error."]);
|
||||
http_response_code(500);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
// --- verify_payment_ai.php ---
|
||||
include "../../connect.php";
|
||||
include "./finalize_payment.php";
|
||||
include "../GeminiAi.php";
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$json_data = file_get_contents('php://input');
|
||||
$data = json_decode($json_data, true) ?: $_POST;
|
||||
|
||||
$invoiceNumber = $data['invoice_number'] ?? '';
|
||||
$proofText = $data['proof_text'] ?? '';
|
||||
$proofImageBase64 = $data['proof_image_base64'] ?? '';
|
||||
|
||||
if (empty($invoiceNumber)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice number is required."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($proofText) && empty($proofImageBase64)) {
|
||||
echo json_encode(["status" => "failure", "message" => "Proof text or image is required."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $con->prepare("SELECT id, amount FROM mtn_invoices WHERE invoice_number = :inv AND status = 'pending'");
|
||||
$stmt->execute([':inv' => $invoiceNumber]);
|
||||
$invoice = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$invoice) {
|
||||
echo json_encode(["status" => "failure", "message" => "Invoice not found or already processed."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$amount = $invoice['amount'];
|
||||
|
||||
$geminiKey = $_ENV['GEMINI_API_KEY'] ?? getenv('GEMINI_API_KEY') ?: '';
|
||||
|
||||
if (empty($geminiKey)) {
|
||||
echo json_encode(["status" => "error", "message" => "Gemini API key not configured."]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$gemini = new GeminiAi($geminiKey);
|
||||
$aiResult = $gemini->verifyPayment($invoiceNumber, $amount, "MTN", $proofText, $proofImageBase64);
|
||||
|
||||
if (isset($aiResult['verified']) && $aiResult['verified'] === true) {
|
||||
$con->beginTransaction();
|
||||
$upd = $con->prepare("UPDATE mtn_invoices SET status = 'completed', updated_at = NOW() WHERE id = :id AND status = 'pending'");
|
||||
$upd->execute([':id' => $invoice['id']]);
|
||||
|
||||
if ($upd->rowCount() > 0) {
|
||||
$finalizationResult = finalizeMtnPayment($con, $invoice['id']);
|
||||
if ($finalizationResult['success']) {
|
||||
$con->commit();
|
||||
echo json_encode(["status" => "success", "message" => "Payment verified and finalized."]);
|
||||
} else {
|
||||
$con->rollBack();
|
||||
echo json_encode(["status" => "error", "message" => "Verification succeeded but finalization failed."]);
|
||||
}
|
||||
} else {
|
||||
$con->rollBack();
|
||||
echo json_encode(["status" => "error", "message" => "Invoice already processed."]);
|
||||
}
|
||||
} else {
|
||||
$reason = $aiResult['reason'] ?? "AI rejected the proof.";
|
||||
echo json_encode(["status" => "failure", "message" => "Verification failed: $reason"]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Error in MTN verify: " . $e->getMessage());
|
||||
echo json_encode(["status" => "error", "message" => "Server error."]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
include "../../jwtconnect.php";
|
||||
//addPassengersWallet.php
|
||||
$passenger_id = filterRequest("passenger_id");
|
||||
$balance = filterRequest("balance");
|
||||
$token = filterRequest("token");
|
||||
|
||||
|
||||
// Retrieve token details from the database
|
||||
$stmt = $con->prepare("SELECT * FROM payment_tokens_passenger WHERE token = :token AND isUsed = FALSE");
|
||||
$stmt->execute([':token' => $token]);
|
||||
|
||||
$tokenData = $stmt->fetch();
|
||||
|
||||
if ($tokenData) {
|
||||
// Insert into passengerWallet securely using prepared statements
|
||||
$sql = "INSERT INTO `passengerWallet` (`passenger_id`, `balance`) VALUES (:passenger_id, :balance)";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute([':passenger_id' => $passenger_id, ':balance' => $balance]);
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Mark the token as used
|
||||
$updateTokenStmt = $con->prepare("UPDATE payment_tokens_passenger SET isUsed = TRUE WHERE token = :token");
|
||||
$updateTokenStmt->execute([':token' => $token]);
|
||||
|
||||
printSuccess("Wallet record created successfully");
|
||||
} else {
|
||||
printFailure("Failed to create wallet record");
|
||||
}
|
||||
} else {
|
||||
printFailure("Invalid or already used token");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
include "../../jwtconnect.php";
|
||||
//addPaymentTokenPassenger.php
|
||||
$passengerId = filterRequest("passengerId");
|
||||
$amount = filterRequest("amount");
|
||||
|
||||
// Check if required fields are present
|
||||
if ($passengerId === null || $amount === null) {
|
||||
printFailure("Missing required fields: passengerId and amount must be provided");
|
||||
exit;
|
||||
}
|
||||
|
||||
// Generate the token using current time
|
||||
$token = generateSecureToken($passengerId, $amount, date('Y-m-d H:i:s', time()));
|
||||
|
||||
// Store the token in the database, using NOW() for dateCreated
|
||||
$stmt = $con->prepare("INSERT INTO payment_tokens_passenger (token, passengerId, dateCreated, amount) VALUES (?, ?, NOW(), ?)");
|
||||
|
||||
try {
|
||||
$stmt->execute([$token, $passengerId, $amount]);
|
||||
if ($stmt->rowCount() > 0) {
|
||||
printSuccess($token);
|
||||
} else {
|
||||
printFailure("Failed to save record");
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
printFailure("Database error: " . $e->getMessage());
|
||||
}
|
||||
|
||||
// Rest of your code including the generateSecureToken function...
|
||||
|
||||
// Rest of your code including the generateSecureToken function...
|
||||
|
||||
function generateSecureToken($passengerId, $amount, $dateCreated) {
|
||||
global $secretKey;
|
||||
// Concatenate the parameters
|
||||
$data = $passengerId . $amount . $dateCreated;
|
||||
|
||||
// Add the secret key from the environment variable
|
||||
$data .= $secretKey;
|
||||
|
||||
// Generate a hash
|
||||
$hash = hash('sha256', $data);
|
||||
|
||||
// Add some randomness
|
||||
$randomBytes = bin2hex(random_bytes(16));
|
||||
|
||||
// Combine hash and random bytes
|
||||
$token = $hash . $randomBytes;
|
||||
|
||||
// Truncate to a reasonable length (e.g., 64 characters)
|
||||
return substr($token, 0, 64);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
$id = filterRequest("id");
|
||||
|
||||
$sql = "DELETE FROM `passengerWallet` WHERE `id` = '$id'";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Print a success message
|
||||
printSuccess($message = "Wallet record deleted successfully");
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure($message = "Failed to delete wallet record");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$passenger_id = filterRequest("passenger_id");
|
||||
|
||||
$sql = "SELECT
|
||||
passengerWallet.`id`,
|
||||
passengerWallet.`passenger_id`,
|
||||
SUM(passengerWallet.balance) AS total,
|
||||
passengers.first_name,
|
||||
passengers.last_name,
|
||||
passengers.phone,
|
||||
passengers.email
|
||||
FROM
|
||||
`passengerWallet`
|
||||
LEFT JOIN passengers ON passengers.id = passengerWallet.passenger_id
|
||||
GROUP BY
|
||||
passenger_id";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$passenger_id = filterRequest("passenger_id");
|
||||
|
||||
$sql = "SELECT
|
||||
`id`,
|
||||
`passenger_id`,
|
||||
`balance`,
|
||||
`created_at`,
|
||||
`updated_at`,
|
||||
(
|
||||
SELECT
|
||||
SUM(balance)
|
||||
FROM
|
||||
passengerWallet
|
||||
WHERE
|
||||
passenger_id = '$passenger_id'
|
||||
) AS total
|
||||
FROM
|
||||
`passengerWallet`
|
||||
WHERE
|
||||
passenger_id = '$passenger_id'
|
||||
GROUP BY
|
||||
`passenger_id`,
|
||||
`id`;";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$passenger_id = filterRequest("passenger_id");
|
||||
|
||||
$sql = "SELECT
|
||||
passengerWallet.`id`,
|
||||
passengerWallet.balance,
|
||||
passengerWallet.`created_at`
|
||||
FROM
|
||||
`passengerWallet`
|
||||
WHERE
|
||||
passenger_id = '$passenger_id'AND created_at >= DATE_SUB(NOW(), INTERVAL 1 MONTH)
|
||||
ORDER BY
|
||||
`passengerWallet`.`id`
|
||||
DESC";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$passenger_id = filterRequest("passenger_id");
|
||||
|
||||
$sql = "SELECT
|
||||
COALESCE(dummy.passenger_id, '$passenger_id') AS passenger_id,
|
||||
COALESCE(SUM(pw.balance), 0) AS total, -- Adjust column to represent payments
|
||||
COALESCE(p.first_name, '') AS first_name,
|
||||
COALESCE(p.last_name, '') AS last_name,
|
||||
COALESCE(p.phone, '') AS phone
|
||||
FROM
|
||||
(SELECT '$passenger_id' AS passenger_id) AS dummy
|
||||
LEFT JOIN `passengerWallet` pw ON pw.passenger_id = dummy.passenger_id
|
||||
LEFT JOIN passengers p ON p.id = dummy.passenger_id
|
||||
GROUP BY
|
||||
dummy.passenger_id, p.first_name, p.last_name, p.phone
|
||||
LIMIT 0, 25;
|
||||
";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Fetch the record
|
||||
$row = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
printSuccess( $row);
|
||||
|
||||
}
|
||||
else{
|
||||
// Print a failure message
|
||||
printFailure($message = "No wallet record found");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
// process_wait_compensation.php
|
||||
// يوضع هذا الملف على سيرفر المدفوعات (Payment Server)
|
||||
|
||||
include "../../connect.php"; // تأكد من مسار الاتصال
|
||||
|
||||
// 1. استقبال البيانات
|
||||
$rideId = filterRequest("ride_id");
|
||||
$driverId = filterRequest("driver_id");
|
||||
$passengerId = filterRequest("passenger_id");
|
||||
$amount = filterRequest("amount"); // المبلغ الموجب (للسائق)
|
||||
$amountPassenger= filterRequest("amount_passenger"); // المبلغ السالب (للراكب)
|
||||
$tokenDriver = filterRequest("token_driver");
|
||||
$tokenPassenger = filterRequest("token_passenger");
|
||||
$paymentMethod = "wait-cancel"; // أو يمكن استقباله من التطبيق
|
||||
|
||||
if (!$rideId || !$driverId || !$passengerId || !$amount || !$tokenDriver || !$tokenPassenger) {
|
||||
printFailure("Missing parameters");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// 🔥 بدء المعاملة المالية (Transaction)
|
||||
$con->beginTransaction();
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// الخطوة 1: التحقق من التوكنات (Security Check)
|
||||
// ---------------------------------------------------------
|
||||
|
||||
// أ) فحص توكن السائق
|
||||
$stmtCheckD = $con->prepare("SELECT id FROM payment_tokens WHERE token = ? AND isUsed = FALSE");
|
||||
$stmtCheckD->execute([$tokenDriver]);
|
||||
$tokenDriverData = $stmtCheckD->fetch();
|
||||
|
||||
if (!$tokenDriverData) {
|
||||
throw new Exception("Invalid or used Driver Token");
|
||||
}
|
||||
|
||||
// ب) فحص توكن الراكب
|
||||
$stmtCheckP = $con->prepare("SELECT id FROM payment_tokens_passenger WHERE token = ? AND isUsed = FALSE");
|
||||
$stmtCheckP->execute([$tokenPassenger]);
|
||||
$tokenPassengerData = $stmtCheckP->fetch();
|
||||
|
||||
if (!$tokenPassengerData) {
|
||||
throw new Exception("Invalid or used Passenger Token");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// الخطوة 2: إضافة سجل النقاط (paymentsDriverPoints)
|
||||
// ---------------------------------------------------------
|
||||
// هذا الجدول يبدو أنه "سجل العمليات" الرئيسي
|
||||
$sqlPoints = "INSERT INTO `paymentsDriverPoints` (`amount`, `payment_method`, `driverID`) VALUES (?, ?, ?)";
|
||||
$stmtPoints = $con->prepare($sqlPoints);
|
||||
$stmtPoints->execute([$amount, $paymentMethod, $driverId]);
|
||||
|
||||
// نحصل على ID العملية لنربطه بالمحفظة
|
||||
$paymentRecordID = $con->lastInsertId();
|
||||
|
||||
if ($stmtPoints->rowCount() == 0) {
|
||||
throw new Exception("Failed to insert into paymentsDriverPoints");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// الخطوة 3: إضافة الرصيد لمحفظة السائق (driverWallet)
|
||||
// ---------------------------------------------------------
|
||||
// نستخدم $paymentRecordID كمرجع للعملية
|
||||
$sqlWalletD = "INSERT INTO `driverWallet` (`driverID`, `paymentID`, `amount`, `paymentMethod`) VALUES (?, ?, ?, ?)";
|
||||
$stmtWalletD = $con->prepare($sqlWalletD);
|
||||
$stmtWalletD->execute([$driverId, $paymentRecordID, $amount, $paymentMethod]);
|
||||
|
||||
// حرق توكن السائق
|
||||
$con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE id = ?")->execute([$tokenDriverData['id']]);
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// الخطوة 4: خصم الرصيد من محفظة الراكب (passengerWallet)
|
||||
// ---------------------------------------------------------
|
||||
$sqlWalletP = "INSERT INTO `passengerWallet` (`passenger_id`, `balance`) VALUES (?, ?)";
|
||||
$stmtWalletP = $con->prepare($sqlWalletP);
|
||||
$stmtWalletP->execute([$passengerId, $amountPassenger]);
|
||||
|
||||
// حرق توكن الراكب
|
||||
$con->prepare("UPDATE payment_tokens_passenger SET isUsed = TRUE WHERE id = ?")->execute([$tokenPassengerData['id']]);
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// إتمام العملية (Commit)
|
||||
// ---------------------------------------------------------
|
||||
$con->commit();
|
||||
printSuccess("Compensation processed successfully");
|
||||
|
||||
} catch (Exception $e) {
|
||||
// في حال حدوث أي خطأ، يتم التراجع عن كل العمليات السابقة
|
||||
if ($con->inTransaction()) {
|
||||
$con->rollBack();
|
||||
}
|
||||
printFailure("Transaction Failed: " . $e->getMessage());
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
$id = filterRequest("id");
|
||||
$balance = filterRequest("balance");
|
||||
|
||||
$sql = "UPDATE `passengerWallet` SET `balance` = '$balance' WHERE `id` = '$id'";
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
// Print a success message
|
||||
printSuccess($message = "Wallet record updated successfully");
|
||||
} else {
|
||||
// Print a failure message
|
||||
printFailure($message = "Failed to update wallet record");
|
||||
}
|
||||
?>
|
||||
100
walletintaleq.intaleq.xyz/v2/main/ride/payMob/payWithPayMob.php
Normal file
100
walletintaleq.intaleq.xyz/v2/main/ride/payMob/payWithPayMob.php
Normal file
@@ -0,0 +1,100 @@
|
||||
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
// 1. احصل على AUTH TOKEN
|
||||
$api_key = getenv("payMobApiKey1"); // ضع API Key الخاص بك هنا
|
||||
$email= filterRequest("amount");
|
||||
$first_name= filterRequest("first_name");
|
||||
$last_name= filterRequest("last_name");
|
||||
$phone_number= filterRequest("phone_number");
|
||||
$amount= filterRequest("amount");
|
||||
|
||||
$auth_url = "https://accept.paymob.com/api/auth/tokens";
|
||||
$auth_data = json_encode(["api_key" => $api_key]);
|
||||
|
||||
$response = callAPI("POST", $auth_url, $auth_data);
|
||||
// printResponse("AUTH TOKEN RESPONSE", $response);
|
||||
|
||||
$auth_token = $response->token ?? null;
|
||||
if (!$auth_token) {
|
||||
die("❌ فشل الحصول على AUTH TOKEN!");
|
||||
}
|
||||
// $amount=$amount*100;
|
||||
// 2. أنشئ الطلب ORDER
|
||||
$order_url = "https://accept.paymob.com/api/ecommerce/orders";
|
||||
$order_data = [
|
||||
"auth_token" => $auth_token,
|
||||
"delivery_needed" => false,
|
||||
"amount_cents" => $amount,
|
||||
"currency" => "EGP",
|
||||
"merchant_order_id" => uniqid(),
|
||||
"items" => []
|
||||
];
|
||||
|
||||
$response = callAPI("POST", $order_url, json_encode($order_data));
|
||||
// printResponse("ORDER RESPONSE", $response);
|
||||
|
||||
$order_id = $response->id ?? null;
|
||||
if (!$order_id) {
|
||||
die("❌ فشل إنشاء الطلب!");
|
||||
}
|
||||
$integration_id=getenv("paymobIntegratedIdCard");
|
||||
// 3. احصل على Payment Key
|
||||
$payment_key_url = "https://accept.paymob.com/api/acceptance/payment_keys";
|
||||
$payment_key_data = [
|
||||
"auth_token" => $auth_token,
|
||||
"amount_cents" => $amount,
|
||||
"expiration" => 3600,
|
||||
"order_id" => $order_id,
|
||||
"billing_data" => [
|
||||
"first_name" =>$first_name,
|
||||
"last_name" => $last_name,
|
||||
"email" => $email,
|
||||
"phone_number" => $phone_number,
|
||||
"country" => "EG",
|
||||
"city" => "Cairo",
|
||||
"state" => "shobra",
|
||||
"street" => "Test St.",
|
||||
"building" => "1",
|
||||
"apartment" => "10",
|
||||
"floor" => "2",
|
||||
"postal_code" => "12345",
|
||||
"shipping_method"=> 'card'
|
||||
],
|
||||
"currency" => "EGP",
|
||||
"integration_id" => $integration_id, // ضع الـ Integration ID الصحيح
|
||||
];
|
||||
|
||||
$response = callAPI("POST", $payment_key_url, json_encode($payment_key_data));
|
||||
// printResponse("PAYMENT TOKEN RESPONSE", $response);
|
||||
|
||||
$payment_token = $response->token ?? null;
|
||||
if (!$payment_token) {
|
||||
die("❌ فشل الحصول على PAYMENT TOKEN!");
|
||||
}
|
||||
|
||||
// 4. إنشاء IFRAME URL
|
||||
$iframe_id = "837992"; // ضع الـ Iframe ID الصحيح
|
||||
$iframe_url = "https://accept.paymob.com/api/acceptance/iframes/$iframe_id?payment_token=$payment_token";
|
||||
if($payment_token){
|
||||
|
||||
printSuccess($iframe_url);
|
||||
}
|
||||
// دالة لطلب API عبر CURL
|
||||
function callAPI($method, $url, $data)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => ["Content-Type: application/json"]
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
return json_decode($response);
|
||||
}
|
||||
358
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymet_verfy.php
Normal file
358
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymet_verfy.php
Normal file
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
include "../../connect.php";
|
||||
|
||||
define("BASE_URL", "https://wl.tripz-egypt.com/v1/main/ride");
|
||||
define("LOG_FILE", "../logs/payment_verification.log"); // Define log file path
|
||||
|
||||
// Function to write to error log
|
||||
function logError($step, $message, $data = null) {
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$logEntry = "[{$timestamp}] STEP {$step}: {$message}";
|
||||
|
||||
if ($data !== null) {
|
||||
$logEntry .= " | Data: " . json_encode($data);
|
||||
}
|
||||
|
||||
// Ensure log directory exists
|
||||
$logDir = dirname(LOG_FILE);
|
||||
if (!is_dir($logDir)) {
|
||||
mkdir($logDir, 0755, true);
|
||||
}
|
||||
|
||||
// Append to log file
|
||||
file_put_contents(LOG_FILE, $logEntry . PHP_EOL, FILE_APPEND);
|
||||
|
||||
// Also log to PHP error log for server monitoring
|
||||
// error_log("PAYMENT_VERIFICATION: {$logEntry}");
|
||||
}
|
||||
|
||||
// Receive parameters from GET request
|
||||
$user_id = filterRequest("user_id");
|
||||
$passengerId = filterRequest("passengerId");
|
||||
$paymentMethod = filterRequest("paymentMethod");
|
||||
|
||||
// Log initial request
|
||||
// logError("0", "Request received", [
|
||||
// "user_id" => $user_id,
|
||||
// "passengerId" => $passengerId
|
||||
// ]);
|
||||
|
||||
// Validate user_id and passengerId
|
||||
if (!$user_id || !$passengerId) {
|
||||
// logError("1", "Invalid parameters", [
|
||||
// "user_id" => $user_id,
|
||||
// "passengerId" => $passengerId
|
||||
// ]);
|
||||
printFailure("Invalid user ID or passenger ID.");
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// Step 1: Get the latest successful payment
|
||||
// logError("1", "Querying latest payment", ["user_id" => $user_id]);
|
||||
|
||||
$stmt = $con->prepare("SELECT * FROM paymentsLog WHERE user_id = :user_id AND created_at >= DATE_SUB(NOW(), INTERVAL 2 MINUTE)
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 1");
|
||||
$stmt->bindParam(':user_id', $user_id, PDO::PARAM_STR);
|
||||
$stmt->execute();
|
||||
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$payment) {
|
||||
logError("1", "No payment found", ["user_id" => $user_id]);
|
||||
printFailure("No payment data found.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// logError("1", "Payment found", [
|
||||
// "payment_id" => $payment['id'] ?? 'unknown',
|
||||
// "status" => $payment['status'],
|
||||
// "amount" => $payment['amount']/100 ?? 'unknown'
|
||||
// ]);
|
||||
|
||||
// Step 2: Check payment status
|
||||
if ($payment['status'] != 1) {
|
||||
// logError("2", "Payment not successful", ["status" => $payment['status']]);
|
||||
printFailure("Payment is not successful yet.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// logError("2", "Payment status verified", ["status" => $payment['status']]);
|
||||
|
||||
$amount = $payment['amount']/100; // Paid amount
|
||||
|
||||
// Step 3: Calculate bonus based on the paid amount
|
||||
// logError("3", "Calculating bonus", ["amount" => $amount]);
|
||||
$finalAmount = calculateBonus($amount);
|
||||
|
||||
if ($finalAmount <= 0) {
|
||||
// logError("3", "Bonus calculation failed", [
|
||||
// "original_amount" => $amount,
|
||||
// "calculated_amount" => $finalAmount
|
||||
// ]);
|
||||
printFailure("Invalid amount for bonus calculation.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// logError("3", "Bonus calculated", [
|
||||
// "original_amount" => $amount,
|
||||
// "final_amount" => $finalAmount
|
||||
// ]);
|
||||
|
||||
// // Step 4: Generate payment token
|
||||
// logError("4", "Generating payment token", [
|
||||
// "passengerId" => $passengerId,
|
||||
// "amount" => $finalAmount
|
||||
// ]);
|
||||
|
||||
$token = generatePaymentToken($passengerId, $finalAmount);
|
||||
|
||||
if (!$token) {
|
||||
// logError("4", "Token generation failed");
|
||||
printFailure("Payment verified, but failed to generate token.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// logError("4", "Token generated successfully", ["token_length" => strlen($token)]);
|
||||
|
||||
// // Step 5: Add balance to passenger's wallet
|
||||
// logError("5", "Adding balance to passenger wallet", [
|
||||
// "passengerId" => $passengerId,
|
||||
// "amount" => $finalAmount
|
||||
// ]);
|
||||
|
||||
$walletResult = addToPassengerWallet($passengerId, $finalAmount, $token);
|
||||
|
||||
if (!$walletResult || !isset($walletResult['status']) || $walletResult['status'] != "success") {
|
||||
// logError("5", "Failed to add balance to passenger wallet", $walletResult);
|
||||
printFailure("Payment verified, but failed to add balance to passenger wallet.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// logError("5", "Balance added to passenger wallet", $walletResult);
|
||||
|
||||
// Step 6: Add balance to Sefer wallet
|
||||
// logError("6", "Adding balance to Sefer wallet", [
|
||||
// "passengerId" => $passengerId,
|
||||
// "amount" => $finalAmount,
|
||||
// "paymentMethod" => $paymentMethod
|
||||
// ]);
|
||||
|
||||
$token = generatePaymentToken($passengerId, $finalAmount);
|
||||
|
||||
if (!$token) {
|
||||
// logError("4", "Token generation failed");
|
||||
printFailure("Payment verified, but failed to generate token.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// logError("4", "Token generated successfully", ["token_length" => strlen($token)]);
|
||||
|
||||
$seferWalletResult = addToSeferWallet($passengerId, $amount, $paymentMethod);
|
||||
|
||||
if (!$seferWalletResult || !isset($seferWalletResult['status']) || $seferWalletResult['status'] != "success") {
|
||||
// logError("6", "Failed to add balance to Sefer wallet", $seferWalletResult);
|
||||
printFailure("Payment verified, but failed to add balance to Sefer wallet.");
|
||||
exit;
|
||||
}
|
||||
|
||||
// logError("6", "Balance added to Sefer wallet", $seferWalletResult);
|
||||
|
||||
// // Final success
|
||||
// logError("7", "Process completed successfully", [
|
||||
// "payment_id" => $payment['id'] ?? 'unknown',
|
||||
// "amount" => $finalAmount,
|
||||
// "passengerId" => $passengerId
|
||||
// ]);
|
||||
|
||||
printSuccess( "Payment data saved successfully");
|
||||
|
||||
} catch (PDOException $e) {
|
||||
logError("ERROR", "Database error: " . $e->getMessage());
|
||||
printFailure("Database error occurred.");
|
||||
} catch (Exception $e) {
|
||||
logError("ERROR", "General error: " . $e->getMessage());
|
||||
printFailure("An error occurred during payment verification.");
|
||||
}
|
||||
|
||||
// 🎯 Function to generate payment token with error logging
|
||||
function generatePaymentToken($passengerId, $amount) {
|
||||
$url = BASE_URL . "/passengerWallet/addPaymentTokenPassenger.php";
|
||||
|
||||
$postData = [
|
||||
'passengerId' => $passengerId,
|
||||
'amount' => $amount
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($curlError) {
|
||||
logError("4.1", "cURL error in token generation", [
|
||||
"error" => $curlError,
|
||||
"url" => $url
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($httpCode != 200) {
|
||||
logError("4.2", "HTTP error in token generation", [
|
||||
"http_code" => $httpCode,
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (!$data || !isset($data['message'])) {
|
||||
logError("4.3", "Invalid response format in token generation", [
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data['message']; // ✅ Return token
|
||||
}
|
||||
|
||||
// 🎯 Function to add balance to passenger's wallet with error logging
|
||||
function addToPassengerWallet($passengerId, $amount, $token) {
|
||||
$url = BASE_URL . "/passengerWallet/add.php";
|
||||
|
||||
$postData = [
|
||||
'passenger_id' => $passengerId,
|
||||
'balance' => $amount,
|
||||
'token' => $token
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($curlError) {
|
||||
logError("5.1", "cURL error in passenger wallet update", [
|
||||
"error" => $curlError,
|
||||
"url" => $url
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($httpCode != 200) {
|
||||
logError("5.2", "HTTP error in passenger wallet update", [
|
||||
"http_code" => $httpCode,
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (!$data) {
|
||||
logError("5.3", "Invalid response format in passenger wallet update", [
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data; // ✅ Return result
|
||||
}
|
||||
|
||||
// 🎯 Function to add balance to Sefer wallet with error logging
|
||||
|
||||
|
||||
function addToSeferWallet($passengerId, $amount, $paymentMethod) {
|
||||
|
||||
|
||||
// Generate a new token specifically for the Sefer wallet
|
||||
$seferToken = generatePaymentToken($passengerId, $amount);
|
||||
|
||||
if (!$seferToken) {
|
||||
logError("6.0.1", "Failed to generate Sefer token");
|
||||
return null;
|
||||
}
|
||||
|
||||
logError("6.0.2", "Generated new Sefer token", [
|
||||
"token_length" => ($seferToken)
|
||||
]);
|
||||
|
||||
$url = BASE_URL . "/seferWallet/add.php";
|
||||
|
||||
$postData = [
|
||||
'amount' => $amount,
|
||||
'paymentMethod' => $paymentMethod,
|
||||
'passengerId' => $passengerId,
|
||||
'token' => $seferToken, // Use the new Sefer-specific token
|
||||
'driverId' => 'passenger'
|
||||
];
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if ($curlError) {
|
||||
logError("6.1", "cURL error in Sefer wallet update", [
|
||||
"error" => $curlError,
|
||||
"url" => $url
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($httpCode != 200) {
|
||||
logError("6.2", "HTTP error in Sefer wallet update", [
|
||||
"http_code" => $httpCode,
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = json_decode($response, true);
|
||||
|
||||
if (!$data) {
|
||||
logError("6.3", "Invalid response format in Sefer wallet update", [
|
||||
"response" => $response
|
||||
]);
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data; // ✅ Return result
|
||||
}
|
||||
|
||||
|
||||
// 🎯 Function to calculate bonus
|
||||
function calculateBonus($amount) {
|
||||
logError("3.1", "Bonus calculation input", ["amount" => $amount]);
|
||||
|
||||
$result = 0;
|
||||
if ($amount == 100) $result = 100;
|
||||
else if ($amount == 200) $result = 215;
|
||||
else if ($amount == 400) $result = 450;
|
||||
else if ($amount == 1000) $result = 1140;
|
||||
|
||||
logError("3.2", "Bonus calculation result", [
|
||||
"input" => $amount,
|
||||
"output" => $result
|
||||
]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
Binary file not shown.
100
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/payWithCard.php
Executable file
100
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/payWithCard.php
Executable file
@@ -0,0 +1,100 @@
|
||||
|
||||
<?php
|
||||
include "../../../connect.php";
|
||||
// 1. احصل على AUTH TOKEN
|
||||
$api_key = getenv("payMobApiKey1"); // ضع API Key الخاص بك هنا
|
||||
$email= filterRequest("amount");
|
||||
$first_name= filterRequest("first_name");
|
||||
$last_name= filterRequest("last_name");
|
||||
$phone_number= filterRequest("phone_number");
|
||||
$amount= filterRequest("amount");
|
||||
|
||||
$auth_url = "https://accept.paymob.com/api/auth/tokens";
|
||||
$auth_data = json_encode(["api_key" => $api_key]);
|
||||
|
||||
$response = callAPI("POST", $auth_url, $auth_data);
|
||||
// printResponse("AUTH TOKEN RESPONSE", $response);
|
||||
|
||||
$auth_token = $response->token ?? null;
|
||||
if (!$auth_token) {
|
||||
die("❌ فشل الحصول على AUTH TOKEN!");
|
||||
}
|
||||
$amount=$amount*100;
|
||||
// 2. أنشئ الطلب ORDER
|
||||
$order_url = "https://accept.paymob.com/api/ecommerce/orders";
|
||||
$order_data = [
|
||||
"auth_token" => $auth_token,
|
||||
"delivery_needed" => false,
|
||||
"amount_cents" => $amount,
|
||||
"currency" => "EGP",
|
||||
"merchant_order_id" => uniqid(),
|
||||
"items" => []
|
||||
];
|
||||
|
||||
$response = callAPI("POST", $order_url, json_encode($order_data));
|
||||
// printResponse("ORDER RESPONSE", $response);
|
||||
|
||||
$order_id = $response->id ?? null;
|
||||
if (!$order_id) {
|
||||
die("❌ فشل إنشاء الطلب!");
|
||||
}
|
||||
$integration_id=getenv("paymobIntegratedIdCardDriver");
|
||||
// 3. احصل على Payment Key
|
||||
$payment_key_url = "https://accept.paymob.com/api/acceptance/payment_keys";
|
||||
$payment_key_data = [
|
||||
"auth_token" => $auth_token,
|
||||
"amount_cents" => $amount,
|
||||
"expiration" => 3600,
|
||||
"order_id" => $order_id,
|
||||
"billing_data" => [
|
||||
"first_name" =>$first_name,
|
||||
"last_name" => $last_name,
|
||||
"email" => $email,
|
||||
"phone_number" => $phone_number,
|
||||
"country" => "EG",
|
||||
"city" => "Cairo",
|
||||
"state" => "shobra",
|
||||
"street" => "Test St.",
|
||||
"building" => "1",
|
||||
"apartment" => "10",
|
||||
"floor" => "2",
|
||||
"postal_code" => "12345",
|
||||
"shipping_method"=> 'card'
|
||||
],
|
||||
"currency" => "EGP",
|
||||
"integration_id" => $integration_id, // ضع الـ Integration ID الصحيح
|
||||
];
|
||||
|
||||
$response = callAPI("POST", $payment_key_url, json_encode($payment_key_data));
|
||||
// printResponse("PAYMENT TOKEN RESPONSE", $response);
|
||||
|
||||
$payment_token = $response->token ?? null;
|
||||
if (!$payment_token) {
|
||||
die("❌ فشل الحصول على PAYMENT TOKEN!");
|
||||
}
|
||||
|
||||
// 4. إنشاء IFRAME URL
|
||||
$iframe_id = "837992"; // ضع الـ Iframe ID الصحيح
|
||||
$iframe_url = "https://accept.paymob.com/api/acceptance/iframes/$iframe_id?payment_token=$payment_token";
|
||||
if($payment_token){
|
||||
|
||||
printSuccess($iframe_url);
|
||||
}
|
||||
// دالة لطلب API عبر CURL
|
||||
function callAPI($method, $url, $data)
|
||||
{
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => ["Content-Type: application/json"]
|
||||
]);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
return json_decode($response);
|
||||
}
|
||||
118
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/payWithWallet.php
Executable file
118
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/payWithWallet.php
Executable file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
include "../../../connect.php";
|
||||
|
||||
// 1️⃣ AUTH TOKEN
|
||||
$api_key = getenv("payMobApiKey1");
|
||||
$integration_id = getenv("paymobIntegratedIdDriverWallet"); // 🔁 تأكد أنه خاص بالسائق
|
||||
|
||||
$email = filterRequest("email");
|
||||
$first_name = filterRequest("first_name");
|
||||
$last_name = filterRequest("last_name");
|
||||
$phone_number = filterRequest("phone_number"); // هاتف السائق
|
||||
$wallet_phone = '+2'.$phone_number;
|
||||
$amount = filterRequest("amount");
|
||||
|
||||
$auth_url = "https://accept.paymob.com/api/auth/tokens";
|
||||
$auth_data = json_encode(["api_key" => $api_key]);
|
||||
|
||||
$response = callAPI("POST", $auth_url, $auth_data);
|
||||
$auth_token = $response->token ?? null;
|
||||
|
||||
if (!$auth_token) {
|
||||
error_log("❌ AUTH TOKEN retrieval failed!");
|
||||
die("❌ AUTH TOKEN retrieval failed!");
|
||||
}
|
||||
$amount=$amount*100;
|
||||
// 2️⃣ ORDER CREATE
|
||||
$order_url = "https://accept.paymob.com/api/ecommerce/orders";
|
||||
$order_data = [
|
||||
"auth_token" => $auth_token,
|
||||
"delivery_needed" => false,
|
||||
"amount_cents" => $amount,
|
||||
"currency" => "EGP",
|
||||
"merchant_order_id" => uniqid("DRV_"),
|
||||
"items" => []
|
||||
];
|
||||
|
||||
$response = callAPI("POST", $order_url, json_encode($order_data));
|
||||
$order_id = $response->id ?? null;
|
||||
|
||||
if (!$order_id) {
|
||||
error_log("❌ Failed to create order for driver wallet!");
|
||||
die("❌ Failed to create order for driver wallet!");
|
||||
}
|
||||
|
||||
// 3️⃣ PAYMENT KEY
|
||||
$payment_key_url = "https://accept.paymob.com/api/acceptance/payment_keys";
|
||||
$payment_key_data = [
|
||||
"auth_token" => $auth_token,
|
||||
"amount_cents" => $amount,
|
||||
"expiration" => 3600,
|
||||
"order_id" => $order_id,
|
||||
"billing_data" => [
|
||||
"first_name" => $first_name,
|
||||
"last_name" => $last_name,
|
||||
"email" => $email,
|
||||
"phone_number" => $phone_number,
|
||||
"country" => "EG",
|
||||
"city" => "Cairo",
|
||||
"state" => "Nasr City",
|
||||
"street" => "Driver Zone",
|
||||
"building" => "5",
|
||||
"apartment" => "D1",
|
||||
"floor" => "1",
|
||||
"postal_code" => "11765",
|
||||
"shipping_method" => "driver_wallet"
|
||||
],
|
||||
"currency" => "EGP",
|
||||
"integration_id" => $integration_id
|
||||
];
|
||||
|
||||
$response = callAPI("POST", $payment_key_url, json_encode($payment_key_data));
|
||||
$payment_token = $response->token ?? null;
|
||||
|
||||
if (!$payment_token) {
|
||||
error_log("❌ Failed to get PAYMENT TOKEN for driver!");
|
||||
die("❌ Failed to get PAYMENT TOKEN for driver!");
|
||||
}
|
||||
|
||||
// 4️⃣ Final Step: Pay with Wallet
|
||||
$redirect_url = payWithWallet($payment_token, $wallet_phone);
|
||||
if ($redirect_url) {
|
||||
printSuccess($redirect_url);
|
||||
error_log("✅ redirect_url (driver): " . $redirect_url);
|
||||
} else {
|
||||
error_log("❌ Driver wallet payment failed!");
|
||||
printFailure("Payment verified, but failed to redirect.");
|
||||
}
|
||||
|
||||
|
||||
// 🔁 Shared helper functions
|
||||
function callAPI($method, $url, $data)
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_CUSTOMREQUEST => $method,
|
||||
CURLOPT_POSTFIELDS => $data,
|
||||
CURLOPT_HTTPHEADER => ["Content-Type: application/json"]
|
||||
]);
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return json_decode($response);
|
||||
}
|
||||
|
||||
function payWithWallet($paymentToken, $walletPhone)
|
||||
{
|
||||
$url = "https://accept.paymob.com/api/acceptance/payments/pay";
|
||||
$data = [
|
||||
"source" => [
|
||||
"identifier" => $walletPhone,
|
||||
"subtype" => "WALLET"
|
||||
],
|
||||
"payment_token" => $paymentToken
|
||||
];
|
||||
$response = callAPI("POST", $url, json_encode($data));
|
||||
return $response->redirect_url ?? null;
|
||||
}
|
||||
146
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/paymet_verfy.php
Executable file
146
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/paymet_verfy.php
Executable file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
include "../../../connect.php";
|
||||
define('BASE_URL', 'https://wl.tripz-egypt.com/v1/main/ride');
|
||||
|
||||
try {
|
||||
$driverId = filterRequest('driverID');
|
||||
$user_id = filterRequest('user_id');
|
||||
$paymentMethod = filterRequest('paymentMethod');
|
||||
|
||||
if (empty($user_id) || empty($driverId)) {
|
||||
printFailure('Missing user_id or driverID.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 1️⃣ تحقق من سجل الدفع خلال آخر دقيقتين
|
||||
$stmt = $con->prepare(
|
||||
'SELECT * FROM payment_log_driver
|
||||
WHERE user_id = :uid
|
||||
AND created_at >= DATE_SUB(NOW(), INTERVAL 2 MINUTE)
|
||||
ORDER BY created_at DESC LIMIT 1'
|
||||
);
|
||||
$stmt->execute([':uid' => $user_id]);
|
||||
$payment = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$payment || $payment['status'] != 1) {
|
||||
printFailure('No valid payment found.');
|
||||
exit;
|
||||
}
|
||||
|
||||
$originalAmount = floatval($payment['amount']);
|
||||
$bonus = match ((int)$originalAmount) {
|
||||
80 => 80.0,
|
||||
200 => 215.0,
|
||||
400 => 450.0,
|
||||
1000 => 1140.0,
|
||||
default => $originalAmount,
|
||||
};
|
||||
|
||||
// 2️⃣ توكن لـ DriverWallet
|
||||
$tokenDriver = generateToken($con, $driverId, $bonus);
|
||||
if (!$tokenDriver) {
|
||||
printFailure('Failed to generate token for driver wallet.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 3️⃣ توكن مستقل لـ SeferWallet
|
||||
$tokenSefer = generateToken($con, $driverId, $originalAmount);
|
||||
if (!$tokenSefer) {
|
||||
printFailure('Failed to generate token for sefer wallet.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 4️⃣ Payment ID
|
||||
$paymentID = generatePaymentID($con, $driverId, $bonus, $paymentMethod);
|
||||
if (!$paymentID) {
|
||||
printFailure('Failed to generate payment ID.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 5️⃣ Insert into driverWallet
|
||||
$insertDriver = $con->prepare("INSERT INTO driverWallet (driverID, paymentID, amount, paymentMethod) VALUES (:driverID, :paymentID, :amount, :paymentMethod)");
|
||||
$insertDriver->execute([
|
||||
':driverID' => $driverId,
|
||||
':paymentID' => $paymentID,
|
||||
':amount' => $bonus,
|
||||
':paymentMethod' => $paymentMethod
|
||||
]);
|
||||
|
||||
if ($insertDriver->rowCount() === 0) {
|
||||
printFailure('Failed to insert into driverWallet.');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 6️⃣ Update tokenDriver to isUsed = TRUE
|
||||
$markTokenDriver = $con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token");
|
||||
$markTokenDriver->execute([':token' => $tokenDriver]);
|
||||
|
||||
// 7️⃣ Insert into seferWallet
|
||||
$insertSefer = $con->prepare("INSERT INTO seferWallet (driverId, passengerId, amount, paymentMethod, token, createdAt)
|
||||
VALUES (:driverId, :passengerId, :amount, :paymentMethod, :token, CURRENT_TIMESTAMP)");
|
||||
$insertSefer->execute([
|
||||
':driverId' => $driverId,
|
||||
':passengerId' => 'driver',
|
||||
':amount' => $originalAmount,
|
||||
':paymentMethod' => $paymentMethod,
|
||||
':token' => $tokenSefer
|
||||
]);
|
||||
|
||||
// 8️⃣ Update tokenSefer to isUsed = TRUE
|
||||
$markTokenSefer = $con->prepare("UPDATE payment_tokens SET isUsed = TRUE WHERE token = :token");
|
||||
$markTokenSefer->execute([':token' => $tokenSefer]);
|
||||
|
||||
// 🎉 Success response
|
||||
printSuccess([
|
||||
'message' => 'Payment verified and all wallets updated successfully.',
|
||||
'amount' => $originalAmount,
|
||||
'bonus' => $bonus,
|
||||
'paymentID' => $paymentID,
|
||||
'tokenUsed' => [
|
||||
'driverWalletToken' => $tokenDriver,
|
||||
'seferWalletToken' => $tokenSefer
|
||||
]
|
||||
]);
|
||||
|
||||
} catch (Throwable $e) {
|
||||
printFailure("Server error: " . $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
// ───────────────────────────
|
||||
// FUNCTIONS
|
||||
// ───────────────────────────
|
||||
|
||||
function generateToken($con, $driverId, $amount): ?string {
|
||||
global $secretKey;
|
||||
|
||||
// نفس المنطق من سكربتك
|
||||
$data = $driverId . $amount . time();
|
||||
$data .= $secretKey;
|
||||
$hash = hash('sha256', $data);
|
||||
$randomBytes = bin2hex(random_bytes(16));
|
||||
$token = substr($hash . $randomBytes, 0, 64);
|
||||
// تخزين التوكن في قاعدة البيانات
|
||||
$stmt = $con->prepare("INSERT INTO payment_tokens (token, driverID, dateCreated, amount)
|
||||
VALUES (:token, :driverID, NOW(), :amount)");
|
||||
$stmt->execute([
|
||||
':token' => $token,
|
||||
':driverID' => $driverId,
|
||||
':amount' => $amount
|
||||
]);
|
||||
|
||||
return $stmt->rowCount() > 0 ? $token : null;
|
||||
}
|
||||
|
||||
function generatePaymentID($con, $driverId, $amount, $method): ?string {
|
||||
|
||||
$stmt = $con->prepare("INSERT INTO paymentsDriverPoints (`amount`, `payment_method`, `driverID`)
|
||||
VALUES (:amount, :method, :driverID)");
|
||||
$stmt->execute([
|
||||
':driverID' => $driverId,
|
||||
':amount' => $amount,
|
||||
':method' => $method
|
||||
]);
|
||||
return $stmt->rowCount() > 0 ? $con->lastInsertId() : null;
|
||||
}
|
||||
110
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/paymob_payout.php
Executable file
110
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/paymob_payout.php
Executable file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
// paymob_payout.php
|
||||
// سكريبت بي ات بي لمعاملات Paymob Payout (محفظة وبنك) بدون تخزين في قاعدة البيانات
|
||||
|
||||
declare(strict_types=1);
|
||||
include '../../../connect.php'; // يعطيك $con، filterRequest(), printSuccess(), printFailure()
|
||||
|
||||
// 1) جلب باراميترات الطلب عبر filterRequest
|
||||
$driverId = filterRequest('driverID');
|
||||
$amount = filterRequest('amount');
|
||||
$method = filterRequest('method'); // 'wallet' أو 'bank'
|
||||
$msisdn = filterRequest('msisdn');
|
||||
$bankCard = filterRequest('bankCard'); // يُستعمل عند method == 'bank'
|
||||
$bankCode = filterRequest('bankCode'); // يُستعمل عند method == 'bank'
|
||||
|
||||
if (empty($driverId) || empty($amount) || empty($method)) {
|
||||
printFailure('Missing parameters');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 2) جلب بيانات Paymob من البيئة (Environment Variables)
|
||||
$pmUser = getenv('payMobOutUserName');
|
||||
$pmPass = getenv('payMobOutPassword');
|
||||
$pmClientId = getenv('PAYMOBOUTCLIENT_ID'); // من static const pmobid
|
||||
$pmSecret = getenv('PAYMOBOUTCLIENTSECRET'); // من static const pmobsec
|
||||
|
||||
// 3) دالة للحصول على OAuth Token من Paymob
|
||||
function fetchPaymobToken(string $user, string $pass, string $cid, string $secret): ?string {
|
||||
$ch = curl_init('https://payouts.paymobsolutions.com/api/secure/o/token/');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded'],
|
||||
CURLOPT_POSTFIELDS => http_build_query([
|
||||
'grant_type' => 'password',
|
||||
'username' => $user,
|
||||
'password' => $pass,
|
||||
'client_id' => $cid,
|
||||
'client_secret' => $secret,
|
||||
]),
|
||||
]);
|
||||
$resp = curl_exec($ch);
|
||||
if (!$resp) return null;
|
||||
$data = json_decode($resp, true);
|
||||
return $data['access_token'] ?? null;
|
||||
}
|
||||
|
||||
$oauthToken = fetchPaymobToken($pmUser, $pmPass, $pmClientId, $pmSecret);
|
||||
if (!$oauthToken) {
|
||||
printFailure('Failed to retrieve Paymob token');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 4) دوال صرف الأموال
|
||||
function disburseWallet(string $token, string $amt, string $msisdn): array {
|
||||
$ch = curl_init('https://payouts.paymobsolutions.com/api/secure/disburse/');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer $token",
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
CURLOPT_POSTFIELDS => json_encode([
|
||||
'amount' => $amt,
|
||||
'issuer' => 'wallet',
|
||||
'msisdn' => $msisdn,
|
||||
]),
|
||||
]);
|
||||
$resp = curl_exec($ch);
|
||||
return $resp ? json_decode($resp, true) : [];
|
||||
}
|
||||
|
||||
function disburseBank(string $token, string $amt, string $card, string $code): array {
|
||||
$ch = curl_init('https://payouts.paymobsolutions.com/api/secure/disburse/');
|
||||
curl_setopt_array($ch, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Bearer $token",
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
CURLOPT_POSTFIELDS => json_encode([
|
||||
'amount' => $amt,
|
||||
'issuer' => 'bank_card',
|
||||
'bank_card_number' => $card,
|
||||
'bank_code' => $code,
|
||||
'bank_transaction_type' => 'cash_transfer',
|
||||
]),
|
||||
]);
|
||||
$resp = curl_exec($ch);
|
||||
return $resp ? json_decode($resp, true) : [];
|
||||
}
|
||||
|
||||
// 5) استدعاء الدالة المناسبة وتنفيذ الصرف
|
||||
if ($method === 'wallet') {
|
||||
$result = disburseWallet($oauthToken, $amount, $msisdn);
|
||||
} else {
|
||||
$result = disburseBank($oauthToken, $amount, $bankCard, $bankCode);
|
||||
}
|
||||
|
||||
// 6) التحقق من نجاح الصرف وإرجاع النتيجة
|
||||
if (empty($result) || ($result['disbursement_status'] ?? '') !== 'successful') {
|
||||
printFailure('Disbursement failed');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 7) إرجاع التوكن والنتيجة للعميل بدون تخزين في DB
|
||||
printSuccess( $result);
|
||||
?>
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
include "../../../jwtconnect.php";
|
||||
|
||||
// ------------------------------
|
||||
// قراءة HMAC من الهيدر أو من الـ query
|
||||
// ------------------------------
|
||||
$received_hmac = $_SERVER['HTTP_HMAC'] ?? ($_GET['hmac'] ?? '');
|
||||
$received_hmac = trim($received_hmac);
|
||||
|
||||
// ------------------------------
|
||||
// قراءة البيانات القادمة من Paymob
|
||||
// ------------------------------
|
||||
$raw_body = file_get_contents("php://input");
|
||||
$data = json_decode($raw_body, true);
|
||||
|
||||
// ------------------------------
|
||||
// المفتاح السري
|
||||
// ------------------------------
|
||||
$secret_key = getenv('hmacPaymob');
|
||||
|
||||
// ------------------------------
|
||||
// دالة لتحويل القيم إلى النصوص
|
||||
// ------------------------------
|
||||
function normalize($value) {
|
||||
if ($value === true) return 'true';
|
||||
if ($value === false) return 'false';
|
||||
if (is_null($value)) return '';
|
||||
return (string)$value;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// التحقق من صحة HMAC
|
||||
// ------------------------------
|
||||
function isValidHmac($data, $secret_key, $received_hmac) {
|
||||
if (!isset($data['obj'])) return false;
|
||||
|
||||
$obj = $data['obj'];
|
||||
|
||||
// دمج جميع الحقول بشكل متسلسل
|
||||
$fields = [
|
||||
normalize($obj['amount_cents'] ?? ''),
|
||||
normalize($obj['created_at'] ?? ''),
|
||||
normalize($obj['currency'] ?? ''),
|
||||
normalize($obj['error_occured'] ?? false),
|
||||
normalize($obj['has_parent_transaction'] ?? false),
|
||||
normalize($obj['id'] ?? ''),
|
||||
normalize($obj['integration_id'] ?? ''),
|
||||
normalize($obj['is_3d_secure'] ?? false),
|
||||
normalize($obj['is_auth'] ?? false),
|
||||
normalize($obj['is_capture'] ?? false),
|
||||
normalize($obj['is_refunded'] ?? false),
|
||||
normalize($obj['is_standalone_payment'] ?? false),
|
||||
normalize($obj['is_voided'] ?? false),
|
||||
normalize($obj['order']['id'] ?? ''),
|
||||
normalize($obj['owner'] ?? ''),
|
||||
normalize($obj['pending'] ?? false),
|
||||
normalize($obj['source_data']['pan'] ?? ''),
|
||||
normalize($obj['source_data']['sub_type'] ?? ''),
|
||||
normalize($obj['source_data']['type'] ?? ''),
|
||||
normalize($obj['success'] ?? false)
|
||||
];
|
||||
|
||||
// دمج الحقول في رسالة واحدة
|
||||
$message = implode('', $fields);
|
||||
|
||||
// حساب HMAC باستخدام المفتاح السري
|
||||
$calculated_hmac = hash_hmac('sha512', $message, $secret_key);
|
||||
|
||||
//
|
||||
/*طباعة الرسائل لأغراض التصحيح
|
||||
error_log("🔐 Message used for HMAC: " . $message);
|
||||
error_log("🔐 Calculated HMAC: " . $calculated_hmac);
|
||||
error_log("📩 Received HMAC: " . $received_hmac);
|
||||
error_log("Calculated HMAC length: " . strlen($calculated_hmac));
|
||||
error_log("Received HMAC length: " . strlen($received_hmac));
|
||||
*/
|
||||
// التحقق من تطابق HMAC
|
||||
if (hash_equals($calculated_hmac, $received_hmac)) {
|
||||
error_log("✅ Valid HMAC signature verified.");
|
||||
return $calculated_hmac;
|
||||
} else {
|
||||
http_response_code(401);
|
||||
echo json_encode(["error" => "Unauthorized – Invalid HMAC"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
isValidHmac($data, $secret_key, $received_hmac);
|
||||
// ------------------------------
|
||||
// إذا كانت HMAC صحيحة، نتابع العملية
|
||||
// ------------------------------
|
||||
if ($data && isset($data['obj'])) {
|
||||
$transaction = $data['obj'];
|
||||
|
||||
$payment_id = $transaction['id'] ?? null;
|
||||
$amount = $transaction['amount_cents'] ?? 0;
|
||||
$status = $transaction['success'] ?? false;
|
||||
$is_voided = $transaction['is_voided'] ?? false;
|
||||
$is_refunded = $transaction['is_refunded'] ?? false;
|
||||
$order_id = $transaction['order']['id'] ?? null;
|
||||
$merchant_order_id = $transaction['order']['merchant_order_id'] ?? null;
|
||||
$payment_method = $transaction['source_data']['type'] ?? 'unknown';
|
||||
$card_last4 = $transaction['source_data']['pan'] ?? '****';
|
||||
$transaction_type = $transaction['data']['migs_transaction']['type'] ?? 'UNKNOWN';
|
||||
$created_at = $transaction['created_at'] ?? date("Y-m-d H:i:s");
|
||||
$user_id = $transaction['order']['shipping_data']['phone_number'];
|
||||
|
||||
$user_id='+2'. $user_id;
|
||||
$amount=$amount/100;
|
||||
|
||||
// التحقق من حالة الدفع
|
||||
if (!$status) {
|
||||
error_log("❌ Invalid payment status: " . $status);
|
||||
echo json_encode(["error" => "Invalid payment status"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// إضافة البيانات إلى قاعدة البيانات
|
||||
$query = "INSERT INTO payment_log_driver (`payment_id`, `user_id`, `amount`, `status`)
|
||||
VALUES (:payment_id, :user_id, :amount, :status)";
|
||||
|
||||
$stmt = $con->prepare($query);
|
||||
$stmt->bindParam(':payment_id', $payment_id);
|
||||
$stmt->bindParam(':user_id', $user_id);
|
||||
$stmt->bindParam(':amount', $amount);
|
||||
$stmt->bindParam(':status', $status);
|
||||
|
||||
try {
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
http_response_code(200);
|
||||
echo json_encode(["success" => true, "message" => "Payment data saved successfully"]);
|
||||
error_log("Payment data saved successfully" . $status);
|
||||
} else {
|
||||
http_response_code(200);
|
||||
echo json_encode(["success" => false, "message" => "Payment data already up to date."]);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(["error" => "Failed to execute the query: " . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
142
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/paymob_webhook.php
Executable file
142
walletintaleq.intaleq.xyz/v2/main/ride/payMob/paymob_driver/paymob_webhook.php
Executable file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
include "../../../jwtconnect.php";
|
||||
|
||||
// ------------------------------
|
||||
// قراءة HMAC من الهيدر أو من الـ query
|
||||
// ------------------------------
|
||||
$received_hmac = $_SERVER['HTTP_HMAC'] ?? ($_GET['hmac'] ?? '');
|
||||
$received_hmac = trim($received_hmac);
|
||||
|
||||
// ------------------------------
|
||||
// قراءة البيانات القادمة من Paymob
|
||||
// ------------------------------
|
||||
$raw_body = file_get_contents("php://input");
|
||||
$data = json_decode($raw_body, true);
|
||||
|
||||
// ------------------------------
|
||||
// المفتاح السري
|
||||
// ------------------------------
|
||||
$secret_key = getenv('hmacPaymob');
|
||||
|
||||
// ------------------------------
|
||||
// دالة لتحويل القيم إلى النصوص
|
||||
// ------------------------------
|
||||
function normalize($value) {
|
||||
if ($value === true) return 'true';
|
||||
if ($value === false) return 'false';
|
||||
if (is_null($value)) return '';
|
||||
return (string)$value;
|
||||
}
|
||||
|
||||
// ------------------------------
|
||||
// التحقق من صحة HMAC
|
||||
// ------------------------------
|
||||
function isValidHmac($data, $secret_key, $received_hmac) {
|
||||
if (!isset($data['obj'])) return false;
|
||||
|
||||
$obj = $data['obj'];
|
||||
|
||||
// دمج جميع الحقول بشكل متسلسل
|
||||
$fields = [
|
||||
normalize($obj['amount_cents'] ?? ''),
|
||||
normalize($obj['created_at'] ?? ''),
|
||||
normalize($obj['currency'] ?? ''),
|
||||
normalize($obj['error_occured'] ?? false),
|
||||
normalize($obj['has_parent_transaction'] ?? false),
|
||||
normalize($obj['id'] ?? ''),
|
||||
normalize($obj['integration_id'] ?? ''),
|
||||
normalize($obj['is_3d_secure'] ?? false),
|
||||
normalize($obj['is_auth'] ?? false),
|
||||
normalize($obj['is_capture'] ?? false),
|
||||
normalize($obj['is_refunded'] ?? false),
|
||||
normalize($obj['is_standalone_payment'] ?? false),
|
||||
normalize($obj['is_voided'] ?? false),
|
||||
normalize($obj['order']['id'] ?? ''),
|
||||
normalize($obj['owner'] ?? ''),
|
||||
normalize($obj['pending'] ?? false),
|
||||
normalize($obj['source_data']['pan'] ?? ''),
|
||||
normalize($obj['source_data']['sub_type'] ?? ''),
|
||||
normalize($obj['source_data']['type'] ?? ''),
|
||||
normalize($obj['success'] ?? false)
|
||||
];
|
||||
|
||||
// دمج الحقول في رسالة واحدة
|
||||
$message = implode('', $fields);
|
||||
|
||||
// حساب HMAC باستخدام المفتاح السري
|
||||
$calculated_hmac = hash_hmac('sha512', $message, $secret_key);
|
||||
|
||||
//
|
||||
/*طباعة الرسائل لأغراض التصحيح
|
||||
error_log("🔐 Message used for HMAC: " . $message);
|
||||
error_log("🔐 Calculated HMAC: " . $calculated_hmac);
|
||||
error_log("📩 Received HMAC: " . $received_hmac);
|
||||
error_log("Calculated HMAC length: " . strlen($calculated_hmac));
|
||||
error_log("Received HMAC length: " . strlen($received_hmac));
|
||||
*/
|
||||
// التحقق من تطابق HMAC
|
||||
if (hash_equals($calculated_hmac, $received_hmac)) {
|
||||
error_log("✅ Valid HMAC signature verified.");
|
||||
return $calculated_hmac;
|
||||
} else {
|
||||
http_response_code(401);
|
||||
echo json_encode(["error" => "Unauthorized – Invalid HMAC"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
isValidHmac($data, $secret_key, $received_hmac);
|
||||
// ------------------------------
|
||||
// إذا كانت HMAC صحيحة، نتابع العملية
|
||||
// ------------------------------
|
||||
if ($data && isset($data['obj'])) {
|
||||
$transaction = $data['obj'];
|
||||
|
||||
$payment_id = $transaction['id'] ?? null;
|
||||
$amount = $transaction['amount_cents'] ?? 0;
|
||||
$status = $transaction['success'] ?? false;
|
||||
$is_voided = $transaction['is_voided'] ?? false;
|
||||
$is_refunded = $transaction['is_refunded'] ?? false;
|
||||
$order_id = $transaction['order']['id'] ?? null;
|
||||
$merchant_order_id = $transaction['order']['merchant_order_id'] ?? null;
|
||||
$payment_method = $transaction['source_data']['type'] ?? 'unknown';
|
||||
$card_last4 = $transaction['source_data']['pan'] ?? '****';
|
||||
$transaction_type = $transaction['data']['migs_transaction']['type'] ?? 'UNKNOWN';
|
||||
$created_at = $transaction['created_at'] ?? date("Y-m-d H:i:s");
|
||||
$user_id = $transaction['order']['shipping_data']['phone_number'];
|
||||
|
||||
$user_id='+'. $user_id;
|
||||
$amount=$amount/100;
|
||||
|
||||
// التحقق من حالة الدفع
|
||||
if (!$status) {
|
||||
error_log("❌ Invalid payment status: " . $status);
|
||||
echo json_encode(["error" => "Invalid payment status"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// إضافة البيانات إلى قاعدة البيانات
|
||||
$query = "INSERT INTO payment_log_driver (`payment_id`, `user_id`, `amount`, `status`)
|
||||
VALUES (:payment_id, :user_id, :amount, :status)";
|
||||
|
||||
$stmt = $con->prepare($query);
|
||||
$stmt->bindParam(':payment_id', $payment_id);
|
||||
$stmt->bindParam(':user_id', $user_id);
|
||||
$stmt->bindParam(':amount', $amount);
|
||||
$stmt->bindParam(':status', $status);
|
||||
|
||||
try {
|
||||
$stmt->execute();
|
||||
if ($stmt->rowCount() > 0) {
|
||||
http_response_code(200);
|
||||
echo json_encode(["success" => true, "message" => "Payment data saved successfully"]);
|
||||
error_log("Payment data saved successfully" . $status);
|
||||
} else {
|
||||
http_response_code(200);
|
||||
echo json_encode(["success" => false, "message" => "Payment data already up to date."]);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(["error" => "Failed to execute the query: " . $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user