Skip to content

Instantly share code, notes, and snippets.

@gradosevic
Forked from ashitvora-zz/JVZoo.php
Created August 23, 2016 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gradosevic/d23a01973c374bf4d20d1f2892100a7f to your computer and use it in GitHub Desktop.
Save gradosevic/d23a01973c374bf4d20d1f2892100a7f to your computer and use it in GitHub Desktop.
Verify JVZoo Request
<?php namespace Alfanso\Services\Jvzoo;
class Jvzoo {
public function isValidRequest($data) {
$jvzooSecretKey = config('jvzoo.secret_key');
$receivedVerificationCode = $data['cverify'];
// remove cverify from the array since we don't use that
unset($data['cverify']);
// sort array by key
ksort($data);
// get only the values
$verficationData = array_values($data);
// add JVZoo secret key
$verificatonData[] = $jvzooSecretKey;
// Join by Pipe
$verificationCode = sha1(mb_convert_encoding(implode("|", $verificationData), "UTF-8"));
// Strip It
$strippedVerificationCode = strtoupper(substr($verificationCode, 0, 8));
return $strippedVerificationCode === $receivedVerificationCode;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment