60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Carbon\Carbon;
|
|
use App\Models\User;
|
|
use App\Models\LogUser;
|
|
|
|
class WhatsappPembidaFPXPaid implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public $userId, $resitId, $amount;
|
|
|
|
public function __construct($userId, $resitId, $amount)
|
|
{
|
|
$this->userId = $userId;
|
|
$this->resitId = $resitId;
|
|
$this->amount = $amount;
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
$dt = Carbon::now();
|
|
$user = User::find($this->userId);
|
|
if (!$user || !$user->notelbimbit) return;
|
|
|
|
$message = "Assalamualaikum {$user->name}, bayaran FPX anda sebanyak RM " . number_format($this->amount, 2) . " telah berjaya direkodkan. Resit ID: {$this->resitId}. Terima kasih.";
|
|
|
|
$mobile_no = '6' . $user->notelbimbit;
|
|
if (config('app.env') != 'production') {
|
|
$mobile_no = config('app.admin_phone_number');
|
|
}
|
|
|
|
$response = Http::get(config('app.wabot_api'), [
|
|
'number' => $mobile_no,
|
|
'type' => 'text',
|
|
'message' => $message,
|
|
'instance_id' => config('app.wabot_instances_id'),
|
|
'access_token' => config('app.wabot_token_keys')
|
|
]);
|
|
|
|
$loguser = new LogUser;
|
|
$loguser->date = $dt;
|
|
$loguser->username = 'Operasi';
|
|
$loguser->nama_user = 'System';
|
|
$loguser->nota = 'Notifikasi Pembayaran Billplz Berjaya';
|
|
$loguser->save();
|
|
|
|
Log::info("Notifikasi Pembayaran Billplz Berjaya: " . $response);
|
|
}
|
|
}
|