This commit is contained in:
aozhiwei 2023-08-02 14:10:00 +08:00
parent 7fedd3720d
commit d36d5a67fc

View File

@ -204,9 +204,24 @@ class InAppPurchase {
$this->_rspOk();
}
private function verifySign()
private function verifySign($data)
{
$channel = $data['channel'];
$records = $data['records'];
$sign = $data['sign'];
$strings = array();
foreach ($records as $record) {
ksort($record);
foreach($record as $key => $val){
array_push($strings, $key . '=' . $val);
}
}
$signStr = 'channel=' . $channel . '&' . implode("&", $strings);
error_log('InAppPurchase verify ' . $signStr);
$signature = hash_hmac('sha256', $singStr, BUY_SERVER_PKEY);
return $sign == $signature;
}
}