优化Token验证接口
This commit is contained in:
@@ -443,31 +443,25 @@ class Playx extends Api
|
||||
$client = new \GuzzleHttp\Client($clientOptions);
|
||||
|
||||
if ($isAbsoluteVerifyUrl) {
|
||||
$merchantCode = strval(config('playx.angpow_import.merchant_code', ''));
|
||||
$authKey = strval(config('playx.angpow_import.auth_key', ''));
|
||||
if ($merchantCode === '' || $authKey === '') {
|
||||
if ($authKey === '') {
|
||||
return $this->error(__('PlayX API not configured'));
|
||||
}
|
||||
|
||||
// 与 angpow-imports 同源:HMAC-SHA1 → Base64;仅 X-Request-Signature;Body 对齐对端必填 request_date + PlayX 文档 request_id/token
|
||||
$requestDate = strval(time());
|
||||
$signatureInput = 'merchant_code=' . $merchantCode
|
||||
. '&request_date=' . $requestDate
|
||||
. '&request_id=' . $requestId
|
||||
. '&token=' . $token;
|
||||
// PlayX 文档:Body 仅 request_id + token。X-Request-Signature 与 angpow-imports 同源算法(HMAC-SHA1→Base64、密钥解析同 angpow),明文与 Body 字段一致。
|
||||
$signatureInput = 'request_id=' . $requestId . '&token=' . $token;
|
||||
$signature = $this->buildPlayxTokenVerifySignature($signatureInput, $authKey);
|
||||
if ($signature === null) {
|
||||
return $this->error(__('Invalid signature'), null, 0, ['statusCode' => 500]);
|
||||
}
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Request-Signature' => $signature,
|
||||
'Content-Type' => 'application/json',
|
||||
'X-Request-Signature' => $signature,
|
||||
];
|
||||
$payload = [
|
||||
'request_id' => $requestId,
|
||||
'request_date' => $requestDate,
|
||||
'token' => $token,
|
||||
'request_id' => $requestId,
|
||||
'token' => $token,
|
||||
];
|
||||
$res = $client->post($targetVerifyUrl, [
|
||||
'headers' => $headers,
|
||||
|
||||
Reference in New Issue
Block a user