Home > Article > Backend Development > WeChat Pay cannot obtain openid on some Android devices, but it can be obtained on IOS devices.
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
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!