40 lines
993 B
PHP
40 lines
993 B
PHP
<?php
|
|
|
|
namespace App\Controllers\Frontend;
|
|
|
|
use App\Controllers\BaseController;
|
|
use CodeIgniter\API\ResponseTrait;
|
|
use App\Libraries\Lalamove;
|
|
use App\Models\LogLalamove;
|
|
|
|
class LalamoveController extends BaseController
|
|
{
|
|
protected $lalamove;
|
|
use ResponseTrait;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->lalamove = new Lalamove();
|
|
}
|
|
|
|
public function webhook()
|
|
{
|
|
// $log_lalamove = new LogLalamove();
|
|
// $log_lalamove->insert([
|
|
// 'url' => 'https://icom.ipsgroup.com.my/api/lalamove/webhook',
|
|
// 'request' => json_encode($this->request->getJSON(true)),
|
|
// 'respond' => 'Webhook received',
|
|
// ]);
|
|
$rawBody = file_get_contents('php://input');
|
|
$data = json_decode($rawBody, true);
|
|
if($data){
|
|
$this->lalamove->handleWebhook($data);
|
|
}
|
|
|
|
return $this->respond([
|
|
'status' => 200,
|
|
'message' => 'Webhook received'
|
|
]);
|
|
}
|
|
}
|