Wechat payment can only successfully call the solution to the problem once (Android)

I have been using Android for development for some time, but I have no systematics, and I have focused on server-side development for many years. I always feel that because the project needs to contact Android mobile terminal development is only temporary, I don't care too much. As a result, I encountered a big problem and tossed for a day. Finally, I was prompted by an experienced partner to solve it. At the same time, I feel ashamed, I'm also very happy. After all, I grow up after crossing one barrier after another. I'm ashamed here. I don't know if I'll become a cow in another place. Ha ha. Let's stop here and share:

It is necessary to briefly describe the overall process of wechat payment calling interface (at present, most of the online materials are codes adapted to the old version of wechat payment. There is no demo on the server in the latest wechat payment official document, and some interfaces have changed, and the parameter names have also changed. I hope my friends can pay attention to it) : 1. Wechat payment does not need to access the interface for obtaining token; 2. Direct access https://api.mch.weixin.qq.com/pay/unifiedorder Get prepayid and transfer the parameters in XML format; 3. With prepayid and some other parameters mentioned in the official website, you can adjust the wechat payment interface of the client;

At this time, there is a problem: the first call is very OK. You see the wechat payment interface, which has its own generated order number and amount. However, if you enter after giving up payment, even the wechat client can't call it. The same is true for another order. The first order is for another mobile phone. You can call the wechat client to display the order number and amount, But the second order can't say anything. It's fixed in the payment interface of its own app. There's no error, and there's no response.

The reason is here: when we apply for wechat payment, there is a place for you to fill in your application key:

After applying, you will see the application signature on the picture. How to generate this signature is described here: https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_ 5 the problem is that the generation of this key is related to the packaging and signing during the official release. When we release the Android application, we will add this key as the key of the application to prevent malicious coverage. When we apply to register the wechat application, we must provide the officially generated key of the application to the wechat official website.

Therefore, this matter was ignored, so that in the process of development, when we run and package locally, visit the wechat server and adjust the payment, wechat got the request from our application for the first time, as if it had established a connection and started a heartbeat,

At this time, wechat will asynchronously verify the saved application package name and application key with the package name and application key you are sending. I believe that even if you make payment for the first time, it is likely to be unsuccessful, but I have not verified this, because the verification results have been recalled back at this time.

Therefore, when the operation and maintenance personnel get the release, they will type the key into the APK installation package and package the formal key. The command is as follows:

The problem is solved. Wechat payment can be called smoothly every time you visit. I have to sigh that wechat also strictly controls the applications registered with him. Register one key and use one. If you want to use it again, go through the process again.

This article has been sorted into "Android wechat payment tutorial summary", welcome to learn and read.

For more highlights, click Android wechat development tutorial summary and Java wechat development tutorial summary. You are welcome to learn and read.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>