File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,24 @@ public static function __callStatic($method, $args)
194194 throw new Exception \ApiException ("Call to undefined function {$ method }" );
195195 }
196196
197+ /**
198+ * Verify that HMAC hash of parameters matches HMAC signature
199+ * @return [type] [description]
200+ */
201+ public static function validateHmac ()
202+ {
203+ $ params = [];
204+ foreach ($ _GET as $ param => $ value ) {
205+ if ($ param != 'signature ' && $ param != 'hmac ' ) {
206+ $ params [$ param ] = "{$ param }= {$ value }" ;
207+ }
208+ }
209+ asort ($ params );
210+ $ params = implode ("& " , $ params );
211+
212+ return $ _GET ['hmac ' ] === hash_hmac ('sha256 ' , $ params , self ::$ api_secret );
213+ }
214+
197215 /**
198216 * Return the root API url based on the authenticated store
199217 * @return string
You can’t perform that action at this time.
0 commit comments