Skip to content

Instantly share code, notes, and snippets.

@ashitvora-zz
Last active August 23, 2016 09:26
Show Gist options
  • Save ashitvora-zz/6973f00e5b4864526e1c to your computer and use it in GitHub Desktop.
Save ashitvora-zz/6973f00e5b4864526e1c 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