public static function setOrderLog($id, $message) { $order = Order::find($id); if ($order != null) { $dataOrder = json_decode($order->data_116, true); if (!isset($dataOrder['log'])) { $dataOrder['log'] = []; } array_unshift($dataOrder['log'], ['time' => date('U'), 'status' => $order->status_id_116, 'message' => $message]); $order->data_116 = json_encode($dataOrder); $order->save(); } }
public function updateCustomRecord($parameters) { $order = Order::find($parameters['id']); Order::where('id_116', $parameters['id'])->update(['status_id_116' => $this->request->input('status'), 'payment_method_id_116' => $this->request->input('paymentMethod'), 'comments_116' => $this->request->has('comments') ? $this->request->input('comments') : null, 'has_gift_116' => $this->request->has('gift'), 'gift_from_116' => $this->request->has('giftFrom') ? $this->request->input('giftFrom') : null, 'gift_to_116' => $this->request->has('giftTo') ? $this->request->input('giftTo') : null, 'gift_message_116' => $this->request->has('giftMessage') ? $this->request->input('giftMessage') : null, 'customer_id_116' => $this->request->input('customerId'), 'customer_company_116' => $this->request->has('customerCompany') ? $this->request->input('customerCompany') : null, 'customer_tin_116' => $this->request->has('customerTin') ? $this->request->input('customerTin') : null, 'customer_name_116' => $this->request->has('customerName') ? $this->request->input('customerName') : null, 'customer_surname_116' => $this->request->has('customerSurname') ? $this->request->input('customerSurname') : null, 'customer_email_116' => $this->request->input('customerEmail'), 'customer_phone_116' => $this->request->has('customerPhone') ? $this->request->input('customerPhone') : null, 'customer_mobile_116' => $this->request->has('customerMobile') ? $this->request->input('customerMobile') : null, 'has_shipping_116' => $this->request->has('hasShipping'), 'shipping_company_116' => $this->request->has('shippingCompany') ? $this->request->input('shippingCompany') : null, 'shipping_name_116' => $this->request->has('shippingName') ? $this->request->input('shippingName') : null, 'shipping_surname_116' => $this->request->has('shippingSurname') ? $this->request->input('shippingSurname') : null, 'shipping_email_116' => $this->request->has('shippingEmail') ? $this->request->input('shippingEmail') : null, 'shipping_phone_116' => $this->request->has('shippingPhone') ? $this->request->input('shippingPhone') : null, 'shipping_mobile_116' => $this->request->has('shippingMobile') ? $this->request->input('shippingMobile') : null, 'shipping_amount_116' => $this->request->has('shippingAmount') ? $this->request->input('shippingAmount') : 0]); // if order status is different that previous status order, we record this change if ($order->status_id_116 != (int) $this->request->input('status')) { $orderStatus = OrderStatus::builder()->where('lang_id_114', base_lang()->id_001)->where('active_114', true)->get(); Order::setOrderLog($parameters['id'], trans('market::pulsar.message_user_change_order_status', ['user' => auth('pulsar')->user()->user_010, 'oldStatus' => $orderStatus->where('id_114', $order->status_id_116)->first()->name_114, 'newStatus' => $orderStatus->where('id_114', (int) $this->request->input('status'))->first()->name_114])); } }
/** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function checkoutPayment() { $paymentId = $this->request->input('paymentId'); $payment = Payment::get($paymentId, $this->apiContext); $execution = new PaymentExecution(); $execution->setPayerId($this->request->input('PayerID')); try { $response = $payment->execute($execution, $this->apiContext); } catch (\Exception $ex) { dd($ex->getMessage()); } $order = Order::builder()->where('payment_id_116', $this->request->input('paymentId'))->first(); if ($response->getState() == 'approved') { if (!empty($order->order_status_successful_id_115)) { // set next status to complete payment method $order->status_id_116 = $order->order_status_successful_id_115; $order->save(); } $viewResponse['html'] = ' <form id="redirect_paypal_form" action="' . route($this->preferences->where('id_018', 'marketPayPalSuccessRoute')->first()->value_018) . '" method="post"> <input type="hidden" name="_token" value="' . csrf_token() . '"/> <input type="hidden" name="order" value="' . $order->id_116 . '"/> </form> <script>document.getElementById("redirect_paypal_form").submit();</script> '; return view('pulsar::common.views.html_display', $viewResponse); } else { $viewResponse['html'] = ' <form id="redirect_paypal_form" action="' . route($this->preferences->where('id_018', 'marketPayPalErrorRoute')->first()->value_018) . '" method="post"> <input type="hidden" name="_token" value="' . csrf_token() . '"/> <input type="hidden" name="order" value="' . $order->id_116 . '"/> </form> <script>document.getElementById("redirect_paypal_form").submit();</script> '; return view('pulsar::common.views.html_display', $viewResponse); } }