Home >Backend Development >PHP Tutorial >WeChat Pay cannot obtain openid on some Android devices, but it can be obtained on IOS devices.

WeChat Pay cannot obtain openid on some Android devices, but it can be obtained on IOS devices.

WBOY
WBOYOriginal
2016-07-06 13:52:581664browse

There is no problem with WeChat payment on IOS devices, but Android devices have not been able to obtain openid, resulting in the inability to make payments. The error code returned by WeChat is 40029

Reply content:

There is no problem with WeChat payment on IOS devices, but Android devices have not been able to obtain openid, resulting in the inability to make payments. The error code returned by WeChat is 40029

It is because the WeChat server submitted the code several times that the code became invalid (the code can only be used once). If you add the log writing operation during execution, you can find that it was indeed executed twice! The problem after passing multiple tests is that the json data converted into an object when obtaining user information failed (that is, an exception), without trying it, causing the WeChat service to submit the same code to you again, and you have already used this code. So the 40029 problem occurs when obtaining access_token in the second step. (ps: I got it once before.)

Solution: Add a try catch as a whole to find the source of the problem and solve it!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn