Last active
August 23, 2016 09:26
-
-
Save ashitvora-zz/6973f00e5b4864526e1c to your computer and use it in GitHub Desktop.
Verify JVZoo Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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