The following error occurred while calling Alipay payment:
After referring to the official error-free document (RSA2 the private key to fill in the wrong set), still did not find the problem.
Finally, a step-by-step breakpoint debugging found that the original project to configure the merchant's private key is directly read. A PEM private key file that already contains the "BEGIN" and "End" tails, And the official SDK provided in the aopclient.php file in the sign method has such a piece of code:
That is, only the main body of the merchant's private key, the beginning and the program has automatically helped us Add.
So I saved the back of the. pem file and then read it again, and found that the same error was reported. After some debugging, the original is my editor at the time of saving automatically at the end of the file to add a line of blank, after the sign function, the merchant's private key to the head and tail, however, "end" before a line more than a row, resulting in the final signature parameter value is an empty string. After the blank line is removed, everything runs smoothly.
It is recommended to configure Alipay payment configuration when the text is read, as far as possible not to read the way the file.