Level 1
this is my job file
public function verify_order(Request $request){ $validator = Validator::make($request->all(), [ 'reference' => 'required|string', ]);
if (!$validator) {
return response(['errors' => $validator->errors()->all()], 422);
}
if($response['status'] == "error") return response(['errors' => 'Transaction is not valid...'.$response['message']], 500);
if($response['data'] == null || $response['data']['status'] != 'successful') return response(['errors' => 'Transaction is not valid...'], 500);
$data = $response['data'];
// if($data['meta']==null) return response(['errors' => 'Transaction is not valid...'], 500);
// get the order_id from the consumer_mac prop
$order_id = $data['meta']['consumer_mac'];
// make sure the order exists
$order = Order::where('id', $order_id)->first();
// make sure the prices match
$price_match = $order->total_amount == $data['amount'];
if($price_match && $data['status'] == 'successful'){
$order->status = 'fulfilled';
$order->save();
// notify the buyer of the order
$user = Reservations::find($order->user_id);
$mailData = [
'name' => $user->name,
'subject' => "Order Received",
'image'=>'',
'msg' => "Hi ".$user->name.", we've received your order and will get back to you shortly",
];
// Mail::to($user->email)->send(new BroadcastMail($mailData));
SendOrderNotification::dispatch($mailData)->onQueue('emails');
// notify the platform owner of the order
$admin_email = "[email protected]";
$mailData2 = [
'name' => "Unboxed Party Admin",
'image'=>'',
'subject' => "New Order Placed",
'msg' => "Hi admin, the customer, ".$user->name.", has placed a new order at Unboxed website. Their order ID is ".$order->id.". Please do well to attend to this order as soon as possible!",
];
// Mail::to($admin_email)->send(new BroadcastMail($mailData2));
SendOrderNotification::dispatch($mailData2)->onQueue('emails');
return response()->json(['success' => true]);
}else{
return response(['errors' => 'Transaction is not valid'], 500);
}
}
this is my job
Please or to participate in this conversation.