Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
create webhook for payment status
Browse files Browse the repository at this point in the history
  • Loading branch information
FemiNoviaLina committed Jun 5, 2022
1 parent 8184181 commit 299a606
Show file tree
Hide file tree
Showing 12 changed files with 19,960 additions and 13,537 deletions.
3 changes: 3 additions & 0 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ public function rejectOrder($id) {
}

public function doneVehicle() {
$id = request()->order_id;
$order = Order::find($id);

$order->order_status = 'COMPLETED';
$order->save();

Expand Down
40 changes: 30 additions & 10 deletions app/Http/Controllers/RentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,6 @@ public function rentVehicle($type, $id, Request $request)

public function getUserOrders()
{
// $orders = Order::join('vehicles', 'orders.vehicle_id', '=', 'vehicles.id')
// ->where('user_id', '=', auth()->user()->id)
// ->where('order_status', 'IN', ['PENDING', 'WAITING_FOR_PAYMENT'])
// ->where('pickup_date', '<', date('Y-m-d'))
// ->orWhere(function($query) {
// $query->where('pickup_date', '=', date('Y-m-d'))
// ->where('pickup_time', '<', date('H:i:s'));
// })
// ->update(['order_status' => 'CANCELED']);

$orders = Order::join('vehicles', 'orders.vehicle_id', '=', 'vehicles.id')
->select("orders.id", "orders.order_status", "orders.created_at", "vehicles.name")
->where('user_id', '=', auth()->user()->id)
Expand Down Expand Up @@ -280,4 +270,34 @@ public function checkPayment($id) {

return redirect()->route('user-orders');
}

public function paymentNotification() {
$notif = request()->input();

$transaction = $notif['transaction_status'];
$type = $notif['payment_type'];
$transaction_id = $notif['transaction_id'];
$fraud = $notif['fraud_status'];

$order = Order::where('transaction_id', '=', $transaction_id)->first();

if ($transaction == 'settlement') {
$order->order_status = 'PAYMENT_DONE';
}
else if($transaction == 'pending') {
$order->order_status = 'WAITING_FOR_PAYMENT';
}
else if ($transaction == 'deny') {
$order->order_status = 'REJECTED';
}
else if ($transaction == 'expire') {
$order->order_status = 'CANCELED';
}
else if ($transaction == 'cancel') {
$order->order_status = 'CANCELED';
}

$order->save();
return response()->noContent();
}
}
2 changes: 1 addition & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
* @var array<int, string>
*/
protected $except = [
//
'/payment/notification'
];
}
Loading

0 comments on commit 299a606

Please sign in to comment.