From 6be2e6d02bc8103904113c44cd7da2bb6bae3c75 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 7 Mar 2026 10:21:00 +0000 Subject: [PATCH] modifying pos --- api/order.php | 7 ++++++- includes/WablasService.php | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/api/order.php b/api/order.php index e57474a..e316b43 100644 --- a/api/order.php +++ b/api/order.php @@ -9,6 +9,7 @@ require_once __DIR__ . '/../includes/WablasService.php'; $input = file_get_contents('php://input'); $data = json_decode($input, true); + if (!$data) { echo json_encode(['success' => false, 'error' => 'No data provided']); exit; @@ -417,7 +418,11 @@ You've earned *{points_earned} points* with this order. ]; $msg = str_replace(array_keys($replacements), array_values($replacements), $template); - $wablas->sendMessage($customer_phone, $msg); + $customer_phone = trim((string)$customer_phone); + $res = $wablas->sendMessage($customer_phone, $msg); + if (empty($res['success'])) { + error_log("Wablas Order Send Failed for {$customer_phone}: " . ($res['message'] ?? 'Unknown')); + } } catch (Exception $w) { error_log("Wablas Exception: " . $w->getMessage()); diff --git a/includes/WablasService.php b/includes/WablasService.php index 3593c20..373e98b 100644 --- a/includes/WablasService.php +++ b/includes/WablasService.php @@ -21,9 +21,9 @@ class WablasService { $settings[$r['setting_key']] = $r['setting_value']; } - $this->domain = $settings['domain'] ?? ''; - $this->token = $settings['token'] ?? ''; - $this->secret_key = $settings['secret_key'] ?? ''; + $this->domain = trim($settings['domain'] ?? ''); + $this->token = trim($settings['token'] ?? ''); + $this->secret_key = trim($settings['secret_key'] ?? ''); $this->is_enabled = ($settings['is_enabled'] ?? '0') === '1'; } @@ -38,6 +38,7 @@ class WablasService { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); @@ -105,10 +106,11 @@ class WablasService { "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_UNICODE)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Added 10 second timeout + curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $response = curl_exec($ch); $curlError = curl_error($ch);