Пример #1
0
 /**
  * Handle a Stripe webhook call.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handleWebhook()
 {
     $payload = (array) json_decode(Request::getContent(), true);
     $method = 'handle' . studly_case(str_replace('.', '_', $payload['type']));
     if (method_exists($this, $method)) {
         return $this->{$method}($payload);
     } else {
         return $this->missingMethod();
     }
 }
 public function login()
 {
     $raw = json_decode(Request::getContent());
     $user = User::where('name', $raw->name)->where('password', $raw->pass)->firstOrFail();
     return Response::json(['status_code' => 200, 'data' => $user]);
     // return redirect()->intended('dashboard');
     // }
     // abort(403, "You're not authorized to access this public REST API.");
     // $auth = auth()->guard('api');
     // if ($auth->check()) {
     // return $auth->user();
     // };
     // abort(403, "You're not authorized to access this public REST API.");
 }
Пример #3
0
 /**
  * Handles the request made to StyleCI by the GitHub API.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function handle()
 {
     $class = 'StyleCI\\StyleCI\\Events\\Repo\\GitHub\\GitHub' . ucfirst(camel_case(Request::header('X-GitHub-Event'))) . 'Event';
     if (!class_exists($class)) {
         throw new BadRequestHttpException('Event not supported.');
     }
     $data = Request::input();
     $repo = Repo::find($data['repository']['id']);
     if (!$repo) {
         throw new BadRequestHttpException('Request integrity validation failed.');
     }
     list($algo, $sig) = explode('=', Request::header('X-Hub-Signature'));
     $hash = hash_hmac($algo, Request::getContent(), $repo->token);
     if (!Str::equals($hash, $sig)) {
         throw new BadRequestHttpException('Request integrity validation failed.');
     }
     event(new $class($repo, $data));
     return new JsonResponse(['message' => 'Event successfully received.']);
 }
 /**
  * Get the JSON payload for the request.
  *
  * @return array
  */
 protected function getJsonPayload()
 {
     return (array) json_decode(Request::getContent(), true);
 }
Пример #5
0
 public function __construct()
 {
     $k2Data = Request::getContent();
     $this->k2 = new K2($k2Data);
 }
Пример #6
0
 /**
  * Validate the request MD5 data header.
  *
  * @param  string $clientSecret
  * @return boolean
  */
 public function validateMD5Data($clientSecret = '')
 {
     $md5 = $this->header('CONTENT_MD5');
     if (parent::isJson()) {
         $content = parent::getContent();
         if (empty($md5) and empty($content)) {
             return true;
         }
         return md5($content . $clientSecret) == $md5;
     }
     $input = $this->all();
     if (!empty($input)) {
         foreach ($input as $key => $item) {
             if (str_contains($key, '/')) {
                 unset($input[$key]);
             }
         }
     }
     if (empty($md5) and empty($input)) {
         return true;
     }
     return md5(http_build_query($input) . $clientSecret) == $md5;
 }
Пример #7
0
 /**
  * 
  * 支付结果通用通知
  * @param function $callback
  * 直接回调函数使用方法: notify(you_function);
  * 回调类成员函数方法:notify(array($this, you_function));
  * $callback  原型为:function function_name($data){}
  */
 public static function notify($callback, &$msg)
 {
     //获取通知的数据
     $xml = Request::getContent();
     //$GLOBALS['HTTP_RAW_POST_DATA'];
     //如果返回成功则验证签名
     try {
         $result = PayResults::Init($xml);
     } catch (WxException $e) {
         $msg = $e->errorMessage();
         return false;
     }
     return call_user_func($callback, $result);
 }