Recently, the new app needs to integrate WeChat payment , because we know that there are many pits in WeChat payment. Although the previous App has integrated WeChat payment, it is still cautious when it is copied and copied, but the result is still not satisfactory. ios prompts a signature error , Android calls WeChat white screen and errCode=-1 . According to the official WeChat interpretation of the code, we have checked the signature , APPID and background order parameters back and forth on both ends of Android, ios and backend . There is still no clue about the processing. After more than a day of various search tests, the back-end colleagues shouted and found that the judgment on the sign encryption type processing in the copied WeChat official java file WXPAY.java was the root cause. ,code show as below:
Regarding the method for the client to call WeChat, the official WeChat document does not explain, most of the blog posts are also covered in one stroke, as follows:
When I tested the payment, I found that on WeChat that is not the latest version, although the isWXAppSupportAPI() of the API indicates that the current WeChat version does not support payment , it can actually call WeChat for payment, so I only used the isWXAppInstalled() method to determine , If installed, directly call WeChat to pay.
On IOS, most manufacturers’ apps use the openWXApp() method that calls the API first , and then calls WeChat payment.