api chat, send summary, health sertificate, callback duitku
This commit is contained in:
@@ -143,10 +143,17 @@ class LivechatController extends Controller
|
||||
);
|
||||
} else {
|
||||
// insert table livechat
|
||||
|
||||
/**
|
||||
* Status Livechat
|
||||
* 1=Request, 2=Accept, 3=Decline, 4=Waiting Payment, 5=Success Payment, 6 = End Chat
|
||||
*/
|
||||
|
||||
$timezone = date_default_timezone_get();
|
||||
$data['request_date'] = date('Y-m-d H:i:s');
|
||||
$data['timezone'] = $timezone;
|
||||
$data['uuid'] = (string) Str::orderedUuid();
|
||||
$data['status'] = 1;
|
||||
$livechat = Livechat::create($data);
|
||||
$doctor = $livechat->doctor;
|
||||
$data = [
|
||||
@@ -159,6 +166,7 @@ class LivechatController extends Controller
|
||||
return Helper::responseJson(data: $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function consultation_request_show($id){
|
||||
$livechat = Livechat::where('id', $id)->with(['doctor', 'practitioner'])->first();
|
||||
$practitionerRole = PractitionerRole::where('id',$livechat->practitioner->id)->first();
|
||||
@@ -229,44 +237,62 @@ class LivechatController extends Controller
|
||||
return Helper::responseJson(data: $data);
|
||||
}
|
||||
|
||||
public function consultation_payment(Request $request){
|
||||
public function consultation_payment(Request $request)
|
||||
{
|
||||
try {
|
||||
// Mengambil data Livechat dengan relasi doctor dan practitioner
|
||||
$livechat = Livechat::with(['doctor', 'practitioner'])->find($request->consultation_id);
|
||||
|
||||
$livechat = Livechat::where('id', $request->consultation_id)->with(['doctor', 'practitioner'])->first();
|
||||
|
||||
$practitionerRole = PractitionerRole::where('id',$livechat->practitioner->id)->first();
|
||||
$price = $practitionerRole->price ? $practitionerRole->price : 30000;
|
||||
$adminFee = 5000;
|
||||
$discount = 0;
|
||||
$totalPay = $price + $adminFee - $discount;
|
||||
if (!$livechat) {
|
||||
return response()->json(['success' => false, 'message' => 'Consultation not found'], 404);
|
||||
}
|
||||
|
||||
// From database linksehat
|
||||
$user = User::with('detail')
|
||||
->where('nId', $livechat->patient_id)
|
||||
->first();
|
||||
|
||||
$data['paymentMethod'] = $request->payment_code;
|
||||
$data['paymentAmount'] = $totalPay;
|
||||
$data['email'] = $user->sEmail;
|
||||
$data['phoneNumber'] = $user->sPhone;
|
||||
$data['productDetails'] = $user->sEmail;
|
||||
$data['merchantOrderId'] = $livechat->uuid;
|
||||
$data['additionalParam'] = '';
|
||||
$data['merchantUserInfo'] = '';
|
||||
$data['customerVaName'] = $user->sFirstName . ' ' . $user->sLastName;
|
||||
$data['callbackUrl'] = 'htpps://google.com';
|
||||
$data['returnUrl'] = 'htpps://linksehat.com';
|
||||
$data['expiryPeriod'] = 60;
|
||||
$data['firstName'] = $user->sFirstName;
|
||||
$data['lastName'] = $user->sLastName;
|
||||
// Update status
|
||||
$livechat->status = 4;
|
||||
$livechat->save();
|
||||
|
||||
// dd($user);
|
||||
$data['alamat'] = '';
|
||||
$data['city'] = '';
|
||||
$data['postalCode'] = '';
|
||||
$practitionerRole = PractitionerRole::find($livechat->practitioner->id);
|
||||
$price = $practitionerRole->price ?? 30000; // Gunakan null coalescing operator
|
||||
$adminFee = 5000;
|
||||
$discount = 0;
|
||||
$totalPay = $price + $adminFee - $discount;
|
||||
|
||||
$duitku = DuitkuHelper::createInvoice($data);
|
||||
// Mengambil user dari database
|
||||
$user = User::with('detail')->where('nId', $livechat->patient_id)->first();
|
||||
|
||||
return $duitku;
|
||||
if (!$user) {
|
||||
return response()->json(['success' => false, 'message' => 'User not found'], 404);
|
||||
}
|
||||
|
||||
// Menyiapkan data untuk invoice
|
||||
$data = [
|
||||
'paymentMethod' => $request->payment_code,
|
||||
'paymentAmount' => $totalPay,
|
||||
'email' => $user->sEmail,
|
||||
'phoneNumber' => $user->sPhone,
|
||||
'productDetails' => 'Telekonsul Livechat LMS',
|
||||
'merchantOrderId' => $livechat->uuid,
|
||||
'additionalParam' => '',
|
||||
'merchantUserInfo' => '',
|
||||
'customerVaName' => $user->sFirstName . ' ' . $user->sLastName,
|
||||
'callbackUrl' => 'https://google.com',
|
||||
'returnUrl' => 'https://linksehat.com',
|
||||
'expiryPeriod' => 60,
|
||||
'firstName' => $user->sFirstName,
|
||||
'lastName' => $user->sLastName,
|
||||
'alamat' => '',
|
||||
'city' => '',
|
||||
'postalCode' => ''
|
||||
];
|
||||
|
||||
// Membuat invoice menggunakan DuitkuHelper
|
||||
$duitku = DuitkuHelper::createInvoice($data);
|
||||
|
||||
return response()->json(['success' => true, 'data' => $duitku], 200);
|
||||
} catch (Exception $e) {
|
||||
// Menangkap error dan mengembalikan respon error
|
||||
return response()->json(['success' => false, 'message' => $e->getMessage()], 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function consultation_check_payment($id){
|
||||
|
||||
Reference in New Issue
Block a user