all(); $gateway = GatewayWorkflow::run($trasition, $gateway, $request); $data = new GatewayResource($gateway); return $this->response->message(trans('messages.success.updated', ['Module' => trans('payment::gateway.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('payment/gateway/' . $gateway->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('payment/gateway/' . $gateway->getRouteKey())) ->redirect(); } } /** * Get the gateway and user for the workflow. * * @param PublicRequest $request * @param string $gateway * @param string $user * * @return Response */ public function get(PublicRequest $request, $gateway, $user) { if (!$request->hasValidSignature()) { abort(403, 'This url is expired!'); } $auth = Auth::guard()->getProvider()->getModel(); $user = $auth::findBySignedId($user); Auth::guard()->login($user); $gateway = Gateway::findBySignedId($gateway); $transitions = $this->transitions($gateway, $user); $user = user(); Auth::logout(); return $this->response->setMetaTitle(trans('payment::gateway.name') . ' ' . trans('Approvals')) ->view('payment::public.gateway.workflow') ->layout('mobile') ->data(compact('gateway', 'user', 'transitions')) ->output(); } /** * Display the workflow form for the gateway. * * @param PublicRequest $request * @param string $gateway * @param string $user * * @return Response */ public function post(PublicRequest $request, $gateway, $user) { if (!$request->hasValidSignature()) { abort(403, 'This url is expired!'); } $transition = $request->transition; $auth = Auth::guard()->getProvider()->getModel(); $user = $auth::findBySignedId($user); Auth::guard()->login($user); $gateway = Gateway::findBySignedId($gateway); $user = user(); $gateway = GatewayWorkflow::run($transition, $gateway, $request->all()); Auth::logout(); return response()->json( [ 'status' => 'success', 'url' => $request->url(), ] ); } private function transitions($gateway, $user) { $transitions = []; foreach ($gateway->workflow()->transitions($gateway) as $key => $value) { $name = $value->getName(); $array['url'] = URL::temporarySignedRoute('litecms.gateway.workflow', now()->addMinutes(3), [ 'guard' => 'admin', 'transition' => $name, 'gateway' => $gateway->getSignedId(now()->addMinutes(3)), 'user' => $user->getSignedId(now()->addMinutes(3)), 'trans' => 'en', ] ); $array['name'] = $name; $array['key'] = $name; $array['form'] = $gateway->workflow()->form($value); $array['label'] = trans('payment::gateway.workflow.' . $name); $transitions[] = $array; } return $transitions; } }