Tag Archives: Wechat payment API error

Wechat payment API V3 payment notice asynchronous signature verification failed

WeChat payment V3 asynchronous check failed
Here we receive parameters (message body) generally through the framework of the built-in request.
TP6: $this-> request-> param();
if you use the receive mode in here to convert the json attestation will fail.
We need to use the native receive method: file_get_contents(‘ PHP ://input ‘);
directly take the data after receiving the signature verification.

public function verifySign()
    {
        $timestamp = "Timestamp in header header";
        $nonce = "random string in header header";
        $signature = "signature in header header";
        $certZs = "Platform certificate";//        $data = $this->request->param();
        $data = file_get_contents('php://input');

        $message = "$timestamp\n$nonce\n$data\n";

        //Verify signature

        if (!$this->verify($message, $signature, $certZs)) {
            throw new \Exception('Failed visa check', 123456);
        }
    }123456789101112131415161718