api chat, send summary, health sertificate, callback duitku
This commit is contained in:
@@ -5,6 +5,9 @@ namespace Modules\Linksehat\Http\Controllers\Api;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Organization;
|
||||
use App\Models\Speciality;
|
||||
use App\Models\Livechat;
|
||||
use App\Models\Channel;
|
||||
use App\Models\UserChannel;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -271,6 +274,8 @@ class DuitkuController extends Controller
|
||||
header('Content-Type: application/json');
|
||||
$notif = json_decode($callback);
|
||||
|
||||
// $notif = $request; ini untuk di local
|
||||
|
||||
DB::table('api_logs')
|
||||
->insert([
|
||||
'type' => 'in',
|
||||
@@ -280,12 +285,57 @@ class DuitkuController extends Controller
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
|
||||
if ($notif->resultCode == "00") {
|
||||
// Action Success
|
||||
return Redirect::to('https://linksehat.com/');
|
||||
$livechat = Livechat::where('uuid', $notif->merchantOrderId)->first();
|
||||
// Update status pembayaran
|
||||
$livechat->payment_method = $notif->paymentCode;
|
||||
$livechat->status = 5; // success payment
|
||||
$livechat->save();
|
||||
|
||||
// Update start chat
|
||||
$livechat->start_date = date('Y-m-d H:i:s');
|
||||
// Buat dan simpan data channel ke dalam tabel
|
||||
$channel = Channel::updateOrCreate([
|
||||
'name' => $livechat->patient_id .'_' . $request->doctor_id,
|
||||
],
|
||||
[
|
||||
'name' => $livechat->patient_id .'_' . $livechat->doctor_id,
|
||||
'type' => 'Private',
|
||||
'member_id' => $livechat->patient_id,
|
||||
'doctor_id' => $livechat->doctor_id,
|
||||
]);
|
||||
|
||||
// Menggunakan updateOrCreate untuk menambahkan data UserChannel untuk member_id
|
||||
$userChannelMember = UserChannel::updateOrCreate(
|
||||
[
|
||||
'user_id' => $livechat->patient_id,
|
||||
'channel_id' => $channel->id
|
||||
],
|
||||
[
|
||||
'user_id' => $livechat->patient_id,
|
||||
'channel_id' => $channel->id
|
||||
]
|
||||
);
|
||||
|
||||
// Menggunakan updateOrCreate untuk menambahkan data UserChannel untuk doctor_id
|
||||
$userChannelDoctor = UserChannel::updateOrCreate(
|
||||
[
|
||||
'user_id' => $livechat->doctor_id,
|
||||
'channel_id' => $channel->id
|
||||
],
|
||||
[
|
||||
'user_id' => $livechat->doctor_id,
|
||||
'channel_id' => $channel->id
|
||||
]
|
||||
);
|
||||
|
||||
// Berikan respons yang sesuai ke klien
|
||||
return response()->json(['message' => 'Channel created successfully', 'channel' => $channel]);
|
||||
|
||||
} else if ($notif->resultCode == "01") {
|
||||
// Action Failed
|
||||
return response()->json(['message' => 'User Gagal melakukan pembayaran']);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user