Use WebView in APP to call up H5 payment

WeChat H5 payment development official documentation reference: https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_4 

 

0. Scenario description: Use webView in the APP to display the third-party H5, the WeChat payment process is involved in H5, and the payment cannot be made normally, and it prompts "The merchant parameter format is incorrect, please contact the merchant to solve it ".

1. Clue analysis: Refer to the official documentation of WeChat H5 payment development, mentioning " If H5 payment is activated in the APP, you need to manually set the referer in the webview ", the details are as follows, or refer to the official documentation: PS@Official Documentation--Thanks

1. 1 Solution: According to the description of the official document, after adding the referer, it is found that this error is still prompted:

 

2. Lead analysis: After asking the H5 front-end technicians, it is reported that the referer needs to be set and updated in real time. Each page must obtain the referer of the previous interface, and then pass it to the next page , rather than the same layer. PS@H5 front-end technology -- thanks

2.1 Solution strategy: Through clue analysis, two important clues are known ->

  Num 1: The referer needs to be updated in real time -> the referer needs to be set in real time in WebViewClient -> shouldOverrideUrlLoading() instead of only setting the referer in the outermost layer;

  Num 2: Each page needs to get the referer of the previous interface, and then pass it to the next page  -> get the referer of the previous interface and pass it to the next page;

2.2 Small problems encountered *#110*#: There is no related method to obtain referer in WebView. What kind of ghost is referer? ? ? ? ? ? ? ? ? ?

  Guess: According to the meaning of the word, does it refer to the URL of the previous interface, that is, the source of the page?

  Try: use the authorized domain name as the initial referer, and then save the url of the previous page as the referer of the next page each time 

 

Run the code - "Debug -" problem solved.

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325560522&siteId=291194637