· 9 years ago · Jan 30, 2017, 09:08 PM
1$data = [];
2 foreach ($params as $key => $value) {
3 $key = str_replace('%', '%25', $key);
4 $key = str_replace('&', '%26', $key);
5 $key = str_replace('=', '%3D', $key);
6 $value = str_replace('%', '%25', $value);
7 $value = str_replace('&', '%26', $value);
8 $compute_array[$key] = $value;
9 $data[$key] = $value;
10 }
11 $secret_key = env('SHOPIFY_API_SECRET');
12 //dd(http_build_query($data));
13 $hmac = hash_hmac('sha256', http_build_query($data), $secret_key, false);
14
15 if ($hmac != $request->get('hmac')) {
16 Log::error('Invalid hmac hash');
17 abort(403); //invalid hmac
18 }